Skip to content

Commit 9afe5cd

Browse files
authored
opentelemetry-go: add new fuzz tests and change fuzzer naming pattern (#14250)
This PR add new fuzzers and renames fuzzer binaries in the OpenTelemetry Go projects to include the module path as a prefix, improving clarity and avoiding name collisions. ## Changes ### projects/opentelemetry-go/build.sh - Added 3 new fuzzers: `FuzzHashKVs`, `FuzzTraceIDFromHex`, and `FuzzSpanIDFromHex` - Renamed fuzzer binaries to include module prefixes: - `FuzzHashKVs` → `sdk_attribute_FuzzHashKVs` - `FuzzGetBin` → `sdk_metric_internal_aggregate_FuzzGetBin` - `FuzzTraceIDFromHex` → `trace_FuzzTraceIDFromHex` - `FuzzSpanIDFromHex` → `trace_FuzzSpanIDFromHex` ### projects/opentelemetry-go-contrib/build.sh - Added new fuzzer: `FuzzYAMLWithEnvVars` - Renamed fuzzer binaries to include module and version prefixes: - `FuzzJSON` → `otelconf_v0.3.0_FuzzJSON` - `FuzzYAML` → `otelconf_v0.3.0_FuzzYAML` - `FuzzYAMLWithEnvVars` → `otelconf_v0.3.0_FuzzYAMLWithEnvVars` ## Benefits - **Clearer naming**: Fuzzer binary names now indicate which module they test - **Avoid collisions**: Prevents potential name conflicts when multiple modules have fuzzers with the same function name
1 parent 85631ab commit 9afe5cd

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

projects/opentelemetry-go-contrib/build.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
# limitations under the License.
1515
#
1616
################################################################################
17+
REPO=$PWD
1718

18-
pushd otelconf/v0.3.0
19-
compile_native_go_fuzzer_v2 $(go list) FuzzJSON FuzzJSON
20-
compile_native_go_fuzzer_v2 $(go list) FuzzYAML FuzzYAML
21-
popd
19+
cd $REPO/otelconf/v0.3.0
20+
compile_native_go_fuzzer_v2 $(go list) FuzzJSON otelconf_v0.3.0_FuzzJSON
21+
compile_native_go_fuzzer_v2 $(go list) FuzzYAML otelconf_v0.3.0_FuzzYAML
22+
compile_native_go_fuzzer_v2 $(go list) FuzzYAMLWithEnvVars otelconf_v0.3.0_FuzzYAMLWithEnvVars

projects/opentelemetry-go/build.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
#
1616
################################################################################
1717

18-
pushd sdk/metric/internal/aggregate
19-
compile_native_go_fuzzer_v2 $(go list) FuzzGetBin FuzzGetBin
20-
popd
18+
REPO=$PWD
19+
20+
cd $REPO/attribute
21+
# Mitigate the error: found packages attribute_test and attribute in /src/opentelemetry-go/attribute.
22+
# Remove all Go files with *_test package before building the fuzzer.
23+
# Tracking issue: https://github.com/google/oss-fuzz/issues/7923.
24+
grep -rl --include="*.go" '^package .*_test' . | xargs rm -f
25+
compile_native_go_fuzzer_v2 $(go list) FuzzHashKVs sdk_attribute_FuzzHashKVs
26+
27+
cd $REPO/sdk/metric/internal/aggregate
28+
compile_native_go_fuzzer_v2 $(go list) FuzzGetBin sdk_metric_internal_aggregate_FuzzGetBin
29+
30+
cd $REPO/trace
31+
compile_native_go_fuzzer_v2 $(go list) FuzzTraceIDFromHex trace_FuzzTraceIDFromHex
32+
compile_native_go_fuzzer_v2 $(go list) FuzzSpanIDFromHex trace_FuzzSpanIDFromHex

0 commit comments

Comments
 (0)