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 Syft's cyclonedx component properties in Grype output #951

Closed
cjnosal opened this issue Oct 6, 2022 · 9 comments · Fixed by #1038
Closed

Include Syft's cyclonedx component properties in Grype output #951

cjnosal opened this issue Oct 6, 2022 · 9 comments · Fixed by #1038
Assignees
Labels
enhancement New feature or request

Comments

@cjnosal
Copy link
Contributor

cjnosal commented Oct 6, 2022

What would you like to be added:
Syft's cyclonedx output was improved in anchore/syft#710.
I would like Grype to offer the same level of detail as Syft.

Why is this needed:
The current cyclonedx or vex outputs don't contain full information to aid in triage. I need to cross-reference grype cyclonedx against syft json to find additional metadata (e.g. file path containing a go module, which syft encodes as properties).

Additional context:
Syft component encoding:
https://github.com/anchore/syft/blob/main/syft/formats/common/cyclonedxhelpers/component.go#L30

Grype:
https://github.com/anchore/grype/blob/main/grype/presenter/cyclonedx/document.go#L48
https://github.com/anchore/grype/blob/main/grype/presenter/cyclonedxvex/document.go#L67

@cjnosal cjnosal added the enhancement New feature or request label Oct 6, 2022
@kzantow
Copy link
Contributor

kzantow commented Oct 20, 2022

Hi @xtreme-conor-nosal -- is the main gist of this ask to be able to match Grype CycloneDX results against elements in a Syft SBOM? In other words: if we added a file path would this allow you do do what you need -- or could there be a package ID that matches, which might be easier?

@cjnosal
Copy link
Contributor Author

cjnosal commented Oct 20, 2022

Using syft $image -o cyclonedx as a baseline, I would like syft $image | grype -o cyclonedx or grype $image -o cyclonedx to have at least as much detail about each component.

If I run grype -o cyclonedx and want to know why e.g. there's two copies of a package, I need to context switch, run syft against the same image, and search for the package name to see that the package is part of two binaries in my image. If grype surfaced the same information, it can save me a step as I triage each result.

@kzantow
Copy link
Contributor

kzantow commented Oct 21, 2022

Thanks @xtreme-conor-nosal, so if only the location information was included in the Grype output, would that be sufficient for your use case here? I ask because that would be a fairly simple change to make, whereas including all the properties would be a much bigger lift.

@cjnosal
Copy link
Contributor Author

cjnosal commented Oct 21, 2022

Yes, having location would be a good first step.

@cjnosal
Copy link
Contributor Author

cjnosal commented Oct 21, 2022

Given Grype has the two use cases of generating the sbom internally via Syft vs reading an sbom from stdin (that may or may not come from Syft), what do you think about a second ticket for preserving any extra properties that appear in a provided sbom (in addition to this ticket focusing on properties generated by Grype)?

@kzantow
Copy link
Contributor

kzantow commented Oct 21, 2022

This might be tricky to do... for CycloneDX -> CycloneDX it might be fairly straightforward, but mapping other arbitrary properties between formats might be a lot more work to determine where to put said properties.

@cjnosal
Copy link
Contributor Author

cjnosal commented Oct 25, 2022

Yeah, I was thinking it might need to be constrained to the cases where the input and output formats match, and even then could represent a sizeable code diff.

@cjnosal
Copy link
Contributor Author

cjnosal commented Oct 25, 2022

A second field that might be worth prioritizing is purl. Where package names from different ecosystems collide the type is a useful disambiguator, with the advantage of being a cyclonedx spec field (compared to the syft:package:* properties)

@spiffcs
Copy link
Contributor

spiffcs commented Dec 22, 2022

Hey @xtreme-conor-nosal check out #1038 and the enhancements made there. Using grype standalone now should give you the same output as if you had used syft. We updated grype to just consume our formatting library from syft.

If you have questions, comments, or improvements let me know and I can follow up!

spiffcs added a commit that referenced this issue Dec 22, 2022
grype currently produces CYCLONE-DX SBOM that are not compliant with the cyclone-dx tooling libraries. Rather than write the logic in two places, this PR moves grype to use syft's formatting functions as a library to produce valid CYCLONE-DX SBOM components along with the discovered vulnerabilities.

For more context on impacted issues:
#796
#951
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
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants