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 14bdd9332c.
This commit is contained in:
jonathanmetzman 2020-01-07 08:23:13 -08:00 committed by GitHub
parent 70513142eb
commit 689c3f4b65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 66 deletions

View File

@ -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.

View File

@ -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/"

View File

@ -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 <fuzz_target_binary>"
exit 1
fi
main $1

View File

@ -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: