Skip to content

Commit eb1ea69

Browse files
committed
prometheus: update to native go fuzzing
Related to prometheus/prometheus#17393 Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
1 parent a330fe5 commit eb1ea69

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

projects/prometheus/build.sh

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,30 @@
1414
# limitations under the License.
1515
#
1616
################################################################################
17-
# Wrong naming in this fuzzer breaks the coverage build
18-
rm promql/fuzz_test.go
1917

20-
compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetric fuzzParseMetric
21-
compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseOpenMetric fuzzParseOpenMetric
22-
compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseMetricSelector fuzzParseMetricSelector
23-
compile_go_fuzzer github.com/prometheus/prometheus/promql FuzzParseExpr fuzzParseExpr
18+
# go-118-fuzz-build_v2 overlays $GOROOT/src/testing/fuzz.go. When Go
19+
# downloads a newer toolchain to satisfy a go.work/go.mod requirement,
20+
# GOROOT falls under GOMODCACHE whose files Go refuses to overlay. To
21+
# work around this, copy the downloaded toolchain to a writable temp
22+
# dir, prepend it to PATH, and pin GOTOOLCHAIN=local so the copied
23+
# go binary (which IS the required version) is used directly.
24+
goroot=$(go env GOROOT)
25+
gomodcache=$(go env GOMODCACHE)
26+
if [[ "$goroot" == "$gomodcache"* ]]; then
27+
tmp_go=$(mktemp -d)
28+
cp -r "$goroot/." "$tmp_go"
29+
export GOROOT="$tmp_go"
30+
export PATH="$tmp_go/bin:$PATH"
31+
export GOTOOLCHAIN=local
32+
fi
33+
34+
compile_native_go_fuzzer_v2 github.com/prometheus/prometheus/util/fuzzing FuzzParseMetricText fuzzParseMetricText
35+
compile_native_go_fuzzer_v2 github.com/prometheus/prometheus/util/fuzzing FuzzParseOpenMetric fuzzParseOpenMetric
36+
compile_native_go_fuzzer_v2 github.com/prometheus/prometheus/util/fuzzing FuzzParseMetricSelector fuzzParseMetricSelector
37+
compile_native_go_fuzzer_v2 github.com/prometheus/prometheus/util/fuzzing FuzzParseExpr fuzzParseExpr
38+
39+
go generate -tags fuzzing ./util/fuzzing/corpus_gen
40+
mv util/fuzzing/fuzzParseExpr_seed_corpus.zip $OUT/
41+
mv util/fuzzing/fuzzParseMetricSelector_seed_corpus.zip $OUT/
42+
mv util/fuzzing/fuzzParseMetricText_seed_corpus.zip $OUT/
43+
mv util/fuzzing/fuzzParseOpenMetric_seed_corpus.zip $OUT/

0 commit comments

Comments
 (0)