Proposal Details
1. Introduction
I propose adding a new go audit command to the go tool. This command will provide a centralized location for all security-related functionality included with the Go standard library.
I further propose a subcommand go audit vuln which will provide a unified way to check Go modules for known vulnerabilities and other security issues. Crucially, it will build upon the existing govulncheck tool and integrate directly into the main Go distribution.
2. Background
The Go team has made significant investments into vulnerability management, including the Go Vulnerability Database (go/vulndb) and the govulncheck tool. By incorporating the existing capabilities of govulncheck into the new go audit vuln command, vulnerability detection will become a standard, easily accessible part of the Go development workflow.
3. Proposal
The basic invocation of the new command will be as follows:
go audit [subcommand]
Example:
$ go audit vuln ./...
The vuln subcommand will analyze specified packages (or the current directory if none are specified) and report known vulnerabilities and other issues. For now the only subcommand supported will be the vuln command.
3.1. Proposed Flags
Go audit vuln reports known vulnerabilities in dependencies.
Usage:
go audit vuln [flags] [patterns]
go audit vuln -mode=binary [flags] [binary]
-C dir
change to dir before running vuln
-format value
specify format output
The supported values are 'text', 'json', 'sarif', and 'openvex' (default 'text')
-json
output JSON (Go compatible legacy flag, see format flag)
-mode value
supports 'source', 'binary', and 'extract' (default 'source')
-scan value
set the scanning level desired, one of 'module', 'package', or 'symbol' (default 'symbol')
-show list
enable display of additional information specified by the comma separated list
The supported values are 'traces','color', 'version', and 'verbose'
-tags list
comma-separated list of build tags
-test
analyze test files (only valid for source mode, default false)
See https://golang.org/ref/audit#go-audit-vuln for more about 'go audit vuln'.
3.2. Scope of Audit
Go vet must always produce actionable information. It can never produce false positives. Go audit exists as a separate space where “more fuzzy” “code health” analyzers may require human review. Where go vet would prevent compilation, go audit would suggest to the user possible actions to take in regards to code health.
Initially, go audit will focus on vulnerability detection, effectively being an integration of govulncheck. In the future, its scope could be expanded to include:
- Dependency health: Checking for outdated or deprecated dependencies.
- Best practices: Enforcing best practices for go.mod files and other aspects of Go modules.
- License compliance: Auditing licenses of dependencies.
- Coding Style: Checking for code style standards and best practices related to security
- Modernizations: Checking for modernizations impacting security
3.3. Vulnerability Database
To align with standard Go toolchain best practices, the legacy govulncheck flag -db (previously used to override the default vulnerability database URL at https://vuln.go.dev) is removed. Instead, go audit vuln will read from the GOVULNDB environment variable to configure or override the target vulnerability database URL.
Proposal Details
1. Introduction
I propose adding a new
go auditcommand to the go tool. This command will provide a centralized location for all security-related functionality included with the Go standard library.I further propose a subcommand
go audit vulnwhich will provide a unified way to check Go modules for known vulnerabilities and other security issues. Crucially, it will build upon the existing govulncheck tool and integrate directly into the main Go distribution.2. Background
The Go team has made significant investments into vulnerability management, including the Go Vulnerability Database (go/vulndb) and the
govulnchecktool. By incorporating the existing capabilities of govulncheck into the newgo audit vulncommand, vulnerability detection will become a standard, easily accessible part of the Go development workflow.3. Proposal
The basic invocation of the new command will be as follows:
The
vulnsubcommand will analyze specified packages (or the current directory if none are specified) and report known vulnerabilities and other issues. For now the only subcommand supported will be the vuln command.3.1. Proposed Flags
3.2. Scope of Audit
Go vet must always produce actionable information. It can never produce false positives. Go audit exists as a separate space where “more fuzzy” “code health” analyzers may require human review. Where go vet would prevent compilation, go audit would suggest to the user possible actions to take in regards to code health.
Initially,
go auditwill focus on vulnerability detection, effectively being an integration ofgovulncheck. In the future, its scope could be expanded to include:3.3. Vulnerability Database
To align with standard Go toolchain best practices, the legacy
govulncheckflag-db(previously used to override the default vulnerability database URL at https://vuln.go.dev) is removed. Instead,go audit vulnwill read from theGOVULNDBenvironment variable to configure or override the target vulnerability database URL.