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

golang binary version parsing fails if GOEXPERIMENT was enabled #6698

Closed
knqyf263 opened this issue May 16, 2024 Discussed in #6695 · 0 comments · Fixed by #6696
Closed

golang binary version parsing fails if GOEXPERIMENT was enabled #6698

knqyf263 opened this issue May 16, 2024 Discussed in #6695 · 0 comments · Fixed by #6696
Labels
kind/bug Categorizes issue or PR as related to a bug.
Milestone

Comments

@knqyf263
Copy link
Collaborator

Discussed in #6695

Originally posted by lyoung-confluent May 16, 2024

Description

When running trivy on a Golang binary that was compiled with GOEXPERIMENT such as boringcrypto or loopvar the version extraction for stdlib will fail:

2024-05-15T15:20:45-07:00	WARN	Version matching error	err="version error (1.21.5 X:boringcrypto): malformed version: 1.21.5 X:boringcrypto"

This is because the returned GoVersion includes the additional experiment tags as part of the "version".

Desired Behavior

Trivy successfully extracts the Go version and reports the vulnerabilities

Actual Behavior

Trivy fails to extract the Go version and as such does not detect/report Go stdlib vulnerabilities

Reproduction Steps

  1. Build the following Dockerfile (docker build -t goexperiment-test .):
FROM golang:1.22.1 AS builder
COPY <<EOF /example.go
package main

func main() {
    println("Hello World")
}
EOF
RUN GOEXPERIMENT=loopvar go build -o /example /example.go

FROM scratch
COPY --from=builder /example /example
  1. Scan the image using trivy, observe that no stdlib vulnerabilities are reported and an error is found in the output:
$ trivy image goexperiment-test
2024-05-15T15:44:09-07:00	INFO	[gobinary] Detecting vulnerabilities...
2024-05-15T15:44:09-07:00	WARN	Version matching error	err="version error (1.22.1 X:loopvar): malformed version: 1.22.1 X:loopvar"

Target

Container Image

Scanner

Vulnerability

Output Format

None

Mode

None

Debug Output

N/A
@knqyf263 knqyf263 added the kind/bug Categorizes issue or PR as related to a bug. label May 16, 2024
@knqyf263 knqyf263 added this to the v0.52.0 milestone May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant