Skip to content

Commit

Permalink
Add snooze or mute check for sca vulnerabilities (#845)
Browse files Browse the repository at this point in the history
* Add snooze or mute check for sca vulnerabilities

* Add snooze or mute check for sca vulnerabilities

---------

Co-authored-by: AlvoBen <[email protected]>
  • Loading branch information
AlvoBen and BenAlvo1 authored Aug 26, 2024
1 parent 6f2411f commit f16ae22
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/commands/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ const (
redundantLabel = "redundant"
delayValueForReport = 10
fixLinkPrefix = "https://devhub.checkmarx.com/cve-details/"
snoozeLabel = "Snooze"
muteLabel = "Muted"
)

var summaryFormats = []string{
Expand Down Expand Up @@ -2332,12 +2334,16 @@ func buildScaType(typesByCVE map[string]wrappers.ScaTypeCollection, result *wrap

func buildScaState(typesByCVE map[string]wrappers.ScaTypeCollection, result *wrappers.ScanResult) string {
types, ok := typesByCVE[result.ID]
if ok && types.IsIgnored {
if ok && (types.IsIgnored || isSnoozeOrMutePackage(&types)) {
return notExploitable
}
return result.State
}

func isSnoozeOrMutePackage(result *wrappers.ScaTypeCollection) bool {
return strings.EqualFold(result.RiskState, snoozeLabel) || strings.EqualFold(result.RiskState, muteLabel)
}

func addPackageInformation(
resultsModel *wrappers.ScanResultsCollection,
scaPackageModel *[]wrappers.ScaPackageCollection,
Expand Down
1 change: 1 addition & 0 deletions internal/wrappers/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ type ScaType struct {
ID string `json:"Id,omitempty"`
Type string `json:"Type,omitempty"`
IsIgnored bool `json:"IsIgnored,omitempty"`
RiskState string `json:"RiskState,omitempty"`
}
1 change: 1 addition & 0 deletions internal/wrappers/results-sca-package.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ type ScaTypeCollection struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
IsIgnored bool `json:"isIgnored,omitempty"`
RiskState string `json:"omitempty"`
}

0 comments on commit f16ae22

Please sign in to comment.