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

GenerateFromDependency without CPE or PURL #373

Merged
merged 6 commits into from
Aug 5, 2022
Merged

GenerateFromDependency without CPE or PURL #373

merged 6 commits into from
Aug 5, 2022

Conversation

fg-j
Copy link

@fg-j fg-j commented Aug 3, 2022

Summary

Currently, it's not possible to use GenerateFromDependency() in paketo-buildpacks/vsdbg#1 because the vsdbg dependency has neither a CPE nor a PURL and 'GenerateFromDependency()' fails if the dependency lacks a CPE. With this change, the function generates an SBOM when the CPE is absent. The tests also assert that SBOM generation succeeds without a PURL.

⚠️ Note

As you can see in the test assertions, for SPDX and Syft SBOMs, when the dependency CPE is empty, the SBOM output gets cpe:2.3:-:-:-:-:-:-:-:-:-:-:- for its CPE. As far as I can gather from the CPE Naming Spec 2.3, this means that every attribute of the software gets the value "NA" or Not Applicable.

My understanding is that consumers will compare CPEs in SBOMs to CPEs in published vulnerability notices. If the CPEs in an SBOM match the CPEs for a vulnerability, the software is deemed vulnerable. The CPE Matching Spec 2.3 describes how tools are supposed to compare CPEs to understand whether a given piece of software contains a vulnerability.

From what I can tell in that document, assigning an "all N/A" CPE to dependencies with unknown CPEs is our best way to avoid false positives. We don't want a dependency with unknown CPE to set off alarms that it's vulnerable to CVEs in unrelated packages, (or, even worse, CVEs in all packages.)

✋ Help

The naming spec and matching spec are dense. I'd appreciate a second set of eyes to confirm if my choice of UnknownCPE makes sense.

Todo:

  • Add godoc to UnknownCPE once its value is confirmed

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@fg-j fg-j requested a review from a team as a code owner August 3, 2022 21:53
@ForestEckhardt ForestEckhardt added the semver:minor A change requiring a minor version bump label Aug 4, 2022
@ForestEckhardt ForestEckhardt added this to the v2.4.0 milestone Aug 4, 2022
@fg-j fg-j self-assigned this Aug 4, 2022
@fg-j
Copy link
Author

fg-j commented Aug 5, 2022

I've spent some time playing around with a Golang implementation of the CPE2.3 naming and matching specs: https://github.com/knqyf263/go-cpe. As you can see in this Go playground example, the UnknownCPE I've chosen is consistently disjoint with other CPEs. This gives me pretty good confidence that it won't cause false positives.

ForestEckhardt
ForestEckhardt previously approved these changes Aug 5, 2022
@fg-j fg-j merged commit 444cccb into v2 Aug 5, 2022
@fg-j fg-j deleted the sbom-without-cpe branch August 5, 2022 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants