-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for Bzlmod Requires fixing a case of a non-hermetic Python import in `dict_validation_test` that breaks with Python 3.11, with which Bazel uses `PYTHONSAFEPATH` by default. A follow-up PR will provide the publishing setup for releases to the Bazel Central Registry (BCR). * Disable layering_check for OSS-Fuzz OSS-Fuzz builds fail with: ``` ERROR: /root/.cache/bazel/_bazel_root/17db7bb59affe64429348778697da03a/external/abseil-cpp~20230802.1/absl/strings/BUILD.bazel:591:11: Compiling absl/strings/internal/cordz_functions.cc failed: undeclared inclusion(s) in rule '@@abseil-cpp~20230802.1//absl/strings:cordz_functions': this rule is missing dependency declarations for the following files included by 'absl/strings/internal/cordz_functions.cc': 'bazel-out/k8-opt-ST-b76ee6246659/bin/external/abseil-cpp~20230802.1/absl/base/atomic_hook.cppmap' 'bazel-out/k8-opt-ST-b76ee6246659/bin/external/abseil-cpp~20230802.1/absl/base/errno_saver.cppmap' 'bazel-out/k8-opt-ST-b76ee6246659/bin/external/abseil-cpp~20230802.1/absl/base/log_severity.cppmap' ``` These files are emitted by Bazel when using the `layering_check` feature. This looks like a bug or breaking change in clang. * Revert "Disable layering_check for OSS-Fuzz" This reverts commit 60a831d. * Address review comments * Update abseil and use a custom repo_name * Add subproject to .bazelignore * Use `Label` in macros * Update Bazel to 7.0.2 and ignore WORKSPACE repos in example repo * Add _repo_mapping file if supported * Apply repo mapping to local_jdk exclusion * Fix failure if there are no runfiles * Make `local_jdk` visible
- Loading branch information
Showing
20 changed files
with
304 additions
and
25 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 @@ | ||
examples/bzlmod |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
7.0.0 | ||
7.0.2 |
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
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
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,75 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
module( | ||
name = "rules_fuzzing", | ||
# Automatically updated during releases by the Publish to BCR app. | ||
version = "0.0.0", | ||
) | ||
|
||
bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name = "com_google_absl") | ||
bazel_dep(name = "bazel_skylib", version = "1.5.0") | ||
bazel_dep(name = "platforms", version = "0.0.8") | ||
bazel_dep(name = "rules_python", version = "0.28.0") | ||
bazel_dep(name = "rules_java", version = "6.5.2") | ||
|
||
bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True, repo_name = "io_bazel_stardoc") | ||
bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True, repo_name = "com_google_googletest") | ||
bazel_dep(name = "re2", version = "2023-11-01", dev_dependency = True) | ||
|
||
non_module_dependencies = use_extension("//fuzzing/private:extensions.bzl", "non_module_dependencies") | ||
use_repo( | ||
non_module_dependencies, | ||
"honggfuzz", | ||
"rules_fuzzing_jazzer", | ||
"rules_fuzzing_jazzer_api", | ||
"rules_fuzzing_oss_fuzz", | ||
) | ||
|
||
SUPPORTED_PYTHON_VERSIONS = [ | ||
"3.8", | ||
"3.9", | ||
"3.10", | ||
"3.11", | ||
"3.12", | ||
] | ||
|
||
python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
|
||
[ | ||
python.toolchain( | ||
# Required to avoid an error when running as root in OSS-Fuzz. | ||
ignore_root_user_error = True, | ||
is_default = python_version == SUPPORTED_PYTHON_VERSIONS[-1], | ||
python_version = python_version, | ||
) | ||
for python_version in SUPPORTED_PYTHON_VERSIONS | ||
] | ||
|
||
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip") | ||
|
||
[ | ||
pip.parse( | ||
extra_pip_args = ["--require-hashes"], | ||
hub_name = "rules_fuzzing_py_deps", | ||
python_version = python_version, | ||
requirements_lock = "//fuzzing:requirements.txt", | ||
) | ||
for python_version in SUPPORTED_PYTHON_VERSIONS | ||
] | ||
|
||
use_repo(pip, fuzzing_py_deps = "rules_fuzzing_py_deps") | ||
|
||
java_toolchains = use_extension("@rules_java//java:extensions.bzl", "toolchains") | ||
use_repo(java_toolchains, "local_jdk") |
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,17 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
# Intentionally left blank as all deps are defined in MODULE.bazel. | ||
# By having this file exist, Bazel will not add the repositories defined in the implicit | ||
# "WORKSPACE suffix" with --enable_bzlmod. |
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,17 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
common --repo_env=CC=clang | ||
common --@my_rules_fuzzing//fuzzing:cc_engine_instrumentation=libfuzzer | ||
common --@my_rules_fuzzing//fuzzing:cc_engine_sanitizer=asan |
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,27 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
load("@my_rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzz_test") | ||
load("@my_rules_fuzzing//fuzzing:java_defs.bzl", "java_fuzz_test") | ||
|
||
cc_fuzz_test( | ||
name = "cc_fuzz_test", | ||
srcs = ["cc_fuzz_test.cc"], | ||
) | ||
|
||
java_fuzz_test( | ||
name = "java_fuzz_test", | ||
srcs = ["JavaFuzzTest.java"], | ||
target_class = "com.example.JavaFuzzTest", | ||
) |
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,23 @@ | ||
// Copyright 2024 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. | ||
|
||
// A plain fuzz target that does nothing. | ||
|
||
package com.example; | ||
|
||
import com.code_intelligence.jazzer.api.FuzzedDataProvider; | ||
|
||
public class JavaFuzzTest { | ||
public static void fuzzerTestOneInput(FuzzedDataProvider data) {} | ||
} |
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 2024 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 | ||
# | ||
# https://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. | ||
|
||
# We use a custom repo_name to verify that e.g. macros do not contain hard-coded | ||
# references to rules_fuzzing. | ||
bazel_dep(name = "rules_fuzzing", repo_name = "my_rules_fuzzing") | ||
local_path_override( | ||
module_name = "rules_fuzzing", | ||
path = "../..", | ||
) |
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,17 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
# Intentionally left blank as all deps are defined in MODULE.bazel. | ||
# By having this file exist, Bazel will not add the repositories defined in the implicit | ||
# "WORKSPACE suffix" with --enable_bzlmod. |
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,22 @@ | ||
// Copyright 2024 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. | ||
|
||
// A plain fuzz target that does nothing (just returns). | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
return 0; | ||
} |
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
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
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,22 @@ | ||
# Copyright 2024 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 | ||
# | ||
# https://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. | ||
|
||
"""Internal dependencies that are not Bazel modules.""" | ||
|
||
load("//fuzzing:repositories.bzl", "rules_fuzzing_dependencies") | ||
|
||
def _non_module_dependencies(_): | ||
rules_fuzzing_dependencies() | ||
|
||
non_module_dependencies = module_extension(_non_module_dependencies) |
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
Oops, something went wrong.