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

merge-cachi2-sboms: re-generate test data, fix uncovered bugs #204

Merged
merged 6 commits into from
Dec 19, 2024

Conversation

chmeliik
Copy link
Contributor

@chmeliik chmeliik commented Dec 17, 2024

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

@chmeliik chmeliik requested a review from a team as a code owner December 17, 2024 10:56
@chmeliik
Copy link
Contributor Author

Reviewer guide:

  • first commit (the vast majority of lines changed) is a script for generating test data + generated test data
  • everything up to the handle ... commits is refactoring
  • the two handle ... commits are bugfixes

@chmeliik chmeliik force-pushed the merge-cachi2-sboms-tests branch 2 times, most recently from 6ef813a to 1214a67 Compare December 18, 2024 10:14
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]>
@chmeliik chmeliik force-pushed the merge-cachi2-sboms-tests branch from 1214a67 to 504d0c0 Compare December 18, 2024 10:16
@chmeliik
Copy link
Contributor Author

I noticed the generated SBOMs were changing every time I reran the test_data/assemble-input-sboms.sh script. Fixed that.

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()
Copy link
Contributor Author

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)

Copy link
Contributor

@tnevrlka tnevrlka left a 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

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]>
@chmeliik chmeliik force-pushed the merge-cachi2-sboms-tests branch from 504d0c0 to 4e2ef25 Compare December 18, 2024 14:51
@chmeliik
Copy link
Contributor Author

@brunoapimentel you're probably the only one with more experience regarding this script if you want to take a look 😄

@chmeliik chmeliik requested a review from a team December 19, 2024 12:35
@chmeliik
Copy link
Contributor Author

Gonna merge this, there are more big changes coming 😅

@chmeliik chmeliik merged commit f2e6d10 into konflux-ci:main Dec 19, 2024
1 check passed
@chmeliik chmeliik deleted the merge-cachi2-sboms-tests branch December 19, 2024 12:59
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.

2 participants