diff --git a/infra/base-images/base-runner/coverage b/infra/base-images/base-runner/coverage index ea6acc34d..54154212d 100755 --- a/infra/base-images/base-runner/coverage +++ b/infra/base-images/base-runner/coverage @@ -61,6 +61,8 @@ objects="" # Number of CPUs available, this is needed for running tests in parallel. NPROC=$(nproc) +CORPUS_DIR=${CORPUS_DIR:-"/corpus"} + function run_fuzz_target { local target=$1 @@ -69,7 +71,7 @@ function run_fuzz_target { local profraw_file="$DUMPS_DIR/$target.%1m.profraw" local profraw_file_mask="$DUMPS_DIR/$target.*.profraw" local profdata_file="$DUMPS_DIR/$target.profdata" - local corpus_real="/corpus/${target}" + local corpus_real="$CORPUS_DIR/${target}" # -merge=1 requires an output directory, create a new, empty dir for that. local corpus_dummy="$OUT/dummy_corpus_dir_for_${target}" @@ -122,7 +124,7 @@ function run_go_fuzz_target { local target=$1 echo "Running go target $target" - export FUZZ_CORPUS_DIR="/corpus/${target}/" + export FUZZ_CORPUS_DIR="$CORPUS_DIR/${target}/" export FUZZ_PROFILE_NAME="$DUMPS_DIR/$target.perf" $OUT/$target -test.coverprofile $DUMPS_DIR/$target.profdata &> $LOGS_DIR/$target.log # translate from golangish paths to current absolute paths @@ -138,7 +140,7 @@ function run_java_fuzz_target { local exec_file="$DUMPS_DIR/$target.exec" local class_dump_dir="$DUMPS_DIR/${target}_classes/" mkdir "$class_dump_dir" - local corpus_real="/corpus/${target}" + local corpus_real="$CORPUS_DIR/${target}" # -merge=1 requires an output directory, create a new, empty dir for that. local corpus_dummy="$OUT/dummy_corpus_dir_for_${target}" diff --git a/infra/cifuzz/generate_coverage_report.py b/infra/cifuzz/generate_coverage_report.py index 7e427ab6d..fa4fc8339 100644 --- a/infra/cifuzz/generate_coverage_report.py +++ b/infra/cifuzz/generate_coverage_report.py @@ -24,6 +24,7 @@ def run_coverage_command(workspace, config): config.language) docker_args += [ '-e', 'COVERAGE_EXTRA_ARGS=', '-e', 'HTTP_PORT=', '-e', + f'CORPUS_DIR={workspace.corpora}', '-e', f'COVERAGE_OUTPUT_DIR={workspace.coverage_report}', '-t', docker.BASE_RUNNER_TAG, 'coverage' ] @@ -32,8 +33,7 @@ def run_coverage_command(workspace, config): def download_corpora(fuzz_target_paths, clusterfuzz_deployment): """Downloads corpora for fuzz targets in |fuzz_target_paths| using - clusterfuzz_deployment| to download corpora from ClusterFuzz/OSS-Fuzz.""" - # TODO(metzman): Download to /corpus dir. + |clusterfuzz_deployment| to download corpora from ClusterFuzz/OSS-Fuzz.""" for target_path in fuzz_target_paths: target = os.path.basename(target_path) clusterfuzz_deployment.download_corpus(target) diff --git a/infra/cifuzz/generate_coverage_report_test.py b/infra/cifuzz/generate_coverage_report_test.py index b5f2b489a..c34939f0f 100644 --- a/infra/cifuzz/generate_coverage_report_test.py +++ b/infra/cifuzz/generate_coverage_report_test.py @@ -40,6 +40,7 @@ class TestRunCoverageCommand(unittest.TestCase): 'OUT=/workspace/build-out', '-v', f'{workspace.workspace}:{workspace.workspace}', '-e', 'COVERAGE_EXTRA_ARGS=', '-e', 'HTTP_PORT=', '-e', + f'CORPUS_DIR={workspace.corpora}', '-e', f'COVERAGE_OUTPUT_DIR={workspace.coverage_report}', '-t', 'gcr.io/oss-fuzz-base/base-runner', 'coverage' ]