fix(cyclonedx): duplicated entries in dependsOn#9802
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/pljava@1.6.6"
}
],
"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/pljava@1.6.6"
}
],
"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/pljava@1.6.6"
}
],
"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: pkgB@2.0.0. 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. |
|
No problem! I’ve created #9815 for it. |
|
This PR is stale because it has been labeled with inactivity. |
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