Skip to content

Commit 28009df

Browse files
authored
[Go] Fix oss-fuzz-integration for go (#1887)
Fix oss-fuzz-integration for go Signed-off-by: Arthur Chan <[email protected]>
1 parent e6754fc commit 28009df

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

oss_fuzz_integration/build_all_custom_images.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ if [[ -z ${CLOUD_BUILD_ENV:+dummy} ]]; then
5555
docker build -t gcr.io/oss-fuzz-base/base-builder-python infra/base-images/base-builder-python
5656
docker build -t gcr.io/oss-fuzz-base/base-builder-jvm infra/base-images/base-builder-jvm
5757
docker build -t gcr.io/oss-fuzz-base/base-builder-rust infra/base-images/base-builder-rust
58+
docker build -t gcr.io/oss-fuzz-base/base-builder-go infra/base-images/base-builder-go
5859
fi

oss_fuzz_integration/build_post_processing.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ docker build -t gcr.io/oss-fuzz-base/base-builder infra/base-images/base-builder
4545
docker build -t gcr.io/oss-fuzz-base/base-builder-python infra/base-images/base-builder-python
4646
docker build -t gcr.io/oss-fuzz-base/base-builder-jvm infra/base-images/base-builder-jvm
4747
docker build -t gcr.io/oss-fuzz-base/base-builder-rust infra/base-images/base-builder-rust
48+
docker build -t gcr.io/oss-fuzz-base/base-builder-go infra/base-images/base-builder-go
4849
docker build -t gcr.io/oss-fuzz-base/base-runner infra/base-images/base-runner

oss_fuzz_integration/oss-fuzz-patches.diff

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ index d0f45bb73..388563180 100755
7979
export AR=llvm-ar
8080
export NM=llvm-nm
8181
export RANLIB=llvm-ranlib
82-
@@ -210,10 +220,19 @@ if [ "$SANITIZER" = "introspector" ]; then
82+
@@ -210,10 +220,27 @@ if [ "$SANITIZER" = "introspector" ]; then
8383

8484
apt-get install -y libjpeg-dev zlib1g-dev libyaml-dev
8585
python3 -m pip install --upgrade pip setuptools
@@ -88,12 +88,20 @@ index d0f45bb73..388563180 100755
8888
python3 -m pip install --prefer-binary matplotlib
8989

9090
- python3 /fuzz-introspector/src/main.py light
91+
+ # Install Fuzz-Introspector
92+
+ pushd /fuzz-introspector/src
93+
+ python3 -m pip install -r /fuzz-introspector/requirements.txt
94+
+ python3 -m pip install .
95+
+ popd
96+
+
9197
+ if [ "$FUZZING_LANGUAGE" = "python" ]; then
9298
+ python3 /fuzz-introspector/src/main.py light --language=python
9399
+ elif [ "$FUZZING_LANGUAGE" = "jvm" ]; then
94100
+ python3 /fuzz-introspector/src/main.py light --language=jvm
95101
+ elif [ "$FUZZING_LANGUAGE" = "rust" ]; then
96102
+ python3 /fuzz-introspector/src/main.py light --language=rust
103+
+ elif [ "$FUZZING_LANGUAGE" = "go" ]; then
104+
+ python3 /fuzz-introspector/src/main.py light --language=go
97105
+ else
98106
+ python3 /fuzz-introspector/src/main.py light
99107
+ fi
@@ -110,7 +118,7 @@ index d0f45bb73..388563180 100755
110118
unset CXXFLAGS
111119
unset CFLAGS
112120
export G_ANALYTICS_TAG="G-8WTFM1Y62J"
113-
@@ -295,6 +314,21 @@ if [ "$SANITIZER" = "introspector" ]; then
121+
@@ -295,6 +316,31 @@ if [ "$SANITIZER" = "introspector" ]; then
114122
mkdir -p $SRC/my-fi-data
115123
find $OUT/ -name *.data -exec mv {} $SRC/my-fi-data/ \;
116124
find $OUT/ -name *.data.yaml -exec mv {} $SRC/my-fi-data/ \;
@@ -129,10 +137,20 @@ index d0f45bb73..388563180 100755
129137
+
130138
+ # Restore the sanitizer flag for rust
131139
+ export SANITIZER="introspector"
140+
+ elif [ "$FUZZING_LANGUAGE" = "go" ]; then
141+
+ echo "GOING go route"
142+
+
143+
+ # Run the go frontend
144+
+ python3 -m fuzz_introspector.frontends.src.oss_fuzz --language go --target-dir $SRC
145+
+
146+
+ # Move files temporarily to fix workflow of other languages.
147+
+ mkdir -p $SRC/my-fi-data
148+
+ find ./ -name "*.data" -exec mv {} $SRC/my-fi-data/ \;
149+
+ find ./ -name "*.data.yaml" -exec mv {} $SRC/my-fi-data/ \;
132150
fi
133151

134152
mkdir -p $SRC/inspector
135-
@@ -335,6 +369,12 @@ if [ "$SANITIZER" = "introspector" ]; then
153+
@@ -335,6 +388,18 @@ if [ "$SANITIZER" = "introspector" ]; then
136154
REPORT_ARGS="$REPORT_ARGS --language=jvm"
137155
python3 /fuzz-introspector/src/main.py report $REPORT_ARGS
138156
rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
@@ -141,8 +159,13 @@ index d0f45bb73..388563180 100755
141159
+ REPORT_ARGS="$REPORT_ARGS --target_dir=$SRC/inspector"
142160
+ REPORT_ARGS="$REPORT_ARGS --language=rust"
143161
+ python3 /fuzz-introspector/src/main.py report $REPORT_ARGS
162+
+ rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
163+
+ elif [ "$FUZZING_LANGUAGE" = "go" ]; then
164+
+ echo "GOING go route"
165+
+ REPORT_ARGS="$REPORT_ARGS --target_dir=$SRC/inspector"
166+
+ REPORT_ARGS="$REPORT_ARGS --language=go"
167+
+ python3 /fuzz-introspector/src/main.py report $REPORT_ARGS
144168
+ rsync -avu --delete "$SRC/inspector/" "$OUT/inspector"
145169
else
146170
# C/C++
147171

148-

0 commit comments

Comments
 (0)