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

Add support for .options files to fuzzing_binary #148

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions fuzzing/private/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Provider for storing information about a fuzz test binary.
"corpus_dir": "The directory of the corpus files used as input seeds.",
"dictionary_file": "The dictionary file to use in fuzzing runs.",
"engine_info": "The `FuzzingEngineInfo` provider of the fuzzing engine used in the fuzz test.",
"options_file": "The .options file to use in OSS-Fuzz.",
fmeum marked this conversation as resolved.
Show resolved Hide resolved
},
)

Expand Down Expand Up @@ -110,6 +111,8 @@ def _fuzzing_binary_impl(ctx):
other_runfiles.append(ctx.file.corpus)
if ctx.file.dictionary:
other_runfiles.append(ctx.file.dictionary)
if ctx.file.options:
other_runfiles.append(ctx.file.options)
return [
DefaultInfo(
executable = output_file,
Expand All @@ -121,6 +124,7 @@ def _fuzzing_binary_impl(ctx):
corpus_dir = ctx.file.corpus,
dictionary_file = ctx.file.dictionary,
engine_info = ctx.attr.engine[FuzzingEngineInfo],
options_file = ctx.file.options,
),
]

Expand Down Expand Up @@ -158,6 +162,10 @@ The instrumentation is controlled by the following flags:
doc = "A dictionary file to use in fuzzing runs.",
allow_single_file = True,
),
"options": attr.label(
doc = "A file with INI-style options for OSS-Fuzz.",
fmeum marked this conversation as resolved.
Show resolved Hide resolved
allow_single_file = True,
),
"_allowlist_function_transition": attr.label(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
Expand Down Expand Up @@ -198,6 +206,10 @@ be incorporated in the target configuration (e.g., on the command line or the
doc = "A dictionary file to use in fuzzing runs.",
allow_single_file = True,
),
"options": attr.label(
doc = "A file with INI-style options for OSS-Fuzz.",
allow_single_file = True,
),
fmeum marked this conversation as resolved.
Show resolved Hide resolved
"_instrument_binary": attr.bool(
default = False,
),
Expand Down
4 changes: 4 additions & 0 deletions fuzzing/private/oss_fuzz/package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ def _oss_fuzz_package_impl(ctx):
if [[ -n "{dictionary_path}" ]]; then
ln -s "$(pwd)/{dictionary_path}" "$STAGING_DIR/{base_name}.dict"
fi
if [[ -n "{options_path}" ]]; then
ln -s "$(pwd)/{options_path}" "$STAGING_DIR/{base_name}.options"
fi
tar -chf "{output}" -C "$STAGING_DIR" .
""".format(
base_name = ctx.attr.base_name,
binary_path = binary_info.binary_file.path,
corpus_dir = binary_info.corpus_dir.path if binary_info.corpus_dir else "",
dictionary_path = binary_info.dictionary_file.path if binary_info.dictionary_file else "",
options_path = binary_info.options_file.path if binary_info.options_file else "",
output = output_archive.path,
),
)
Expand Down