-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(cyclonedx): duplicated entries in dependsOn #9802
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
base: main
Are you sure you want to change the base?
Conversation
fd46b5a to
d6c9097
Compare
d6c9097 to
5a46565
Compare
|
Hi @d3vv3, I checked the image. It contains three identical packages that differ only by the SPDXID suffix. This looks like a bug. ➜ cat .spdx-postgresql.spdx | jq ' .packages[] | select (.name=="org.postgresql:pljava")'
{
"name": "org.postgresql:pljava",
"SPDXID": "SPDXRef-Package-81b064a6dd4b165f",
"versionInfo": "1.6.6",
"supplier": "NOASSERTION",
"downloadLocation": "NONE",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"copyrightText": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE_MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:maven/org.postgresql/[email protected]"
}
],
"filesAnalyzed": false
}
{
"name": "org.postgresql:pljava",
"SPDXID": "SPDXRef-Package-200e4c8a9fedcdb5",
"versionInfo": "1.6.6",
"supplier": "NOASSERTION",
"downloadLocation": "NONE",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"copyrightText": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE_MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:maven/org.postgresql/[email protected]"
}
],
"filesAnalyzed": false
}
{
"name": "org.postgresql:pljava",
"SPDXID": "SPDXRef-Package-c30a860d16f62e1b",
"versionInfo": "1.6.6",
"supplier": "NOASSERTION",
"downloadLocation": "NONE",
"licenseConcluded": "NONE",
"licenseDeclared": "NONE",
"copyrightText": "NOASSERTION",
"externalRefs": [
{
"referenceCategory": "PACKAGE_MANAGER",
"referenceType": "purl",
"referenceLocator": "pkg:maven/org.postgresql/[email protected]"
}
],
"filesAnalyzed": false
}SPDXRef-Package-200e4c8a9fedcdb5 and SPDXRef-Package-c30a860d16f62e1b do not have any relationships with other components. If this is not a bug, then we cannot simply drop the duplicates — we would “lose” some of the packages. Regards, Dmitriy |
|
Hi @DmitriyLewen I added the SPDXID to maintain uniqueness. I think the previous commit is still important to ensure the output schema is valid. What do you think? |
In this case, we must not prioritize a “valid-looking” SBOM over correct package detection. So we shouldn’t remove duplicated packages.
About SPDXID — this field helps us see that packages are different (in pkgIdentifier.UID). For example, in the SBOM we have: For the SPDX-1 and SPDX-3 packages, the DependsOn entry will be the same: [email protected]. This situation is similar to the problem we had with Maven modules: I think we should use bomRef / SPDXID as the Package.ID. We already discussed about BOMID (#9597 (comment)) |
|
Hi @DmitriyLewen , thanks for your input. Then, as for the invalid cyclonedx format, I think trivy should fail and exit when there al duplicated entries in a For the root cause of the issue, thanks for the explanation. I see that it would be a huge refactor and it would sadly escape my golang skills. |
Description
Reproduce:
trivy -q image --format cyclonedx --output /tmp/postgresql.json --timeout 3600s --parallel 2 docker.io/bitnamilegacy/postgresql:15.4.0-debian-11-r45cat /tmp/postgresql.json | jq ".dependencies[139].dependsOn"Related issues
Related PRs
Remove this section if you don't have related PRs.
Checklist