Skip to content

Commit a6de02d

Browse files
committed
add oss-fuzz build script
1 parent 85e45c5 commit a6de02d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

fuzz/oss_fuzz_build.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -eu
2+
# Copyright 2021 Google Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
FUZZERS_BASE=$SRC/hcl/hclsyntax/fuzz
19+
FUZZERS_PACKAGE=github.com/hashicorp/hcl/v2/hclsyntax/fuzz
20+
FUZZER_CLASS=Fuzz
21+
22+
for THE_FUZZER in config expr template traversal
23+
do
24+
THE_FUZZER_NAME="fuzz_"$THE_FUZZER
25+
compile_go_fuzzer $FUZZERS_PACKAGE/$THE_FUZZER $FUZZER_CLASS $THE_FUZZER_NAME
26+
27+
OUTDIR=$OUT/$THE_FUZZER_NAME"_seed_corpus"
28+
mkdir $OUTDIR
29+
find $FUZZERS_BASE/$THE_FUZZER/corpus -type f | while read FNAME
30+
do
31+
SHASUM_NAME=$(shasum "$FNAME" | awk '{print $1}')
32+
cp "$FNAME" $OUTDIR
33+
done
34+
zip -r $OUTDIR".zip" $OUTDIR
35+
rm -rf $OUTDIR
36+
done

0 commit comments

Comments
 (0)