From 124db941a74d4ba10b42713845fb86792586edbd Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 11 May 2021 19:10:54 +0200 Subject: [PATCH] [infra] Fix java coverage (#5747) * Filter non-fuzz target binaries in coverage script * Filter non-fuzz target binaries in helper.py * Fix fuzz target executable bit check in helper.py Python and JVM fuzz target executables created via the docs template set the exectuable via `chmod u+x` as the root user, which means that os.access checks in infra/helper.py don't see the exectuable bit if not run as root locally. With this commit, the check now looks for any of the three exectuable bits. --- infra/base-images/base-runner/coverage | 7 ++++++- infra/helper.py | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/infra/base-images/base-runner/coverage b/infra/base-images/base-runner/coverage index 3a72b2fe6..5b37b946f 100755 --- a/infra/base-images/base-runner/coverage +++ b/infra/base-images/base-runner/coverage @@ -19,7 +19,12 @@ cd $OUT if (( $# > 0 )); then FUZZ_TARGETS="$@" else - FUZZ_TARGETS="$(find . -maxdepth 1 -type f -executable -printf '%P\n')" + FUZZ_TARGETS="$(find . -maxdepth 1 -type f -executable -printf '%P\n' | \ + grep -v -x -F \ + -e 'llvm-symbolizer' \ + -e 'jazzer_agent_deploy.jar' \ + -e 'jazzer_driver' \ + -e 'jazzer_driver_asan')" fi DUMPS_DIR="$OUT/dumps" diff --git a/infra/helper.py b/infra/helper.py index 5a96c949d..ee476d1e6 100755 --- a/infra/helper.py +++ b/infra/helper.py @@ -680,9 +680,15 @@ def _get_fuzz_targets(project_name): for name in os.listdir(_get_out_dir(project_name)): if name.startswith('afl-'): continue + if name.startswith('jazzer_'): + continue + if name == 'llvm-symbolizer': + continue path = os.path.join(_get_out_dir(project_name), name) - if os.path.isfile(path) and os.access(path, os.X_OK): + # Python and JVM fuzz targets are only executable for the root user, so + # we can't use os.access. + if os.path.isfile(path) and (os.stat(path).st_mode & 0o111): fuzz_targets.append(name) return fuzz_targets