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

feat(image): goversion as stdlib #6277

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

thepwagner
Copy link
Contributor

@thepwagner thepwagner commented Mar 5, 2024

Description

Modify the golang/binary parser to emit the version of the golang runtime as stdlib.

The purl generated by this name is compatible to what is produced by syft, but I don't think it will be useful for vulnerability matching. Grype's strategy seems to be CPE matching.

My goal is to make the go runtime version visible when reporting in the CycloneDX format. This is motivated by 2024-03-05 release: https://groups.google.com/g/golang-announce/c/5pwGVUPoMbg

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
    • N/A(?)
  • I've added usage information (if the PR introduces new options)
    • N/A
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).
    • N/A

@CLAassistant
Copy link

CLAassistant commented Mar 5, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@thepwagner
Copy link
Contributor Author

👋 it's been a little over a month - are you able to provide any feedback? Thanks!

@itaysk
Copy link
Contributor

itaysk commented Apr 9, 2024

@thepwagner thanks for the contribution! some of the maintainers are away this week, we will try to look at it soon after returning.

@knqyf263
Copy link
Collaborator

Thanks for your contribution. OSV uses toolchain rather than stdlib. I think it's better to get aligned with them.

curl -s "https://api.osv.dev/v1/vulns/GO-2021-0068" | jq '.affected[].package'
{
  "name": "toolchain",
  "ecosystem": "Go",
  "purl": "pkg:golang/toolchain"
}

@knqyf263
Copy link
Collaborator

Hmm. But they also use stdlib.

$ curl -s "https://api.osv.dev/v1/vulns/GO-2024-2687" | jq ".affected[].package"
{
  "name": "stdlib",
  "ecosystem": "Go",
  "purl": "pkg:golang/stdlib"
}
{
  "name": "golang.org/x/net",
  "ecosystem": "Go",
  "purl": "pkg:golang/golang.org/x/net"
}

@knqyf263
Copy link
Collaborator

It seems like they use toolchain for cmd/go. In this case, stdlib looks better.

BTW, I don't know why the tests were not triggered. I'll merge the main branch and see if it triggers the tests.

@knqyf263 knqyf263 enabled auto-merge April 15, 2024 10:40
auto-merge was automatically disabled April 15, 2024 10:59

Head branch was pushed to by a user without write access

@cbandy
Copy link

cbandy commented Apr 15, 2024

📝 Go versions prior to 1.21 did an unusual thing with their version numbers. It probably won't matter now that those all have patches and 1.20 is not supported.

https://go.dev/doc/go1.21

Go 1.21 introduces a small change to the numbering of releases. In the past, we used Go 1.N to refer to both the overall Go language version and release family as well as the first release in that family. Starting in Go 1.21, the first release is now Go 1.N.0.

@knqyf263
Copy link
Collaborator

Trivy expects semantic versions in Go. It may show warnings with binaries compiled Go prior to 1.21, but I believe it won't stop scanning. Let's see.

@knqyf263 knqyf263 added this pull request to the merge queue Apr 15, 2024
Merged via the queue into aquasecurity:main with commit d82d6cb Apr 15, 2024
12 checks passed
@thepwagner thepwagner deleted the go-binary-parse-stdlib branch April 15, 2024 19:48
@knqyf263 knqyf263 mentioned this pull request Apr 29, 2024
8 tasks
fl0pp5 pushed a commit to altlinux/trivy that referenced this pull request May 6, 2024
Co-authored-by: knqyf263 <knqyf263@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Golang stdlib vulnerabilities
5 participants