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

Is it possible to represent a Go stdlib package with a purl? #113

Closed
chmeliik opened this issue Aug 17, 2021 · 3 comments
Closed

Is it possible to represent a Go stdlib package with a purl? #113

chmeliik opened this issue Aug 17, 2021 · 3 comments

Comments

@chmeliik
Copy link

I would like to identify all the dependencies of a Go package, both external and from the standard library, via purls. Is this possible?

Let's say I use archive/tar as a dependency. I could think of 2 ways to represent this with a purl, but both seem questionable at best.

  • pkg:golang/golang.org/pkg/archive/tar
  • pkg:golang/archive/tar

The first one uses golang.org/pkg as the "namespace" for stdlib packages. However, this does not pass the go get test. The second one uses only the package name. Interestingly, go get archive/tar does work - at least in the sense that the command does nothing and returns 0.

Would either of the two formats (or some other format) be an acceptable way to identify a stdlib package? Is identifying stdlib packages a misuse of purl?

@chmeliik chmeliik changed the title Is it possible to identify a Go stdlib package with a purl? Is it possible to represent a Go stdlib package with a purl? Aug 17, 2021
@jasinner
Copy link

I think the 2nd one is better. It looks like the osv.dev project is not using purl for stdlib things yet, but they way the represent GO-2021-0068 seems to look closer to the 2nd suggestion here pkg:golang/cmd/go to me.

$ curl -s "https://api.osv.dev/v1/vulns/GO-2021-0068" | jq '.package'
{
  "name": "cmd/go",
  "ecosystem": "Go"
}

@pombredanne any thoughts?

@pombredanne
Copy link
Member

@chmeliik I agree with @jasinner: pkg:golang/archive/tar feels more natural and aligned with how a one would refer to the package.
Please close if you think this answers your question!
You could also send a PR to clarify this with an example too.

@chmeliik
Copy link
Author

chmeliik commented Nov 1, 2021

This does answer my question, thanks!

@chmeliik chmeliik closed this as completed Nov 1, 2021
nscuro added a commit to CycloneDX/cyclonedx-gomod that referenced this issue Nov 21, 2021
this is also to better represent stdlib packages, see package-url/purl-spec#113

Signed-off-by: nscuro <[email protected]>
nscuro added a commit to CycloneDX/cyclonedx-gomod that referenced this issue Nov 21, 2021
* add option to include packages in application sbom

Signed-off-by: nscuro <[email protected]>

* use pkg import paths for their component names

Signed-off-by: nscuro <[email protected]>

* add changelog

Signed-off-by: nscuro <[email protected]>

* sort packages by import path

Signed-off-by: nscuro <[email protected]>

* regenerate example sboms

Signed-off-by: nscuro <[email protected]>

* handle stdlib packages #84

Signed-off-by: nscuro <[email protected]>

* fix goroot determination

Signed-off-by: nscuro <[email protected]>

* update changelog

Signed-off-by: nscuro <[email protected]>

* update changelog

Signed-off-by: nscuro <[email protected]>

* don't strip `go` prefix from go version

Signed-off-by: nscuro <[email protected]>

* don't try to load stdlib module for `bin`

Signed-off-by: nscuro <[email protected]>

* update help string for `app`

Signed-off-by: nscuro <[email protected]>

* regenerate example sboms

Signed-off-by: nscuro <[email protected]>

* use import path for package PURLs

this is also to better represent stdlib packages, see package-url/purl-spec#113

Signed-off-by: nscuro <[email protected]>

* add purl `type` qualifier for modules

to better distinguish modules from packages

Signed-off-by: nscuro <[email protected]>

* add test

Signed-off-by: nscuro <[email protected]>

* update changelog

Signed-off-by: nscuro <[email protected]>

* regenerate example sboms

Signed-off-by: nscuro <[email protected]>

* update changelog

Signed-off-by: nscuro <[email protected]>

* include stdlib and packages in our own sbom

Signed-off-by: nscuro <[email protected]>

Closes #85
Closes #84
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

No branches or pull requests

3 participants