Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions syft/format/common/cyclonedxhelpers/to_format_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func ToFormatModel(s sbom.SBOM) *cyclonedx.BOM {

artifacts := s.Artifacts

// if the source under analysis is a single file (e.g., a lockfile like conan.lock),
// do not add that source file itself as a component entry in the SBOM components list.
// This keeps behavior consistent across OSes and avoids listing the input document as a component.
var srcFilePath string
if fm, ok := s.Source.Metadata.(source.FileMetadata); ok {
srcFilePath = fm.Path
}

for _, coordinate := range coordinates {
var metadata *file.Metadata
// File Info
Expand All @@ -72,6 +80,11 @@ func ToFormatModel(s sbom.SBOM) *cyclonedx.BOM {
}
metadata = &fileMetadata

// Skip adding the source file itself as a component (e.g., conan.lock when scanned directly)
if srcFilePath != "" && metadata.Path == srcFilePath {
continue
}

// Digests
var digests []file.Digest
if digestsForLocation, exists := artifacts.FileDigests[coordinate]; exists {
Expand Down
Loading