fix(osvscanner): filter Grafana Go SDK dependencies - #664
fix(osvscanner): filter Grafana Go SDK dependencies#664alectimison-maker wants to merge 1 commit into
Conversation
Signed commits report1 of 1 commit between
This repository requires all commits to be signed. See GitHub docs on commit signature verification. |
There was a problem hiding this comment.
Pull request overview
This PR brings the Go (go.mod) OSV-scanner path in line with the existing JavaScript lockfile behavior by filtering out vulnerability findings that are inherited from the selected grafana-plugin-sdk-go version, while preserving findings that are direct plugin dependencies or version mismatches. It does so by parsing the plugin’s go.mod, resolving the chosen SDK version (including replace), fetching the SDK’s go.mod from the Go module proxy, and excluding findings only when the vulnerable module is indirect in the plugin and matches versions across plugin/SDK/OSV.
Changes:
- Route
go.modscans through a new Go-specific filtering path (filterGoModResults). - Implement SDK-aware filtering by downloading and parsing the selected
grafana-plugin-sdk-gomodule file. - Add unit tests for the Go module filtering and fail-open behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/analysis/passes/osvscanner/filter.go | Enables Go module filtering by delegating go.mod handling to the new Go-specific filter. |
| pkg/analysis/passes/osvscanner/filter-gomod.go | Adds the Go module filtering implementation, including SDK version resolution and module-proxy fetch/parsing. |
| pkg/analysis/passes/osvscanner/filter_test.go | Adds tests covering Go module filtering behavior and fail-open behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| return filtered |
| "github.com/versioned/indirect", | ||
| }, packageNames(filtered)) | ||
| } | ||
|
|
Summary
grafana-plugin-sdk-goversionand version mismatches
Motivation
The JavaScript lockfile path already removes vulnerabilities inherited from
Grafana packages, but the Go path returned every OSV result unchanged. This can
block a plugin submission for a vulnerability in a module managed by the
Grafana Go SDK rather than by the plugin.
Closes #453.
Design
The filter parses the plugin's
go.mod, resolves its selectedgrafana-plugin-sdk-goversion, and downloads only that version's boundedgo.modfrom the Go module proxy. A finding is excluded only when:This is intentionally stricter than name-only filtering so a plugin's direct
dependency or independently upgraded version remains visible. Fetch, status,
size, version, and parse failures retain the original findings.
Testing
go test ./pkg/analysis/passes/osvscanner/...— passedgo vet ./pkg/analysis/passes/osvscanner/...— passedgo build -o bin/darwin_arm64/plugincheck2 ./pkg/cmd/plugincheck2— passedgo test ./pkg/cmd/plugincheck2 -count=1— passedgo test ./pkg/...— passedCompatibility and risks
JavaScript lockfile behavior and public APIs are unchanged. Go modules that do
not explicitly list transitive requirements keep their existing findings. The
new module-proxy request has a 10-second timeout and a 2 MiB response cap; if it
is unavailable, the validator reports all original vulnerabilities.
Scope
This change does not alter SDK version policy or general OSV allowlisting.