vulncheck

package
v1.232.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package vulncheck runs govulncheck for CI and normalizes its SARIF report so GitHub code scanning accepts it. It backs the `go tool mage ci:vulncheck` target used by .github/workflows/codeql.yml.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DedupeStacks

func DedupeStacks(r io.Reader, w io.Writer) error

DedupeStacks copies a SARIF report from r to w, removing exact duplicate objects from every result's `stacks` array. The scanner can emit identical stacks, but the SARIF schema requires the entries to be unique, so GitHub rejects the upload otherwise.

Only complete duplicates are removed: the first occurrence of each stack keeps its position, frame order and metadata, and findings, distinct stacks and all other properties pass through unchanged. Objects are compared independently of key order. Absent, null or non-array `stacks` values, and absent or null `runs`/`results`, are left as they are.

Malformed or empty input is an error, so a broken scan can never be replaced by an empty report.

func Scan

func Scan(ctx context.Context, params *Params) error

Scan runs `govulncheck -format sarif` and writes the normalized report to params.Output. The tool must be on PATH. A failed scan, or output that is not a valid SARIF report, fails the scan and leaves any existing report untouched, so vulnerabilities can never be hidden by an empty upload.

Types

type Params

type Params struct {
	// Output is the SARIF file to write. It is replaced only after the scan
	// succeeds and the report has been normalized.
	Output string
	// Packages are the package patterns to scan. It defaults to ./...
	Packages []string
	// Stderr receives govulncheck's diagnostics. It defaults to os.Stderr.
	Stderr io.Writer
}

Params configures Scan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL