Skip to content
Open
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
10 changes: 10 additions & 0 deletions fuzzing/engines/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ cc_fuzzing_engine(
name = "libfuzzer",
display_name = "libFuzzer",
launcher = "libfuzzer_launcher.sh",
launcher_data = {
"//fuzzing/tools:realpath": "REALPATH_PATH",
},
library = ":libfuzzer_stub",
visibility = ["//visibility:public"],
)
Expand All @@ -46,6 +49,7 @@ cc_fuzzing_engine(
launcher = "honggfuzz_launcher.sh",
launcher_data = {
"@honggfuzz//:honggfuzz": "HONGGFUZZ_PATH",
"//fuzzing/tools:realpath": "REALPATH_PATH",
},
library = "@honggfuzz//:honggfuzz_engine",
visibility = ["//visibility:public"],
Expand All @@ -58,6 +62,9 @@ cc_fuzzing_engine(
name = "replay",
display_name = "Replay",
launcher = "replay_launcher.sh",
launcher_data = {
"//fuzzing/tools:realpath": "REALPATH_PATH",
},
library = "//fuzzing/replay:replay_main",
visibility = ["//visibility:public"],
)
Expand All @@ -69,6 +76,9 @@ java_fuzzing_engine(
name = "jazzer",
display_name = "Jazzer",
launcher = "jazzer_launcher.sh",
launcher_data = {
"//fuzzing/tools:realpath": "REALPATH_PATH",
},
library = "@jazzer//agent:jazzer_api_compile_only",
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion fuzzing/engines/honggfuzz_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

command_line="$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${HONGGFUZZ_PATH})"
command_line="$("${REALPATH_PATH}" ${HONGGFUZZ_PATH})"
command_line+=("--workspace=${FUZZER_OUTPUT_ROOT}")

if [[ -n "${FUZZER_SEED_CORPUS_DIR}" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion fuzzing/engines/jazzer_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# engine. The launch configuration is supplied by the launcher script through
# environment variables.

command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
command_line=("$("${REALPATH_PATH}" ${FUZZER_BINARY})")

# libFuzzer flags (compatible with Jazzer).

Expand Down
2 changes: 1 addition & 1 deletion fuzzing/engines/libfuzzer_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# libFuzzer engine. The launch configuration is supplied by the launcher
# script through environment variables.

command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
command_line=("$("${REALPATH_PATH}" ${FUZZER_BINARY})")

# libFuzzer flags.

Expand Down
2 changes: 1 addition & 1 deletion fuzzing/engines/replay_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (( ! FUZZER_IS_REGRESSION )); then
echo "NOTE: Non-regression mode is not supported by the replay engine."
fi

command_line=("$(python3 -c 'import os, sys; print(os.path.realpath(sys.argv[1]))' ${FUZZER_BINARY})")
command_line=("$("${REALPATH_PATH}" ${FUZZER_BINARY})")
if [[ -n "${FUZZER_SEED_CORPUS_DIR}" ]]; then
command_line+=("${FUZZER_SEED_CORPUS_DIR}")
fi
Expand Down
9 changes: 6 additions & 3 deletions fuzzing/private/engine.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def _make_fuzzing_engine_info(ctx):
if data_env_var:
if data_env_var in env_vars:
fail("Multiple data dependencies map to variable '%s'." % data_env_var)
if len(data_files) != 1:
fail("Data dependency for variable '%s' doesn't map to exactly one file." % data_env_var)
env_vars[data_env_var] = data_files[0]
if len(data_files) == 1:
env_vars[data_env_var] = data_files[0]
elif data_label.files_to_run.executable:
env_vars[data_env_var] = data_label.files_to_run.executable
else:
fail("Data dependency for variable '%s' is not a single file or executable." % data_env_var)
launcher_runfiles = launcher_runfiles.merge(ctx.runfiles(files = data_files))
launcher_runfiles = launcher_runfiles.merge(data_label[DefaultInfo].default_runfiles)

Expand Down
7 changes: 7 additions & 0 deletions fuzzing/tools/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ py_binary(
deps = [requirement("absl-py")],
)

py_binary(
name = "realpath",
srcs = ["realpath.py"],
python_version = "PY3",
visibility = ["//visibility:public"],
)

py_binary(
name = "validate_dict",
srcs = ["validate_dict.py"],
Expand Down
27 changes: 27 additions & 0 deletions fuzzing/tools/realpath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2020 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.

# Lint as: python3
"""
Gets the realpath of a input path.

This is a portable replacement of `readlink -f`/`realpath`.
"""

import os, sys

if len(sys.argv) < 2:
print("Need an argument for the input path.", file=sys.stderr)
sys.exit(1)
print(os.path.realpath(sys.argv[1]))