-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
feat: introduce package UIDs for improved vulnerability mapping #6583
Conversation
[skip ci] Signed-off-by: knqyf263 <[email protected]>
@DmitriyLewen Please let me know if you have a better idea. |
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
My first thought about this was "Why can't we just use the file path" (another reason to get rid of the two file paths). So your solution is good. This will make it easier to detect the vulnerable package in But I was worried about the hash. It is inconvenient to use manually - this value means nothing to the user. So I think this is a good idea and should be implemented as you suggested. |
Thanks for your input.
PURLs are not IDs that uniquely identify installed packages, so we used to use PURLs + file paths, but that was not suitable for the PURL specification. Then, we have now changed the logic of the CycloneDX output and use UUIDs when PURLs conflict. |
Signed-off-by: knqyf263 <[email protected]>
pkg/fanal/test/integration/testdata/goldens/packages/alpine-310.json.golden
Show resolved
Hide resolved
Signed-off-by: knqyf263 <[email protected]>
218bbb8
to
a188c94
Compare
@DmitriyLewen I didn't come up with a good idea of where we should calculate the UID. Please let me know if you have a better one. |
Signed-off-by: knqyf263 <[email protected]>
Signed-off-by: knqyf263 <[email protected]>
I think you chose a good place. we create identifiers (purl, uid) in one place. |
@DmitriyLewen It's finally ready for review! The tests passed in my env, but failed on GitHub Actions because some tests run only on Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…security#6583) Signed-off-by: knqyf263 <[email protected]>
Description
Currently, Trivy outputs Packages and Vulnerabilities separately in JSON format, with detected vulnerabilities including a subset of package metadata such as name and version. However, identifying the original package from this limited metadata can be challenging in certain scenarios:
To accurately associate detected vulnerabilities with their corresponding packages in these cases, this PR introduces the concept of package UIDs. These UIDs are calculated from the Package struct and serve as unique identifiers for each package. It's important to note that these values (hashes) are not the same as digests used for ensuring integrity; they are solely intended for uniquely identifying packages within Trivy.
One advantage of using hashes instead of UUIDs is that the same hash value will be generated across multiple runs for the same package.
Checklist