Repository navigation
fix: mark Go vuln called when any call-analysis finding is called - #3203
Shanmukh-l33t wants to merge 1 commit into
Conversation
The aggregation in matchAnalysisWithPackageVulns kept whichever
govulncheck finding landed last for a (vulnerability, module) pair, so an
uncalled finding arriving after a called one marked a reachable
vulnerability as uncalled. OR the per-module results instead so a single
called finding dominates regardless of ordering, matching the semantics
already used in rust.go ("Once one advisory marks this vuln as called,
always mark as called").
Adds an order-independence regression test covering [called, uncalled],
[uncalled, called] and all-uncalled finding orderings.
Fixes google#3162
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Note for reviewers: I only saw #3163 after opening this — apologies for the overlap; the issue was assigned and I should have checked open PRs first. If it's useful, the delta here is: the aggregation ORs per-module results so |
|
This is not assigned to you |
|
Understood — apologies for the overstepping. I hadn't meant to race the assignee; the branch stays up on my fork in case any of the regression cases are useful down the line. Leaving this to Subhan1794. |
Overview
A brief description of the changes in this pull request. What is the purpose of this PR? What issue does it fix?
Fixes #3162
Go call analysis aggregated govulncheck findings with a plain map assignment in
matchAnalysisWithPackageVulns, so the last finding per (vulnerability, module) won instead of OR-ing. When a multi-symbol advisory emits both called and uncalled findings and the uncalled one lands last, a reachable vulnerability was misclassified asCalled=false— order-dependently. This PR ORs the per-module results so any called finding dominates, matching the semantics already used ininternal/sourceanalysis/rust.go("Once one advisory marks this vuln as called, always mark as called").Details
Provide a more detailed description of the changes. This can include:
Problem: in
internal/sourceanalysis/go.go, the aggregation loop dididToModuleToCalled[f.OSV][modulePath] = called, keeping only the final finding per module. govulncheck emits one finding per vulnerable symbol and multi-symbol advisories routinely mix called findings (trace frame with a function name) and uncalled findings (single frame, empty function). With order[called, uncalled],ExperimentalAnalysis[id].Calledended upfalse; with the reversed order it wastrue.Downstream,
GroupInfo.IsCalled()(pkg/models/results.go) drives both the exit-code check (determineReturnErrinpkg/osvscanner/osvscanner.go) and the output bucketing (internal/output/output_result.go), so a misclassified vuln was hidden in the uncalled bucket and produced exit 0 — a false negative in reachability analysis purely from finding order.Solution: the minimal one-line change in the aggregation loop:
Called/reachable now dominates uncalled regardless of ordering. Uncalled-only inputs still aggregate to
false, so genuinely uncalled vulnerabilities are unaffected.Regression test:
Test_matchAnalysisWithPackageVulns_calledDominatesUncalledininternal/sourceanalysis/go_test.gois table-driven over finding orderings —[called, uncalled],[uncalled, called], and all-uncalled — asserting the resultingCalledverdict is order-independent. Before the fix the first case fails (Called = false, want true) while the reversed order passes; after the fix all three pass. Existing snapshots are unchanged (verified:go test ./internal/sourceanalysis/...passes without snapshot updates).Testing
Please describe the tests that you ran to verify your changes. For example:
Test_matchAnalysisWithPackageVulns_calledDominatesUncalled(3 table cases covering both orderings plus the uncalled-only negative case)../scripts/run_tests.sh(37 packages ok, exit 0),./scripts/run_lints.sh(golangci-lint: 0 issues), plusgofmt -l .(clean) andgo vet ./...(clean).ExperimentalAnalysis["GO-2021-0053"].Called = false, want truefor order[called, uncalled], reproducing the bug in Go call analysis marks called vulnerabilities as uncalled when an uncalled finding comes last (last-wins aggregation) #3162, and passes after the fix.Checklist
./scripts/run_lints.sh../scripts/run_tests.sh.(CLA checkbox left unticked pending the automated CLA check on this PR — happy to sign at https://cla.developers.google.com/ if it flags.)