-
Notifications
You must be signed in to change notification settings - Fork 18
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
merge-cachi2-sboms: re-generate test data, fix uncovered bugs #204
Conversation
Reviewer guide:
|
6ef813a
to
1214a67
Compare
The previous input SBOMs were created in a mysterious way which is no longer replicable. Re-generate them in a more repeatable way and add a script to do that. Signed-off-by: Adam Cmiel <[email protected]>
1214a67
to
504d0c0
Compare
I noticed the generated SBOMs were changing every time I reran the |
purl = component.purl() | ||
if not purl: | ||
raise ValueError(f"cachi2 component with no purl? name={component.name()}, version={component.version()}") | ||
return purl._replace(qualifiers=None, subpath=None).to_string() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI: NamedTuple methods don't follow the same naming scheme as most other python classes. Despite starting with an underscore, the _replace
method is public API https://docs.python.org/3/library/collections.html#collections.somenamedtuple._replace
(PackageURL is a NamedTuple)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, super tiny nitpicks.
I have zero previous experience with this though, so you might want another reviewer to take a look too
sbom-utility-scripts/scripts/merge-cachi2-sboms-script/test_merge_cachi2_sboms.py
Outdated
Show resolved
Hide resolved
sbom-utility-scripts/scripts/merge-cachi2-sboms-script/merge_cachi2_sboms.py
Show resolved
Hide resolved
The SBOM files are too large to inspect by hand. Check the property that we care about most - the components present in the merged SBOM that were not present in the cachi2 SBOM. Note: this uncovers some bugs (the gomod and npm packages shouldn't be there, they're duplicates). To be fixed later. Also disable the flake8 line-length check; it is useless since we already use 'black' for formatting. Signed-off-by: Adam Cmiel <[email protected]>
An SBOM item is anything that has a name, version and purl. Such as a CycloneDX component or SPDX package. Will be used to implement SPDX support more seamlessly. Also set flake8 to run on python 3.12. In Github CI, the check was failing with a syntax error otherwise (generics syntax). Signed-off-by: Adam Cmiel <[email protected]>
Much easier to use than parsing raw purls manually Signed-off-by: Adam Cmiel <[email protected]>
This removes 4 of the 5 false-positive Go modules in the merged SBOM. One remains - Syft reports it *completely* wrong, not much we can do about that. Signed-off-by: Adam Cmiel <[email protected]>
Cachi2 puts the path in the purl subpath, syft puts it in the namespace and name. Signed-off-by: Adam Cmiel <[email protected]>
504d0c0
to
4e2ef25
Compare
@brunoapimentel you're probably the only one with more experience regarding this script if you want to take a look 😄 |
Gonna merge this, there are more big changes coming 😅 |
https://issues.redhat.com/browse/STONEBLD-3045
Primarily, the need to do this came from working on SPDX. I needed to get equivalent SPDX SBOMs for the CycloneDX SBOMs in our test data. But nobody knows how those were generated, so I re-generated them in a more repeatable way. And that uncovered some bugs.
See the individual commits for more details