diff --git a/fuzzing/private/binary.bzl b/fuzzing/private/binary.bzl index 93da31e..4c85aed 100644 --- a/fuzzing/private/binary.bzl +++ b/fuzzing/private/binary.bzl @@ -34,6 +34,8 @@ Provider for storing information about a fuzz test binary. fields = { "binary_file": "The instrumented fuzz test executable.", "binary_runfiles": "The runfiles of the fuzz test executable.", + "binary_repo_mapping_manifest": "The _repo_mapping file of the fuzz " + + "test executable.", "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 " + @@ -108,9 +110,11 @@ def _fuzzing_binary_impl(ctx): ) if ctx.attr._instrument_binary: # The attribute is a list if a transition is attached. - binary_runfiles = ctx.attr.binary[0][DefaultInfo].default_runfiles + default_info = ctx.attr.binary[0][DefaultInfo] else: - binary_runfiles = ctx.attr.binary[DefaultInfo].default_runfiles + default_info = ctx.attr.binary[DefaultInfo] + binary_runfiles = default_info.default_runfiles + binary_repo_mapping_manifest = getattr(default_info.files_to_run, "repo_mapping_manifest") other_runfiles = [] if ctx.file.corpus: other_runfiles.append(ctx.file.corpus) @@ -126,6 +130,7 @@ def _fuzzing_binary_impl(ctx): FuzzingBinaryInfo( binary_file = ctx.executable.binary, binary_runfiles = binary_runfiles, + binary_repo_mapping_manifest = binary_repo_mapping_manifest, corpus_dir = ctx.file.corpus, dictionary_file = ctx.file.dictionary, engine_info = ctx.attr.engine[FuzzingEngineInfo], diff --git a/fuzzing/private/oss_fuzz/package.bzl b/fuzzing/private/oss_fuzz/package.bzl index e0ae8ed..f98d361 100644 --- a/fuzzing/private/oss_fuzz/package.bzl +++ b/fuzzing/private/oss_fuzz/package.bzl @@ -41,6 +41,8 @@ def _oss_fuzz_package_impl(ctx): ctx.actions.write(runfiles_manifest, runfiles_manifest_content, False) archive_inputs.append(runfiles_manifest) + if binary_info.binary_repo_mapping_manifest: + archive_inputs.append(binary_info.binary_repo_mapping_manifest) if binary_info.corpus_dir: archive_inputs.append(binary_info.corpus_dir) if binary_info.dictionary_file: @@ -61,6 +63,9 @@ def _oss_fuzz_package_impl(ctx): mkdir -p "$(dirname "$STAGING_DIR/{binary_runfiles_dir}/$link")" ln -s "$(pwd)/$target" "$STAGING_DIR/{binary_runfiles_dir}/$link" done <{runfiles_manifest_path} + if [[ -n "{binary_repo_mapping_manifest}" ]]; then + ln -s "$(pwd)/{binary_repo_mapping_manifest}" "$STAGING_DIR/{binary_runfiles_dir}/_repo_mapping" + fi if [[ -n "{corpus_dir}" ]]; then pushd "{corpus_dir}" >/dev/null zip --quiet -r "$STAGING_DIR/{base_name}_seed_corpus.zip" ./* @@ -77,6 +82,7 @@ def _oss_fuzz_package_impl(ctx): base_name = ctx.attr.base_name, binary_path = binary_info.binary_file.path, binary_runfiles_dir = ctx.attr.base_name + ".runfiles", + binary_repo_mapping_manifest = binary_info.binary_repo_mapping_manifest.path if binary_info.binary_repo_mapping_manifest else "", 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 "",