From c2fc92e2f3c16b38c19696503b8ec7fb683a382c Mon Sep 17 00:00:00 2001 From: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> Date: Mon, 12 Jan 2026 13:02:14 +0100 Subject: [PATCH] Fuzzing: Remove old go-fuzz infrastructure After the migration to native Go fuzzing in PR #17393, this removes the old dvyukov/go-fuzz based infrastructure. This enables a smooth transition, because we can merge this pull request when upstream OSS-Fuzz changes have been done. This removes: - promql/fuzz.go and promql/fuzz_test.go (old fuzz functions) - promql/fuzz-data/ (old corpus files) The new fuzzing infrastructure is in util/fuzzing/ and is now used by the CI workflow. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> --- .../fuzz-data/ParseExpr/corpus/from_tests_1 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_10 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_11 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_12 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_13 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_14 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_15 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_16 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_17 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_18 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_19 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_2 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_20 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_21 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_22 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_23 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_24 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_25 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_26 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_27 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_28 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_29 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_3 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_30 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_31 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_32 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_33 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_34 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_4 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_5 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_6 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_7 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_8 | 1 - .../fuzz-data/ParseExpr/corpus/from_tests_9 | 1 - .../982cbe5ad899f03c630b1a21876a206707ea3dc9 | 1 - .../ParseMetric/corpus/exposition_formats_0 | 3 - .../ParseMetric/corpus/exposition_formats_1 | 1 - .../ParseMetric/corpus/exposition_formats_2 | 1 - .../ParseMetric/corpus/exposition_formats_3 | 1 - .../ParseMetric/corpus/exposition_formats_4 | 1 - .../ParseMetric/corpus/exposition_formats_5 | 1 - .../ParseMetric/corpus/exposition_formats_6 | 1 - .../ParseMetric/corpus/exposition_formats_7 | 1 - promql/fuzz.go | 127 ------------------ promql/fuzz_test.go | 38 ------ 45 files changed, 210 deletions(-) delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_1 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_10 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_11 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_12 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_13 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_14 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_15 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_16 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_17 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_18 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_19 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_2 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_20 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_21 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_22 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_23 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_24 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_25 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_26 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_27 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_28 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_29 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_3 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_30 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_31 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_32 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_33 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_34 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_4 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_5 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_6 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_7 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_8 delete mode 100644 promql/fuzz-data/ParseExpr/corpus/from_tests_9 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/982cbe5ad899f03c630b1a21876a206707ea3dc9 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_0 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_1 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_2 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_3 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_4 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_5 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_6 delete mode 100644 promql/fuzz-data/ParseMetric/corpus/exposition_formats_7 delete mode 100644 promql/fuzz.go delete mode 100644 promql/fuzz_test.go diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_1 b/promql/fuzz-data/ParseExpr/corpus/from_tests_1 deleted file mode 100644 index d00491fd7e..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_1 +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_10 b/promql/fuzz-data/ParseExpr/corpus/from_tests_10 deleted file mode 100644 index 96ae912147..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_10 +++ /dev/null @@ -1 +0,0 @@ -0755 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_11 b/promql/fuzz-data/ParseExpr/corpus/from_tests_11 deleted file mode 100644 index 42399b8652..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_11 +++ /dev/null @@ -1 +0,0 @@ -+5.5e-3 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_12 b/promql/fuzz-data/ParseExpr/corpus/from_tests_12 deleted file mode 100644 index ebe4ec8b9e..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_12 +++ /dev/null @@ -1 +0,0 @@ --0755 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_13 b/promql/fuzz-data/ParseExpr/corpus/from_tests_13 deleted file mode 100644 index 8d2f0971e2..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_13 +++ /dev/null @@ -1 +0,0 @@ -1 + 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_14 b/promql/fuzz-data/ParseExpr/corpus/from_tests_14 deleted file mode 100644 index 0b4439e57c..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_14 +++ /dev/null @@ -1 +0,0 @@ -1 - 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_15 b/promql/fuzz-data/ParseExpr/corpus/from_tests_15 deleted file mode 100644 index 6f65828d83..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_15 +++ /dev/null @@ -1 +0,0 @@ -1 * 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_16 b/promql/fuzz-data/ParseExpr/corpus/from_tests_16 deleted file mode 100644 index 7bda04b3eb..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_16 +++ /dev/null @@ -1 +0,0 @@ -1 % 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_17 b/promql/fuzz-data/ParseExpr/corpus/from_tests_17 deleted file mode 100644 index 645e6d9d20..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_17 +++ /dev/null @@ -1 +0,0 @@ -1 / 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_18 b/promql/fuzz-data/ParseExpr/corpus/from_tests_18 deleted file mode 100644 index d8a6bab88c..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_18 +++ /dev/null @@ -1 +0,0 @@ -1 == 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_19 b/promql/fuzz-data/ParseExpr/corpus/from_tests_19 deleted file mode 100644 index 160e8c346e..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_19 +++ /dev/null @@ -1 +0,0 @@ -1 != 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_2 b/promql/fuzz-data/ParseExpr/corpus/from_tests_2 deleted file mode 100644 index 3b6020a27c..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_2 +++ /dev/null @@ -1 +0,0 @@ -+Inf diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_20 b/promql/fuzz-data/ParseExpr/corpus/from_tests_20 deleted file mode 100644 index 627f468173..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_20 +++ /dev/null @@ -1 +0,0 @@ -1 > 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_21 b/promql/fuzz-data/ParseExpr/corpus/from_tests_21 deleted file mode 100644 index faaf3a7a23..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_21 +++ /dev/null @@ -1 +0,0 @@ -1 >= 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_22 b/promql/fuzz-data/ParseExpr/corpus/from_tests_22 deleted file mode 100644 index 9ac3113919..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_22 +++ /dev/null @@ -1 +0,0 @@ -1 < 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_23 b/promql/fuzz-data/ParseExpr/corpus/from_tests_23 deleted file mode 100644 index 2451e5510b..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_23 +++ /dev/null @@ -1 +0,0 @@ -1 <= 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_24 b/promql/fuzz-data/ParseExpr/corpus/from_tests_24 deleted file mode 100644 index 67a5a10772..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_24 +++ /dev/null @@ -1 +0,0 @@ -+1 + -2 * 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_25 b/promql/fuzz-data/ParseExpr/corpus/from_tests_25 deleted file mode 100644 index 25cf8fa2f4..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_25 +++ /dev/null @@ -1 +0,0 @@ -1 + 2/(3*1) diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_26 b/promql/fuzz-data/ParseExpr/corpus/from_tests_26 deleted file mode 100644 index 8b13789179..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_26 +++ /dev/null @@ -1 +0,0 @@ - diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_27 b/promql/fuzz-data/ParseExpr/corpus/from_tests_27 deleted file mode 100644 index 99e8589b50..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_27 +++ /dev/null @@ -1 +0,0 @@ -#comment diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_28 b/promql/fuzz-data/ParseExpr/corpus/from_tests_28 deleted file mode 100644 index 056501e0d4..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_28 +++ /dev/null @@ -1 +0,0 @@ -foo * bar diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_29 b/promql/fuzz-data/ParseExpr/corpus/from_tests_29 deleted file mode 100644 index 4d198a88ad..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_29 +++ /dev/null @@ -1 +0,0 @@ -foo == 1 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_3 b/promql/fuzz-data/ParseExpr/corpus/from_tests_3 deleted file mode 100644 index 8e8b84a07b..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_3 +++ /dev/null @@ -1 +0,0 @@ --Inf diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_30 b/promql/fuzz-data/ParseExpr/corpus/from_tests_30 deleted file mode 100644 index a64e56eedb..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_30 +++ /dev/null @@ -1 +0,0 @@ -2.5 / bar diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_31 b/promql/fuzz-data/ParseExpr/corpus/from_tests_31 deleted file mode 100644 index 8e828c009d..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_31 +++ /dev/null @@ -1 +0,0 @@ -foo and bar diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_32 b/promql/fuzz-data/ParseExpr/corpus/from_tests_32 deleted file mode 100644 index 8eeb0d47b3..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_32 +++ /dev/null @@ -1 +0,0 @@ -foo or bar diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_33 b/promql/fuzz-data/ParseExpr/corpus/from_tests_33 deleted file mode 100644 index 16f8b86e06..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_33 +++ /dev/null @@ -1 +0,0 @@ -foo + bar or bla and blub diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_34 b/promql/fuzz-data/ParseExpr/corpus/from_tests_34 deleted file mode 100644 index 1f70261cfa..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_34 +++ /dev/null @@ -1 +0,0 @@ -bar + on(foo) bla / on(baz, buz) group_right(test) blub diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_4 b/promql/fuzz-data/ParseExpr/corpus/from_tests_4 deleted file mode 100644 index d6c9fff3d7..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_4 +++ /dev/null @@ -1 +0,0 @@ -.5 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_5 b/promql/fuzz-data/ParseExpr/corpus/from_tests_5 deleted file mode 100644 index e4c8c3130a..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_5 +++ /dev/null @@ -1 +0,0 @@ -5. diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_6 b/promql/fuzz-data/ParseExpr/corpus/from_tests_6 deleted file mode 100644 index acaf810388..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_6 +++ /dev/null @@ -1 +0,0 @@ -123.4567 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_7 b/promql/fuzz-data/ParseExpr/corpus/from_tests_7 deleted file mode 100644 index 9bc2000f7d..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_7 +++ /dev/null @@ -1 +0,0 @@ -5e-3 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_8 b/promql/fuzz-data/ParseExpr/corpus/from_tests_8 deleted file mode 100644 index 260602c18e..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_8 +++ /dev/null @@ -1 +0,0 @@ -5e3 diff --git a/promql/fuzz-data/ParseExpr/corpus/from_tests_9 b/promql/fuzz-data/ParseExpr/corpus/from_tests_9 deleted file mode 100644 index f2e222d823..0000000000 --- a/promql/fuzz-data/ParseExpr/corpus/from_tests_9 +++ /dev/null @@ -1 +0,0 @@ -0xc diff --git a/promql/fuzz-data/ParseMetric/corpus/982cbe5ad899f03c630b1a21876a206707ea3dc9 b/promql/fuzz-data/ParseMetric/corpus/982cbe5ad899f03c630b1a21876a206707ea3dc9 deleted file mode 100644 index bdbf8f2029..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/982cbe5ad899f03c630b1a21876a206707ea3dc9 +++ /dev/null @@ -1 +0,0 @@ -o { quantile = "1.0", a = "b" } 8.3835e-05 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_0 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_0 deleted file mode 100644 index 405bb5131c..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_0 +++ /dev/null @@ -1,3 +0,0 @@ -# HELP api_http_request_count The total number of HTTP requests. -# TYPE api_http_request_count counter -http_request_count{method="post",code="200"} 1027 1395066363000 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_1 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_1 deleted file mode 100644 index 76ede7fb69..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_1 +++ /dev/null @@ -1 +0,0 @@ -msdos_file_access_time_ms{path="C:\\DIR\\FILE.TXT",error="Cannot find file:\n\"FILE.TXT\""} 1.234e3 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_2 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_2 deleted file mode 100644 index 64674abec9..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_2 +++ /dev/null @@ -1 +0,0 @@ -metric_without_timestamp_and_labels 12.47 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_3 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_3 deleted file mode 100644 index 6bb7e38838..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_3 +++ /dev/null @@ -1 +0,0 @@ -something_weird{problem="division by zero"} +Inf -3982045 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_4 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_4 deleted file mode 100644 index 47cd3366bc..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_4 +++ /dev/null @@ -1 +0,0 @@ -http_request_duration_seconds_bucket{le="+Inf"} 144320 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_5 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_5 deleted file mode 100644 index bb9f16973c..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_5 +++ /dev/null @@ -1 +0,0 @@ -go_gc_duration_seconds{ quantile="0.9", a="b"} 8.3835e-05 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_6 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_6 deleted file mode 100644 index 8b91128ed0..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_6 +++ /dev/null @@ -1 +0,0 @@ -go_gc_duration_seconds{ quantile="1.0", a="b" } 8.3835e-05 diff --git a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_7 b/promql/fuzz-data/ParseMetric/corpus/exposition_formats_7 deleted file mode 100644 index 760ea69b5a..0000000000 --- a/promql/fuzz-data/ParseMetric/corpus/exposition_formats_7 +++ /dev/null @@ -1 +0,0 @@ -go_gc_duration_seconds { quantile = "1.0", a = "b" } 8.3835e-05 diff --git a/promql/fuzz.go b/promql/fuzz.go deleted file mode 100644 index 3fa28abe48..0000000000 --- a/promql/fuzz.go +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Only build when go-fuzz is in use -//go:build gofuzz - -package promql - -import ( - "errors" - "io" - - "github.com/prometheus/prometheus/model/labels" - "github.com/prometheus/prometheus/model/textparse" - "github.com/prometheus/prometheus/promql/parser" -) - -// PromQL parser fuzzing instrumentation for use with -// https://github.com/dvyukov/go-fuzz. -// -// Fuzz each parser by building appropriately instrumented parser, ex. -// FuzzParseMetric and execute it with it's -// -// go-fuzz-build -func FuzzParseMetric -o FuzzParseMetric.zip github.com/prometheus/prometheus/promql -// -// And then run the tests with the appropriate inputs -// -// go-fuzz -bin FuzzParseMetric.zip -workdir fuzz-data/ParseMetric -// -// Further input samples should go in the folders fuzz-data/ParseMetric/corpus. -// -// Repeat for FuzzParseOpenMetric, FuzzParseMetricSelector and FuzzParseExpr. - -// Tuning which value is returned from Fuzz*-functions has a strong influence -// on how quick the fuzzer converges on "interesting" cases. At least try -// switching between fuzzMeh (= included in corpus, but not a priority) and -// fuzzDiscard (=don't use this input for re-building later inputs) when -// experimenting. -const ( - fuzzInteresting = 1 - fuzzMeh = 0 - fuzzDiscard = -1 - - // Input size above which we know that Prometheus would consume too much - // memory. The recommended way to deal with it is check input size. - // https://google.github.io/oss-fuzz/getting-started/new-project-guide/#input-size - maxInputSize = 10240 -) - -// Use package-scope symbol table to avoid memory allocation on every fuzzing operation. -var symbolTable = labels.NewSymbolTable() - -var fuzzParser = parser.NewParser(parser.Options{}) - -func fuzzParseMetricWithContentType(in []byte, contentType string) int { - p, warning := textparse.New(in, contentType, symbolTable, textparse.ParserOptions{}) - if p == nil || warning != nil { - // An invalid content type is being passed, which should not happen - // in this context. - panic(warning) - } - - var err error - for { - _, err = p.Next() - if err != nil { - break - } - } - if errors.Is(err, io.EOF) { - err = nil - } - - if err == nil { - return fuzzInteresting - } - - return fuzzMeh -} - -// Fuzz the metric parser. -// -// Note that this is not the parser for the text-based exposition-format; that -// lives in github.com/prometheus/client_golang/text. -func FuzzParseMetric(in []byte) int { - return fuzzParseMetricWithContentType(in, "text/plain") -} - -func FuzzParseOpenMetric(in []byte) int { - return fuzzParseMetricWithContentType(in, "application/openmetrics-text") -} - -// Fuzz the metric selector parser. -func FuzzParseMetricSelector(in []byte) int { - if len(in) > maxInputSize { - return fuzzMeh - } - _, err := fuzzParser.ParseMetricSelector(string(in)) - if err == nil { - return fuzzInteresting - } - - return fuzzMeh -} - -// Fuzz the expression parser. -func FuzzParseExpr(in []byte) int { - if len(in) > maxInputSize { - return fuzzMeh - } - _, err := fuzzParser.ParseExpr(string(in)) - if err == nil { - return fuzzInteresting - } - - return fuzzMeh -} diff --git a/promql/fuzz_test.go b/promql/fuzz_test.go deleted file mode 100644 index a24da48e63..0000000000 --- a/promql/fuzz_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Only build when go-fuzz is in use -//go:build gofuzz - -package promql - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestfuzzParseMetricWithContentTypePanicOnInvalid(t *testing.T) { - defer func() { - if p := recover(); p == nil { - t.Error("invalid content type should panic") - } else { - err, ok := p.(error) - require.True(t, ok) - require.ErrorContains(t, err, "duplicate parameter name") - } - }() - - const invalidContentType = "application/openmetrics-text; charset=UTF-8; charset=utf-8" - fuzzParseMetricWithContentType([]byte{}, invalidContentType) -}