bug: spdx checksum empty array; allow syft to generate SHA1 for spdx-tag-value documents#1404
Merged
bug: spdx checksum empty array; allow syft to generate SHA1 for spdx-tag-value documents#1404
Conversation
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
example of empty file being ignored /lib/apk/db/lock Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
650935b to
e7948cc
Compare
Benchmark Test ResultsBenchmark results from the latest changes vs base branch |
spiffcs
commented
Dec 14, 2022
spiffcs
commented
Dec 14, 2022
spiffcs
commented
Dec 14, 2022
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
This was
linked to
issues
Dec 14, 2022
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Contributor
Author
|
-- |
previously we were using filesOwned to interpret files needed for the packageVerificationCode. This commit simplifies this logic by defaulting to using the ContainsRelationship Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
wagoodman
reviewed
Dec 19, 2022
kzantow
reviewed
Dec 19, 2022
Contributor
kzantow
left a comment
There was a problem hiding this comment.
This is great -- I can't wait to be able to have completely valid SPDX files!
Only real question is about image-java-spdx-tools/Dockerfile, primarily because I believe I saw that you might like to add some tests for this.
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
wagoodman
reviewed
Dec 19, 2022
kzantow
approved these changes
Dec 19, 2022
wagoodman
reviewed
Dec 19, 2022
wagoodman
approved these changes
Dec 19, 2022
Contributor
wagoodman
left a comment
There was a problem hiding this comment.
I have a couple of nit comments on the new test (feel free to take it or leave it). Overall a quite-worthy improvement to the SPDX validation --thanks for your time on this 🚀
wagoodman
reviewed
Dec 19, 2022
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs
added a commit
to raboof/syft
that referenced
this pull request
Dec 20, 2022
* main: (87 commits) feat: Add license parsing for java (anchore#1385) fix: cyclonedx component type for binaries (anchore#1406) fix: openjdk detection pattern (anchore#1415) bug: spdx checksum empty array; allow syft to generate SHA1 for spdx-tag-value documents (anchore#1404) Add NetBSD support. (anchore#1412) feat: add catalog delete (anchore#1377) docs: remove file classifier (anchore#1397) chore: update latest cyclonedx library (anchore#1390) feat: Add Java binary catalogers (anchore#1392) chore: Update SPDX license list to 3.19 (anchore#1389) fix: add manual vendor/product removal to fix false flags (anchore#1070) Update Stereoscope to c5ff155d72f166e2332e160a75c3ff2b8e9c7e2e (anchore#1395) chore: fix test busybox image sha (anchore#1393) fix: go version not properly identified in binary (anchore#1384) Update Stereoscope to 3b80d983223f6e6fc2d33b0ffa003d30268418e9 (anchore#1376) fix: Update node binary package name (anchore#1375) feat: Generic Binary Cataloger (anchore#1336) recover from bad parsing of golang binary (anchore#1371) Fix parsing of apk databases with large entries (anchore#1365) Update syft bootstrap tools to latest versions. (anchore#1369) ...
GijsCalis
pushed a commit
to GijsCalis/syft
that referenced
this pull request
Feb 19, 2024
…tag-value documents (anchore#1404)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Syft currently generates SPDX documents that do not contain SHA1 digests for the files by default.
For a user to obtain a document that meets the current specification the following has to be true:
app.FileMetadata.Cataloger.Enabledapp.FileMetadata.Digestsmust addsha1to the list of desired digests (currently defaults to sha256)Here is a link to the reference that shows this requirement:
https://spdx.github.io/spdx-spec/v2.3/file-information/#84-file-checksum-field
How to test ---
I've provided a docker image that wraps the
spdx-java-tools:caphill4/java-spdx-toolsThree images are supplied by #1401
You can follow these steps to see the newly valid spdx documents. Make sure to replace
<IMAGE>with one of the above.Context
Running the following command
syft -o spdx-json alpine:latest > spdx.jsongenerates an SPDX json document.pyspdxtools_parser --file spdx.spdxThis results in a python error:
TypeError: 'NoneType' object is not iterableThe fix in this PR updates the checksum array from
null==>[]Given that a user has enabled the file digest cataloger:
SYFT_FILE_METADATA_CATALOGER_ENABLED=true SYFT_FILE_METADATA_DIGESTS=sha1This PR adds the ability to generate a valid SPDX document by enhancing the package entity with a
PackageVerificationCode.The
PackageVerificationCodeis generated by obtaining all of theContainsrelationships for a package and performing the following algorithm:https://spdx.github.io/spdx-spec/v2.3/package-information/#79-package-verification-code-field
Note:
We use the
Containsrelationship here since this is the value the SPDX validator will key off of if a package verification code is missing.Example:
Validator warns:
At least one file checksum algorithm must be SHA1 for package x filesAfter providing a SHA1 digest for the file:
Validator warns:
Found analyzed files for package x when analyzedFiles is set to falseAfter settting analyzedFiles to true:
Validator warns:
Missing Package Verification Code for package xNote
Empty-size checks were removed from the digest cataloger in order to produce a valid document where empty files like
/lib/apk/db/lockwere not being summed.If this is incorrect or needs to be reworked so we're not missing some edge case regarding the removed tar file note I'm happy to refactor.