From 3ee86835c2c311636351ce6f476c7cd38805e60e Mon Sep 17 00:00:00 2001 From: manunio Date: Sun, 14 Aug 2022 19:31:33 +0530 Subject: [PATCH 1/2] yaml-rust: initial integration --- projects/yaml-rust/Dockerfile | 25 ++++++++++++++ projects/yaml-rust/build.sh | 20 +++++++++++ projects/yaml-rust/fuzz/Cargo.toml | 34 +++++++++++++++++++ .../fuzz/fuzz_targets/fuzz_from_str.rs | 27 +++++++++++++++ projects/yaml-rust/project.yaml | 10 ++++++ 5 files changed, 116 insertions(+) create mode 100644 projects/yaml-rust/Dockerfile create mode 100755 projects/yaml-rust/build.sh create mode 100644 projects/yaml-rust/fuzz/Cargo.toml create mode 100644 projects/yaml-rust/fuzz/fuzz_targets/fuzz_from_str.rs create mode 100644 projects/yaml-rust/project.yaml diff --git a/projects/yaml-rust/Dockerfile b/projects/yaml-rust/Dockerfile new file mode 100644 index 000000000000..724182eb7859 --- /dev/null +++ b/projects/yaml-rust/Dockerfile @@ -0,0 +1,25 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder-rust + +RUN apt-get update && apt-get install -y make autoconf automake libtool +RUN git clone --depth 1 https://github.com/chyh1990/yaml-rust yaml-rust + +COPY fuzz $SRC/yaml-rust/fuzz +WORKDIR $SRC + +COPY build.sh $SRC/ \ No newline at end of file diff --git a/projects/yaml-rust/build.sh b/projects/yaml-rust/build.sh new file mode 100755 index 000000000000..beaed0b783e0 --- /dev/null +++ b/projects/yaml-rust/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash -eu +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +cd $SRC/yaml-rust +cargo fuzz build -O +cp fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_from_str $OUT/ \ No newline at end of file diff --git a/projects/yaml-rust/fuzz/Cargo.toml b/projects/yaml-rust/fuzz/Cargo.toml new file mode 100644 index 000000000000..cfea4ff80a47 --- /dev/null +++ b/projects/yaml-rust/fuzz/Cargo.toml @@ -0,0 +1,34 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +[package] +name = "yaml-rust-fuzz" +version = "0.0.0" +edition = "2021" +publish = false + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" +yaml-rust = { path = ".." } + +[[bin]] +name = "fuzz_from_str" +path = "fuzz_targets/fuzz_from_str.rs" + +[workspace] \ No newline at end of file diff --git a/projects/yaml-rust/fuzz/fuzz_targets/fuzz_from_str.rs b/projects/yaml-rust/fuzz/fuzz_targets/fuzz_from_str.rs new file mode 100644 index 000000000000..d80e4d95c9dc --- /dev/null +++ b/projects/yaml-rust/fuzz/fuzz_targets/fuzz_from_str.rs @@ -0,0 +1,27 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//############################################################################### + +#![no_main] + +use libfuzzer_sys::fuzz_target; +use std::str; +use yaml_rust::*; + +fuzz_target!(|data: &[u8]| { + if let Ok(utf8) = str::from_utf8(data) { + let _ = YamlLoader::load_from_str(utf8); + } +}); diff --git a/projects/yaml-rust/project.yaml b/projects/yaml-rust/project.yaml new file mode 100644 index 000000000000..b7e4942d881f --- /dev/null +++ b/projects/yaml-rust/project.yaml @@ -0,0 +1,10 @@ +homepage: "https://github.com/chyh1990/yaml-rust" +language: rust +main_repo: "https://github.com/chyh1990/yaml-rust" +fuzzing_engines: + - libfuzzer +sanitizers: + - address +vendor_ccs: + - maxnair.dev@gmail.com +file_github_issue: true From e441b64eaa90d7c2ca35745347f231877b511d1d Mon Sep 17 00:00:00 2001 From: manunio Date: Fri, 19 Aug 2022 15:06:13 +0530 Subject: [PATCH 2/2] Removes file_github_issue #8294 disables file_github_issue, until maintainer explicitly mentions it. --- projects/yaml-rust/project.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/yaml-rust/project.yaml b/projects/yaml-rust/project.yaml index b7e4942d881f..241b6dddb60d 100644 --- a/projects/yaml-rust/project.yaml +++ b/projects/yaml-rust/project.yaml @@ -7,4 +7,3 @@ sanitizers: - address vendor_ccs: - maxnair.dev@gmail.com -file_github_issue: true