-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove second call to finalize as the task handles it (#2516)
* fix: remove second call to finalize as the task handles it Signed-off-by: Christopher Phillips <[email protected]> * test: add test to protect against dupe relationships in final SBOM Signed-off-by: Christopher Phillips <[email protected]> --------- Signed-off-by: Christopher Phillips <[email protected]>
- Loading branch information
Showing
2 changed files
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
test/integration/regression_sbom_duplicate_relationships_test.go
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package integration | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/scylladb/go-set/strset" | ||
|
||
"github.com/anchore/syft/syft/source" | ||
) | ||
|
||
func TestRelationshipsUnique(t *testing.T) { | ||
// This test is to ensure that the relationships are deduplicated in the final SBOM. | ||
// It is not a test of the relationships themselves. | ||
// This test is a regression test for #syft/2509 | ||
sbom, _ := catalogFixtureImage(t, "image-pkg-coverage", source.SquashedScope) | ||
observedRelationships := strset.New() | ||
|
||
for _, rel := range sbom.Relationships { | ||
unique := fmt.Sprintf("%s:%s:%s", rel.From.ID(), rel.To.ID(), rel.Type) | ||
if observedRelationships.Has(unique) { | ||
t.Errorf("duplicate relationship found: %s", unique) | ||
} | ||
observedRelationships.Add(unique) | ||
} | ||
} |