-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test project for the Bazel fuzzing rules. (#4936)
* Proof of concept for Bazel support in OSS Fuzz. * Moved the Bazel rules project under a directory with a "-test" suffix, to better convey intent. * Added copyright header. * Update year in copyright note. * Factor out the '_oss_fuzz' package suffix to bash var. * Moving 'disabled' attribute at the end of the yaml file. * Simplified Dockerfile due to base image update.
- Loading branch information
1 parent
3fa5cb1
commit 5f6c8ad
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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 https://github.com/bazelbuild/rules_fuzzing.git | ||
WORKDIR $SRC/rules_fuzzing/ | ||
COPY build.sh $SRC/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/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. | ||
# | ||
################################################################################ | ||
|
||
declare -r QUERY=' | ||
let all_fuzz_tests = attr(tags, "fuzz-test", "//...") in | ||
$all_fuzz_tests - attr(tags, "no-oss-fuzz", $all_fuzz_tests) | ||
' | ||
declare -r PACKAGE_SUFFIX="_oss_fuzz" | ||
declare -r OSS_FUZZ_TESTS="$(bazel query "${QUERY}" | sed "s/$/${PACKAGE_SUFFIX}/")" | ||
|
||
bazel build -c opt --config=oss-fuzz --linkopt=-lc++ ${OSS_FUZZ_TESTS[*]} | ||
for oss_fuzz_archive in $(find bazel-bin/ -name "*${PACKAGE_SUFFIX}.tar"); do | ||
tar -xvf "${oss_fuzz_archive}" -C "${OUT}" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
homepage: "https://github.com/bazelbuild/rules_fuzzing" | ||
language: c++ | ||
primary_contact: "test@example.com" | ||
|
||
fuzzing_engines: | ||
- libfuzzer | ||
- afl | ||
- honggfuzz | ||
- dataflow | ||
|
||
sanitizers: | ||
- address | ||
- undefined | ||
- memory | ||
- dataflow | ||
|
||
# This is a test project. | ||
disabled: true |