TC-1609 Improve package's qualifiers management #86
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.
Description of the PR
The issue happens when:
pkg:maven/io.github.crac/org-crac@0.1.1.redhat-00002?repository_url=https://maven.repository.redhat.com/ga/&type=jar
is ingested from Quarkus SBOMpkg:maven/io.github.crac/org-crac@0.1.1.redhat-00002?type=jar
is ingested from SBOM "B": this ingestion fails with the errorIt's due to the fact that, when adding an
HasMetadata
node, there's a uniqueness check for the package specs to identify a single package. In the scenario described above, both packagespkg:maven/io.github.crac/org-crac@0.1.1.redhat-00002?repository_url=https://maven.repository.redhat.com/ga/&type=jar
andpkg:maven/io.github.crac/org-crac@0.1.1.redhat-00002?type=jar
have been already ingested and theQualifiersMatch
method checks for the provided qualifiers into the DB, i.e.type=jar
, hence finding both the packages that satisfy this condition and hence generating the error.The fix adds a further check that, after having checked all of input package spec qualifiers are available, it also checks the size of the array of the qualifiers to ensure package with a superset of the input qualifiers, e.g.
repository_url=https://maven.repository.redhat.com/ga/
, aren't considered as a valid matching package.I've added a further integration test that loads the SBOM "B" for reproducing this issue with a query to check the
HasMetadata
info is available.Fixes https://issues.redhat.com/browse/TC-1609
"Bonus fix": the log entry
IngestBulkHasMetadata failed with element
was erroneously usingi
instead ofindex
PR Checklist
-s
flag togit commit
.make generate
has been runcollectsub
protobuf has been changed,make proto
has been run