Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml-rust: initial integration #8250

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions projects/yaml-rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
20 changes: 20 additions & 0 deletions projects/yaml-rust/build.sh
Original file line number Diff line number Diff line change
@@ -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/
34 changes: 34 additions & 0 deletions projects/yaml-rust/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
27 changes: 27 additions & 0 deletions projects/yaml-rust/fuzz/fuzz_targets/fuzz_from_str.rs
Original file line number Diff line number Diff line change
@@ -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);
}
});
9 changes: 9 additions & 0 deletions projects/yaml-rust/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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