From 689c3f4b65b77ca27e882de828b4e741121238fc Mon Sep 17 00:00:00 2001 From: jonathanmetzman <31354670+jonathanmetzman@users.noreply.github.com> Date: Tue, 7 Jan 2020 08:23:13 -0800 Subject: [PATCH] Revert "Make bad_build_check more likely to catch hardcoding /out (#3180)" (#3197) Revert so that we don't get two errors in a row. This reverts commit 14bdd9332c0ae144dd24c9d09139c55a397f902d. --- infra/base-images/base-runner/Dockerfile | 1 - infra/base-images/base-runner/test_all | 15 +------ infra/base-images/base-runner/test_one | 50 ------------------------ infra/helper.py | 2 +- 4 files changed, 2 insertions(+), 66 deletions(-) delete mode 100755 infra/base-images/base-runner/test_one diff --git a/infra/base-images/base-runner/Dockerfile b/infra/base-images/base-runner/Dockerfile index e7626628d..0be58102f 100644 --- a/infra/base-images/base-runner/Dockerfile +++ b/infra/base-images/base-runner/Dockerfile @@ -49,7 +49,6 @@ COPY bad_build_check \ run_minijail \ targets_list \ test_all \ - test_one \ /usr/local/bin/ # Default environment options for various sanitizers. diff --git a/infra/base-images/base-runner/test_all b/infra/base-images/base-runner/test_all index 688607cfe..2e49b75ef 100755 --- a/infra/base-images/base-runner/test_all +++ b/infra/base-images/base-runner/test_all @@ -32,18 +32,8 @@ rm -rf $BROKEN_TARGETS_DIR mkdir $VALID_TARGETS_DIR mkdir $BROKEN_TARGETS_DIR -# Move the directory the fuzzer is located in to somewhere that doesn't exist -# on the builder to make it more likely that hardcoding /out fails here (since -# it will fail on ClusterFuzz). -TMP_FUZZER_DIR=/tmp/not-out -rm -rf $TMP_FUZZER_DIR -mkdir $TMP_FUZZER_DIR -# Move contents of $OUT/ into $TMP_FUZZER_DIR. We can't move the directory -# itself because it is a mount. -mv $OUT/* $TMP_FUZZER_DIR - # Main loop that iterates through all fuzz targets and runs the check. -for FUZZER_BINARY in $(find $TMP_FUZZER_DIR -maxdepth 1 -executable -type f); do +for FUZZER_BINARY in $(find $OUT/ -maxdepth 1 -executable -type f); do if file "$FUZZER_BINARY" | grep -v ELF > /dev/null 2>&1; then continue fi @@ -83,9 +73,6 @@ done # Wait for background processes to finish. wait -# Restore $OUT -mv $TMP_FUZZER_DIR/* $OUT - # Sanity check in case there are no fuzz targets in the $OUT/ dir. if [ "$TOTAL_TARGETS_COUNT" -eq "0" ]; then echo "ERROR: no fuzzers found in $OUT/" diff --git a/infra/base-images/base-runner/test_one b/infra/base-images/base-runner/test_one deleted file mode 100755 index 288e31aa1..000000000 --- a/infra/base-images/base-runner/test_one +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -u -# Copyright 2020 Google Inc. -# -# 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 -# -# http://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. -# -################################################################################ - -# Wrapper around bad_build_check that moves the /out directory to /tmp/not-out. -# This is useful when bad_build_check isn't called from test_all which does the -# same thing. - -function main { - # Move the directory the fuzzer is located in to somewhere that doesn't exist - # on the builder to make it more likely that hardcoding /out fails here (since - # it will fail on ClusterFuzz). - local fuzzer=$1 - fuzzer=$(realpath $fuzzer) - local initial_fuzzer_dir=$(dirname $fuzzer) - - local tmp_fuzzer_dir=/tmp/not-out - rm -rf $tmp_fuzzer_dir - mkdir $tmp_fuzzer_dir - # Move the contents of $initial_fuzzer_dir rather than the directory itself in - # case it is a mount. - mv $initial_fuzzer_dir/* $tmp_fuzzer_dir - fuzzer="$tmp_fuzzer_dir/$(basename $fuzzer)" - - bad_build_check $fuzzer - returncode=$? - - mv $tmp_fuzzer_dir/* $initial_fuzzer_dir - exit returncode -} - -if [ $# -ne 1 ]; then - echo "Usage: $0 " - exit 1 -fi - -main $1 diff --git a/infra/helper.py b/infra/helper.py index bc3ee96c8..f70f34387 100755 --- a/infra/helper.py +++ b/infra/helper.py @@ -530,7 +530,7 @@ def check_build(args): if args.fuzzer_name: run_args += [ - 'test_one', + 'bad_build_check', os.path.join('/out', args.fuzzer_name) ] else: