aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects
diff options
context:
space:
mode:
authorGravatar Anirudh <m.anirudh18@gmail.com>2018-07-19 02:27:18 +0530
committerGravatar Abhishek Arya <inferno@chromium.org>2018-07-18 13:57:18 -0700
commitcd8e557241d6da2583019959579dbb53e0a3c5af (patch)
treeffd354c57cbea60f3b691b63f5640f72d39c2211 /projects
parent90f03e3aface9f8b85f2873e46cb071a088e9e15 (diff)
envoy: modified identification of corpus path (#1607)
Diffstat (limited to 'projects')
-rw-r--r--projects/envoy/Dockerfile2
-rwxr-xr-xprojects/envoy/build.sh3
-rw-r--r--projects/envoy/find_corpus.py23
3 files changed, 26 insertions, 2 deletions
diff --git a/projects/envoy/Dockerfile b/projects/envoy/Dockerfile
index 8f5526ce..c260f229 100644
--- a/projects/envoy/Dockerfile
+++ b/projects/envoy/Dockerfile
@@ -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/
diff --git a/projects/envoy/build.sh b/projects/envoy/build.sh
index 3162d051..03253789 100755
--- a/projects/envoy/build.sh
+++ b/projects/envoy/build.sh
@@ -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/
diff --git a/projects/envoy/find_corpus.py b/projects/envoy/find_corpus.py
new file mode 100644
index 00000000..712822ea
--- /dev/null
+++ b/projects/envoy/find_corpus.py
@@ -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]