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

Include stdlib packages in application SBOM #84

Closed
thediveo opened this issue Oct 5, 2021 · 6 comments
Closed

Include stdlib packages in application SBOM #84

thediveo opened this issue Oct 5, 2021 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@thediveo
Copy link

thediveo commented Oct 5, 2021

I've generated a BOM of an application with both -std as well as without: with -std there's only a single Go stdlib component included, without it all included stdlib components seem to be missing from the BOM. I'm using the recent 1.0.0 version, compiled from master only few days ago.

For instance, crypto packages are thus missing from the BOM generated on the basis of the sources, yet scanning the binary reveals that at least some of the crypto packages from the Go stdlib have been bound into the final binary.

Am I doing something wrong or missing some CLI flag that will include stdlib packages en detail into the BOM generated from the sources?

@nscuro
Copy link
Member

nscuro commented Oct 5, 2021

This is indeed working as intended.

cyclonedx-gomod works with modules, not packages. The -std flag was introduced to provide a simple solution for indicating which version of Go / the standard library is used.

The app command has a -file flag though, which will show all files of a module that are used. We currently filter out all stdlib packages, but we could extend this functionality to include stdlib files as well.

@thediveo
Copy link
Author

thediveo commented Oct 5, 2021

Thank you very much for your explanation! (me facepalming myself for mixing up modules and packages again)

Having -flag include stdlib packages would allow for simple postprocessing the bom in jq to get stdlib packages in addition to the modules, such as for ECC clearance.

@nscuro
Copy link
Member

nscuro commented Oct 6, 2021

I've created #85 to include package information in SBOMs.

I'll rename this issue to reflect that packages of the standard library should also be included (if -std is set).

@nscuro nscuro added the enhancement New feature or request label Oct 6, 2021
@nscuro nscuro changed the title BOM does not contain individual Go stdlib components Include stdlib packages in application SBOM Oct 6, 2021
@nscuro nscuro added this to the v1.1.0 milestone Oct 21, 2021
nscuro added a commit that referenced this issue Nov 20, 2021
Signed-off-by: nscuro <nscuro@protonmail.com>
@nscuro nscuro closed this as completed in febc262 Nov 21, 2021
@nscuro
Copy link
Member

nscuro commented Nov 21, 2021

This is now available in v1.1.0-alpha.1.

@thediveo If you'd like to try it out:

$ go install -v github.com/CycloneDX/cyclonedx-gomod@v1.1.0-alpha.1
$ cyclonedx-gomod app -packages -std -json -output bom.json /path/to/your/app

Please let me know if there's something missing in your opinion, or the tool doesn't behave like you expect.

Our own SBOMs now include packages as well, including those of the standard library, e.g. https://github.com/CycloneDX/cyclonedx-gomod/releases/download/v1.1.0-alpha.1/cyclonedx-gomod_1.1.0-alpha.1_linux_amd64.bom.json

@thediveo
Copy link
Author

Unfortunately, I cannot get github.com/CycloneDX/cyclonedx-gomod@v1.1.0-alpha.1 to scan my application: trying to run cyclonedx-gomod app -packages -std -json -output bom.json ./cmd/lxkns on my OpenSource project thedive/lxkns always gives me: ERR error="failed to load modules: not a go module".

@nscuro
Copy link
Member

nscuro commented Nov 22, 2021

@thediveo Ah, that's because the positional argument is expected to be the path to your module. ./cmd/lxkns should be provided via -main. Try this instead, assuming your working directory is the root of your module:

$ cyclonedx-gomod app -packages -std -json -output bom.json -main ./cmd/lxkns .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants