From a9240f097fff33f104544fb48716af2cb81de2af Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Sat, 13 Mar 2021 04:40:33 +0000 Subject: [PATCH] json5format initial integration (#5354) * json5format initial integration * Updated the dockerfile for json5format. --- projects/json5format/Dockerfile | 22 +++++++++++++++++ projects/json5format/build.sh | 22 +++++++++++++++++ projects/json5format/fuzz/.gitignore | 4 ++++ projects/json5format/fuzz/Cargo.toml | 24 +++++++++++++++++++ .../fuzz/fuzz_targets/fuzz_parse.rs | 10 ++++++++ projects/json5format/project.yaml | 10 ++++++++ 6 files changed, 92 insertions(+) create mode 100644 projects/json5format/Dockerfile create mode 100755 projects/json5format/build.sh create mode 100644 projects/json5format/fuzz/.gitignore create mode 100644 projects/json5format/fuzz/Cargo.toml create mode 100644 projects/json5format/fuzz/fuzz_targets/fuzz_parse.rs create mode 100644 projects/json5format/project.yaml diff --git a/projects/json5format/Dockerfile b/projects/json5format/Dockerfile new file mode 100644 index 000000000..d02fd602d --- /dev/null +++ b/projects/json5format/Dockerfile @@ -0,0 +1,22 @@ +# Copyright 2021 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 + +RUN git clone --depth 1 https://github.com/google/json5format +WORKDIR $SRC + +COPY build.sh $SRC/ +COPY fuzz $SRC/json5format/fuzz diff --git a/projects/json5format/build.sh b/projects/json5format/build.sh new file mode 100755 index 000000000..a5647513b --- /dev/null +++ b/projects/json5format/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash -eu +# Copyright 2021 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/json5format +cargo fuzz build -O +ls -la ./fuzz +ls -la ./fuzz/target +cp ./fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_parse $OUT/fuzz_parse diff --git a/projects/json5format/fuzz/.gitignore b/projects/json5format/fuzz/.gitignore new file mode 100644 index 000000000..572e03bdf --- /dev/null +++ b/projects/json5format/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/projects/json5format/fuzz/Cargo.toml b/projects/json5format/fuzz/Cargo.toml new file mode 100644 index 000000000..4ac2c0324 --- /dev/null +++ b/projects/json5format/fuzz/Cargo.toml @@ -0,0 +1,24 @@ + +[package] +name = "json5format-fuzz" +version = "0.0.0" +authors = ["David Korczynski "] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.3" + +[dependencies.json5format] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "fuzz_parse" +path = "fuzz_targets/fuzz_parse.rs" diff --git a/projects/json5format/fuzz/fuzz_targets/fuzz_parse.rs b/projects/json5format/fuzz/fuzz_targets/fuzz_parse.rs new file mode 100644 index 000000000..35e3a7c7a --- /dev/null +++ b/projects/json5format/fuzz/fuzz_targets/fuzz_parse.rs @@ -0,0 +1,10 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use json5format::*; +use std::str; + +fuzz_target!(|data: &[u8]| { + if let Ok(utf8) = str::from_utf8(data) { + ParsedDocument::from_str(utf8, None); + } +}); diff --git a/projects/json5format/project.yaml b/projects/json5format/project.yaml new file mode 100644 index 000000000..e73905ebe --- /dev/null +++ b/projects/json5format/project.yaml @@ -0,0 +1,10 @@ +homepage: "https://crates.io/crates/json5format" +main_repo: "https://github.com/google/json5format" +primary_contact: "richkadel@google.com" +sanitizers: + - address +fuzzing_engines: + - libfuzzer +language: rust +auto_ccs: + - "david@adalogics.com"