Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/vuln: SARIF format incorrect for zero results #70157

Closed
cbandy opened this issue Nov 1, 2024 · 5 comments
Closed

x/vuln: SARIF format incorrect for zero results #70157

cbandy opened this issue Nov 1, 2024 · 5 comments
Assignees
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. vulncheck or vulndb Issues for the x/vuln or x/vulndb repo

Comments

@cbandy
Copy link

cbandy commented Nov 1, 2024

govulncheck version

Go: go1.22.8
Scanner: [email protected]
DB: https://vuln.go.dev
DB updated: 2024-10-30 21:28:25 +0000 UTC

Does this issue reproduce at the latest version of golang.org/x/vuln?

Yes

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/cbandy/Library/Caches/go-build'
GOENV='/Users/cbandy/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/cbandy/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/cbandy/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/cbandy/.local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/cbandy/.local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.8'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/cbandy/tmp/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/b2/6dgjh_xn1xs_zmnnkrkhs9rh0000gn/T/go-build3343678873=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Run govulncheck in an empty project.

cd $(mktemp -d)
go mod init tmp
govulncheck -format sarif ./...

What did you see happen?

The scan finished and found no vulnerabilities, but the SARIF report contains no runs.results field.

{
  "version": "2.1.0",
  "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "govulncheck",
          "semanticVersion": "v1.1.3",
          "informationUri": "https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck",
          "properties": {
            "protocol_version": "v1.0.0",
            "scanner_name": "govulncheck",
            "scanner_version": "v1.1.3",
            "db": "https://vuln.go.dev",
            "db_last_modified": "2024-10-30T21:28:25Z",
            "go_version": "go1.22.8",
            "scan_level": "symbol",
            "scan_mode": "source"
          }
        }
      }
    }
  ]
}

What did you expect to see?

I expected a "results": [] field, as described by the SARIF spec.

3.14.23 results property

If the tool failed to start, … then results MAY be present. If it is present, its value SHALL be null.
If the tool started but failed to begin its analysis… then again results MAY be present, and if present SHALL be null.

In all other circumstances, results SHALL be present and SHALL contain all results detected by the tool. If the tool did not detect any results, results SHALL be an empty array.

@cbandy cbandy added the vulncheck or vulndb Issues for the x/vuln or x/vulndb repo label Nov 1, 2024
@gopherbot gopherbot modified the milestones: Unreleased, vuln/unplanned Nov 1, 2024
@gabyhelp
Copy link

gabyhelp commented Nov 1, 2024

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 1, 2024
@cagedmantis
Copy link
Contributor

cc @golang/vulndb

@zpavlinovic zpavlinovic self-assigned this Nov 1, 2024
@zpavlinovic
Copy link
Contributor

Thanks for reporting this, we'll fix this.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/625355 mentions this issue: internal/sarif: ensure results follow sarif formatting requirements

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/625656 mentions this issue: internal/sarif: use empty arrays instead of nils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. vulncheck or vulndb Issues for the x/vuln or x/vulndb repo
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants