Skip to content

Commit 064b713

Browse files
committed
set statusnote if all detail fields are empty
Signed-off-by: Irena Liu <[email protected]>
1 parent a7f86b8 commit 064b713

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-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: 10 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,7 +589,14 @@ 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.Analysis.State != cdx.IASResolved &&
593+
vulnerability.Analysis.State != cdx.IASExploitable &&
594+
vulnerability.Analysis.State != cdx.IASInTriage &&
595+
vulnerability.Analysis.State != cdx.IASNotAffected {
596+
// Only preserve the CDX state enum information if it's not one of the original 4 states, since those provide additional context beyond what's already captured in vd.Status
597+
// Original states: IASResolved, IASExploitable, IASInTriage, IASNotAffected
598+
vd.StatusNotes = fmt.Sprintf("CDX state: %s", string(vulnerability.Analysis.State))
599+
} else if vulnerability.Detail != "" {
591600
vd.StatusNotes = vulnerability.Detail
592601
}
593602
} else {

0 commit comments

Comments
 (0)