Skip to content

fix: mark Go vuln called when any call-analysis finding is called - #3203

Closed
Shanmukh-l33t wants to merge 1 commit into
google:mainfrom
Shanmukh-l33t:fix/call-analysis-last-wins
Closed

Shanmukh-l33t wants to merge 1 commit into
google:mainfrom
Shanmukh-l33t:fix/call-analysis-last-wins

Conversation

@Shanmukh-l33t

@Shanmukh-l33t Shanmukh-l33t commented Nov 3, 2026 •

Copy link
Copy Markdown

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 as Called=false — order-dependently. This PR ORs the per-module results so any called finding dominates, matching the semantics already used in internal/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:

  • The approach taken to solve the problem.
  • Any technical details that are relevant to the review.
  • Before and after screenshots (if applicable).

Problem: in internal/sourceanalysis/go.go, the aggregation loop did idToModuleToCalled[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].Called ended up false; with the reversed order it was true.

Downstream, GroupInfo.IsCalled() (pkg/models/results.go) drives both the exit-code check (determineReturnErr in pkg/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:

// Once one finding marks this vuln as called, always mark as called
idToModuleToCalled[f.OSV][modulePath] = idToModuleToCalled[f.OSV][modulePath] || called

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_calledDominatesUncalled in internal/sourceanalysis/go_test.go is table-driven over finding orderings — [called, uncalled], [uncalled, called], and all-uncalled — asserting the resulting Called verdict 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:

  • I have added unit tests for the new functionality: Test_matchAnalysisWithPackageVulns_calledDominatesUncalled (3 table cases covering both orderings plus the uncalled-only negative case).
  • I have run the existing test suite and all tests pass: ./scripts/run_tests.sh (37 packages ok, exit 0), ./scripts/run_lints.sh (golangci-lint: 0 issues), plus gofmt -l . (clean) and go vet ./... (clean).
  • I have manually tested the changes in the following way: confirmed the regression test fails on the unpatched code with ExperimentalAnalysis["GO-2021-0053"].Called = false, want true for 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

(CLA checkbox left unticked pending the automated CLA check on this PR — happy to sign at https://cla.developers.google.com/ if it flags.)

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
@google-cla

google-cla Bot commented Nov 3, 2026

Copy link
Copy Markdown

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.

@Shanmukh-l33t

Copy link
Copy Markdown
Author

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 called dominates uncalled in any finding order (matching rust.go semantics), with a table-driven regression test covering [called, uncalled], [uncalled, called], and all-uncalled orders — the last case guards against the fix flipping genuinely uncalled vulns to called. Happy to close this in favor of #3163 if the maintainer prefers that approach.

@G-Rath

G-Rath commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

This is not assigned to you

@G-Rath G-Rath closed this Nov 3, 2026
@Shanmukh-l33t

Copy link
Copy Markdown
Author

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.

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.

Go call analysis marks called vulnerabilities as uncalled when an uncalled finding comes last (last-wins aggregation)

2 participants