Skip to content

Commit f5e60a9

Browse files
authored
create isoccur for top level package when artifact is found (#2137)
Signed-off-by: pxp928 <[email protected]>
1 parent 430b768 commit f5e60a9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

internal/testing/testdata/testdata.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,16 @@ var (
11271127
}
11281128

11291129
CdxIngestionPredicates = assembler.IngestPredicates{
1130+
IsOccurrence: []assembler.IsOccurrenceIngest{
1131+
{
1132+
Pkg: cdxTopLevelPack,
1133+
Artifact: &model.ArtifactInputSpec{
1134+
Algorithm: "sha256",
1135+
Digest: "6ad5b696af3ca05a048bd29bf0f623040462638cb0b29c8d702cbb2805687388",
1136+
},
1137+
IsOccurrence: isOccurrenceJustifyTopPkg,
1138+
},
1139+
},
11301140
IsDependency: CdxDeps,
11311141
HasSBOM: CdxHasSBOM,
11321142
}

pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,8 @@ func (c *cyclonedxParser) GetPredicates(ctx context.Context) *assembler.IngestPr
387387
logger.Infof("CDX artifact was not parsable: %v", err)
388388
} else {
389389
topLevelArts = append(topLevelArts, artInput)
390+
// append to packageArtifacts so that isOccurrence is created
391+
c.packageArtifacts[c.cdxBom.Metadata.Component.BOMRef] = append(c.packageArtifacts[c.cdxBom.Metadata.Component.BOMRef], artInput)
390392
logger.Infof("getArtInput %v", artInput)
391393
}
392394
}

0 commit comments

Comments
 (0)