Skip to content

Commit 0201225

Browse files
committed
set statusnote if all detail fields are empty
1 parent a7f86b8 commit 0201225

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/testing/testdata/testdata.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ var (
126126
//go:embed exampledata/cyclonedx-vex-false-positive.json
127127
CycloneDXVEXFalsePositive []byte
128128

129+
//go:embed exampledata/cyclonedx-vex-resolved-with-pedigree-no-detail.json
130+
CycloneDXVEXResolvedWithPedigreeNoDetail []byte
131+
132+
//go:embed exampledata/cyclonedx-vex-false-positive-no-detail.json
133+
CycloneDXVEXFalsePositiveNoDetail []byte
134+
129135
//go:embed exampledata/cyclonedx-vex.xml
130136
CyloneDXVEXExampleXML []byte
131137

pkg/ingestor/parser/cyclonedx/parser_cyclonedx.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ func (c *cyclonedxParser) getVulnerabilities(ctx context.Context) error {
579579
vd.KnownSince = publishedTime
580580
vd.Statement = vulnerability.Description
581581

582+
// Extract StatusNotes from analysis detail field.
583+
// This applies to all analysis states including resolved_with_pedigree and false_positive.
582584
if vulnerability.Analysis.Detail != "" {
583585
vd.StatusNotes = vulnerability.Analysis.Detail
584586
} else if vulnerability.Analysis.Response != nil {
@@ -587,8 +589,12 @@ func (c *cyclonedxParser) getVulnerabilities(ctx context.Context) error {
587589
response = append(response, string(res))
588590
}
589591
vd.StatusNotes = strings.Join(response, ",")
590-
} else {
592+
} else if vulnerability.Detail != "" {
591593
vd.StatusNotes = vulnerability.Detail
594+
} else {
595+
// If all detail fields are empty, preserve the CDX state enum information
596+
// to avoid losing this metadata (e.g., "CDX state: resolved_with_pedigree")
597+
vd.StatusNotes = fmt.Sprintf("CDX state: %s", string(vulnerability.Analysis.State))
592598
}
593599
} else {
594600
vd = model.VexStatementInputSpec{

0 commit comments

Comments
 (0)