Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wagoodman
Copy link
Contributor

@wagoodman wagoodman commented Nov 19, 2020

Today we use CPEs in grype during the matching process, however, this is really a SBOM field being ephemerally created and thrown away --this could be useful in other aspects SBOM-wise.

This PR does the following:

  • Adds CPEs and PURL to the pkg.Package struct.
  • Does post-processing of packages after the catalogers but before being added to the catalog.
  • The above point makes the syft.Catalog step dependent on distro, so distro identification has been moved under this call (and removed as an independent action from lib.go)
  • When distro.Identify() cannot identify a distro it now returns nil, being consistent with other properties that have the same behavior.
  • Unrelated: oraclelinux distro testing was missed previously, so was added here

Notes:

  • this PR opens up future work to include CPEs into presenters (Add the Common Platform Enumeration (CPE) for the CycloneDX output #268), but in this PR has only been exposed in the JSON presenter.
  • this PR decided to do a "minimal" approach and allow a central spot (within syft.cataloger) to be responsible for accumulating purls and CPEs and attaching them to a package object, however, there is probably a better way to do this in the future. One outcome of this was to start considering individual catalogers to be only responsible for discovering and raising up "raw" information from the entity being cataloged, and interpretations of this data is considered "out of scope" for the catalogers and should be attached to the package downstream of the individual catalogers.

Closes #269

@wagoodman wagoodman requested a review from a team November 19, 2020 16:25
@wagoodman wagoodman self-assigned this Nov 19, 2020
Copy link
Contributor

@luhring luhring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! The only thing I'm not clear on is all the places that Distro was changed to use a pointer... IIRC, this was just recently changed from a pointer type to a non-pointer type. Not a blocking issue for this PR.

@wagoodman
Copy link
Contributor Author

fair question. In #266 the change from pointer to non-pointer of downstream usages of distro.Distro was to eliminate the need for the pointer since the caller should be checking the distro.Type explicitly (and there should never be an empty distro). This PR changes the semantics such that distro.Identify() can indicate it could not identify the distro via a nil pointer (changing the underlying semantics to exists-or-not-exists, and changing downstream references to need the pointer type, where earlier these downstream pointers were not needed).

@wagoodman wagoodman merged commit 0ed3013 into main Nov 19, 2020
@wagoodman wagoodman deleted the cpe-generation branch November 19, 2020 17:38
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
Move package PURL and CPEs to Package definition
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.

Migrate CPE generation to syft (and generally output package identities)

3 participants