Skip to content

Add govulncheck analyzer pass#596

Merged
toddtreece merged 2 commits into
mainfrom
feat/govulncheck-analyzer
May 29, 2026
Merged

Add govulncheck analyzer pass#596
toddtreece merged 2 commits into
mainfrom
feat/govulncheck-analyzer

Conversation

@toddtreece
Copy link
Copy Markdown
Member

@toddtreece toddtreece requested a review from a team as a code owner May 27, 2026 16:20
@toddtreece toddtreece requested review from oshirohugo and sunker May 27, 2026 16:20
@toddtreece toddtreece requested a review from s4kh May 27, 2026 16:20
@toddtreece toddtreece self-assigned this May 27, 2026
@toddtreece toddtreece requested a review from Copilot May 27, 2026 16:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new govulncheck analyzer pass to the plugin-validator to scan Go plugin backend source (when provided) and backend binaries for known vulnerabilities, and wires the tool into docs + container images.

Changes:

  • Introduce pkg/analysis/passes/govulncheck analyzer that runs govulncheck -json in source and -mode=binary on detected backend binaries.
  • Add unit tests covering NDJSON parsing and analyzer behaviors using a fake govulncheck shim.
  • Update README and Docker image to include/install govulncheck (and install go in the runtime image for source-mode scanning).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Documents govulncheck as an additional security tool + analyzer.
pkg/analysis/passes/govulncheck/types.go Adds minimal structs for govulncheck -json NDJSON decoding.
pkg/analysis/passes/govulncheck/govulncheck.go Implements the new analyzer, running source and binary scans and reporting findings.
pkg/analysis/passes/govulncheck/govulncheck_test.go Adds tests for NDJSON parsing and analyzer reporting/scan behaviors.
pkg/analysis/passes/analysis.go Registers the new analyzer in the global analyzer list.
Dockerfile Installs/copies govulncheck into images and adds go to runtime for source scanning.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/analysis/passes/govulncheck/govulncheck.go Outdated
Comment thread pkg/analysis/passes/govulncheck/govulncheck.go Outdated
Comment thread pkg/analysis/passes/govulncheck/govulncheck_test.go Outdated
Comment thread pkg/analysis/passes/govulncheck/govulncheck.go
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@toddtreece toddtreece force-pushed the feat/govulncheck-analyzer branch 2 times, most recently from 733f6f4 to 529b068 Compare May 27, 2026 18:07
@toddtreece toddtreece requested a review from Copilot May 27, 2026 18:07
@toddtreece toddtreece moved this from 📬 Triage to 🔬 In review in Grafana Catalog Team May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment on lines +57 to +63
scansPerformed := 0
scanFailures := 0
findingsReported := 0
hasBackend := hasBackendPlugin(pass)

sourceCodeDir, ok := pass.ResultOf[sourcecode.Analyzer].(string)
if !ok || sourceCodeDir == "" {
Comment on lines +64 to +71
if hasBackend {
scanFailures++
pass.ReportResult(
pass.AnalyzerName,
govulncheckScanFailed,
"govulncheck source scan skipped",
"Backend plugin source code was not provided, so govulncheck could not scan the source.",
)
Comment on lines +139 to +143
err := os.WriteFile(fakeGovulncheck, []byte(`#!/bin/sh
printf '{"config":{"protocol_version":"v1.0.0","scanner_name":"govulncheck"}}\n'
printf 'loading packages failed\n' >&2
exit 1
`), 0o755)
Comment thread Dockerfile
Comment on lines +46 to +49
# govulncheck is distributed as a Go module — install with `go install` rather
# than a binary tarball. Pinned version is fixed via the ARG above.
RUN go install golang.org/x/vuln/cmd/govulncheck@${GOVULNCHECK_VERSION} && \
mv "$(go env GOPATH)/bin/govulncheck" /usr/local/bin/govulncheck
@toddtreece toddtreece force-pushed the feat/govulncheck-analyzer branch from 529b068 to 7b0f98c Compare May 28, 2026 00:19
osvIDs, err := parseCalledFindings(bytes.NewReader(stdout))
if err != nil {
logme.Errorln("Error parsing govulncheck source output", "error", err)
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

returning an error here will stop the whole validator and all other possible checks. only return errors from the validator if you want to break the whole pipeline from it.

for _, moduleDir := range moduleDirs {
stdout, ok, failureDetail, err := runGovulncheckJSON(govulncheckBin, moduleDir, moduleDir, "-json", "./...")
if err != nil {
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

returning an error here will stop the whole validator and all other possible checks. only return errors from the validator if you want to break the whole pipeline from it.

if ok && sourceCodeDir != "" {
moduleDirs, err := goModuleDirs(sourceCodeDir)
if err != nil {
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

returning an error here will stop the whole validator and all other possible checks. only return errors from the validator if you want to break the whole pipeline from it.

for _, binaryPath := range binaryPaths {
stdout, ok, failureDetail, err := runGovulncheckJSON(govulncheckBin, "", filepath.Base(binaryPath), "-mode=binary", "-json", binaryPath)
if err != nil {
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

returning an error here will stop the whole validator and all other possible checks. only return errors from the validator if you want to break the whole pipeline from it.

return moduleDirs, nil
}

func backendBinaries(pass *analysis.Pass) ([]string, error) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should this be called getBackendBinaries instead?

osvIDs, err := parseAllFindings(bytes.NewReader(stdout))
if err != nil {
logme.Errorln("Error parsing govulncheck binary output", "error", err)
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

returning an error here will stop the whole validator and all other possible checks. only return errors from the validator if you want to break the whole pipeline from it.

@toddtreece toddtreece requested a review from academo May 29, 2026 16:13
@toddtreece toddtreece merged commit 6212549 into main May 29, 2026
11 checks passed
@toddtreece toddtreece deleted the feat/govulncheck-analyzer branch May 29, 2026 18:52
@github-project-automation github-project-automation Bot moved this from 🔬 In review to 🚀 Shipped in Grafana Catalog Team May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚀 Shipped

Development

Successfully merging this pull request may close these issues.

4 participants