envoy: modified identification of corpus path (#1607)

This commit is contained in:
Anirudh 2018-07-19 02:27:18 +05:30 committed by Abhishek Arya
parent 90f03e3afa
commit cd8e557241
3 changed files with 26 additions and 2 deletions

View File

@ -36,4 +36,4 @@ RUN apt-get update && apt-get install -y bazel
RUN git clone https://github.com/envoyproxy/envoy.git
WORKDIR /src/envoy/
COPY build.sh $SRC/
COPY find_corpus.py build.sh $SRC/

View File

@ -61,10 +61,11 @@ bazel build --verbose_failures --dynamic_mode=off --spawn_strategy=standalone \
# Copy out test binaries from bazel-bin/ and zip up related test corpuses.
for t in ${FUZZER_TARGETS}
do
TARGET_CORPUS=$(python "${SRC}"/find_corpus.py "$t")
TARGET_BASE="$(expr "$t" : '.*/\(.*\)_fuzz_test')"
cp bazel-bin/"${t}"_driverless "${OUT}"/"${TARGET_BASE}"_fuzz_test
zip "${OUT}/${TARGET_BASE}"_fuzz_test_seed_corpus.zip \
"$(dirname "${t}")"/"${TARGET_BASE}"_corpus/*
"$(dirname "${t}")"/"${TARGET_CORPUS}"/*
done
# Copy dictionaries and options files to $OUT/

View File

@ -0,0 +1,23 @@
#!/usr/bin/python
import os
import sys
import re
fuzzer_target = sys.argv[1]
directory, fuzzer_target_name = os.path.dirname(fuzzer_target), os.path.basename(fuzzer_target)
path = os.path.join('..', 'envoy', directory, 'BUILD')
with open(path, 'r') as f:
searchlines = f.readlines()
for i, line in enumerate(searchlines):
if fuzzer_target_name in line:
for l in searchlines[i:]:
if 'corpus =' in l:
corpus_path = l
break
try:
corpus_path
except NameError:
raise Exception("No corpus path for the given fuzz target")
print re.findall(r'"([^"]*)"', corpus_path)[0]