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

Skip to content

Conversation

@luhring
Copy link
Contributor

@luhring luhring commented Mar 24, 2022

In this PR:

  1. I added a failing test that loops through all formats used by the syft package to ensure that no formats panic when trying to decode or validate an empty SBOM.
  2. I fixed the failing test by adding a nil check to the SPDX document processing logic.

Additionally, for convenience, I implemented fmt.Stringer on the format.ID type for use in string descriptions of format operations. This can be undone if needed!

This prevents the panic shown in anchore/grype#693, but a separate Grype PR will catch the "empty SBOM" case even earlier to provide a more direct error message to the user. So this PR isn't strictly necessary with regard to anchore/grype#693, but it still fixes a panic case for the Syft library.

@luhring luhring merged commit a7db43f into anchore:main Mar 24, 2022
@luhring luhring deleted the fix-panic-on-empty-sbom branch March 24, 2022 14:11
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* Implement fmt.Stringer with format.ID

Signed-off-by: Dan Luhring <[email protected]>

* Add failing test for formats processing empty SBOMs

Signed-off-by: Dan Luhring <[email protected]>

* Account for nil SPDX document during Syft model conversion

Signed-off-by: Dan Luhring <[email protected]>
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