Skip to content

gateway: fix broken coverage build #13333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AdamKorcz
Copy link
Collaborator

@AdamKorcz AdamKorcz commented May 19, 2025

Changes OSS-Fuzz infra such that it no longer builds native go test binaries. Instead, it follows a similar practice as non-native-go fuzzers and builds a test template that calls the fuzzer. This fixes the missing build of gateway.

@sudiptob2 this overwrites gateways upstream build script. I suggest we test here that it works and then move the changes upstream.

Fixes #13285

@AdamKorcz AdamKorcz force-pushed the native_go_cov_build branch 2 times, most recently from ca3ac16 to 7974615 Compare May 19, 2025 12:43
@AdamKorcz AdamKorcz changed the title gateway: fix broken build gateway: fix broken coverage build May 19, 2025
Signed-off-by: Adam Korczynski <[email protected]>
@AdamKorcz AdamKorcz force-pushed the native_go_cov_build branch from 7974615 to 47fb296 Compare May 19, 2025 13:29
@sudiptob2
Copy link
Contributor

Hey, thank you so much for working on the fix 🚀

I am trying to test the branch locally, but I am still getting errors due to a mismatch in corpus formats. I am following the steps described in this documentation:
https://google.github.io/oss-fuzz/advanced-topics/code-coverage/#generate-code-coverage-reports

A part of the logs I see:

        "testdata/fuzz/FuzzGatewayAPIToXDS/ff5b138b12cbc3ee6a224eb117a57b22a92c9fd3": unmarshal: unknown encoding version: 
        "testdata/fuzz/FuzzGatewayAPIToXDS/ff5e59e669228b330291f1888bca5bff3936a262": unmarshal: must include version and at least one value
        "testdata/fuzz/FuzzGatewayAPIToXDS/ff6828318f40822b41f6da263fe1a8c8f72fbfd4": unmarshal: must include version and at least one value
        "testdata/fuzz/FuzzGatewayAPIToXDS/ff7cf23d965420f15cc519e07ecbfdeab533b4d0": unmarshal: unknown encoding version: ���99999999999000000000000000000000:yaml.org,2002:str@�����������������������������
        "testdata/fuzz/FuzzGatewayAPIToXDS/ffb473437706b854e2947ebd64856a4bb20fd585": unmarshal: unknown encoding version: 
        "testdata/fuzz/FuzzGatewayAPIToXDS/ffbb6ee3f221dcd968f0d608f6ad82b121d4ae32": unmarshal: unknown encoding version: /
        "testdata/fuzz/FuzzGatewayAPIToXDS/ffcfdbde5cf831310aa245348d2687c29baeb4c9": unmarshal: must include version and at least one value
        "testdata/fuzz/FuzzGatewayAPIToXDS/ffd8aada07e074e55ab8d21298367ef755b62fce": unmarshal: must include version and at least one value
        "testdata/fuzz/FuzzGatewayAPIToXDS/fffb9a578f3afaec07acc17d4a606cefeed702ed": unmarshal: must include version and at least one value
FAIL
coverage: [no statements]
/out/dumps
2025/05/19 16:17:27 Cannot open profile file at "/out/dumps/*.perf.cpu.prof": open /out/dumps/*.perf.cpu.prof: no such file or directory
mv: cannot stat 'merged.data': No such file or directory
2025/05/19 16:17:27 Cannot open profile file at "/out/dumps/*.perf.heap.prof": open /out/dumps/*.perf.heap.prof: no such file or directory
mv: cannot stat 'merged.data': No such file or directory
Finished generating code coverage report for Go fuzz targets.
Serving the report on http://127.0.0.1:8008/linux/index.html
Serving HTTP on 0.0.0.0 port 8008 (http://0.0.0.0:8008/) ...
10.0.0.122 - - [19/May/2025 16:17:49] "GET //linux/index.html HTTP/1.1" 200 -
10.0.0.122 - - [19/May/2025 16:17:50] "GET //linux/index.html HTTP/1.1" 200 -
10.0.0.122 - - [19/May/2025 16:17:50] "GET //linux/index.html HTTP/1.1" 200 -

@AdamKorcz
Copy link
Collaborator Author

AdamKorcz commented May 19, 2025

@sudiptob2 You need to run this file locally after checking out this branch: https://github.com/google/oss-fuzz/blob/master/infra/base-images/all.sh. This will rebuild the images with the infrastructure changes.

You can modify it to the following to save time:

#docker build --pull -t gcr.io/oss-fuzz-base/base-image "$@" infra/base-images/base-image
#docker build -t gcr.io/oss-fuzz-base/base-clang "$@" infra/base-images/base-clang
docker build -t gcr.io/oss-fuzz-base/base-builder "$@" infra/base-images/base-builder
docker build -t gcr.io/oss-fuzz-base/base-builder-go "$@" infra/base-images/base-builder-go
#docker build -t gcr.io/oss-fuzz-base/base-builder-jvm "$@" infra/base-images/base-builder-jvm
#docker build -t gcr.io/oss-fuzz-base/base-builder-python "$@" infra/base-images/base-builder-python
#docker build -t gcr.io/oss-fuzz-base/base-builder-rust "$@" infra/base-images/base-builder-rust
#docker build -t gcr.io/oss-fuzz-base/base-builder-ruby "$@" infra/base-images/base-builder-ruby
#docker build -t gcr.io/oss-fuzz-base/base-builder-swift "$@" infra/base-images/base-builder-swift
docker build -t gcr.io/oss-fuzz-base/base-runner "$@" infra/base-images/base-runner
#docker build -t gcr.io/oss-fuzz-base/base-runner-debug "$@" infra/base-images/base-runner-debug

Copy link
Contributor

@sudiptob2 sudiptob2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Tested locally and I can now see the coverage report.

AdamKorcz added 2 commits May 19, 2025 22:12
Signed-off-by: Adam Korczynski <[email protected]>
@AdamKorcz
Copy link
Collaborator Author

/gcbrun trial_build.py go --fuzzing-engines libfuzzer --sanitizers coverage address

@sudiptob2
Copy link
Contributor

@AdamKorcz, we recently conducted a comparison between the coverage report generated locally and the coverage report generated using OSS-Fuzz, and found some mismatches in coverage percentage. Reported in issue #13393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No coverage generated due to corpus format in Golang Native Fuzzing
2 participants