Skip to content

Commit f667803

Browse files
committed
fix(#48): summary report severity count
Vulnerabilities should be sorted by severity kind instead of severity score. This is because the acknowledged kind is computed by us, and overrides the actual score since we deem it AOK
1 parent 1f4956c commit f667803

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

internal/publish/to_issue.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ func severityBiggerThan(a string, b string) bool {
6767
func groupVulnReportsByMaxSeverityKind(reports []scanner.Report) map[scanner.SeverityScoreKind][]scanner.Report {
6868
vulnerableReports := pie.Filter(reports, func(r scanner.Report) bool { return r.IsVulnerable })
6969
groupedVulnerabilities := pie.GroupBy(vulnerableReports, func(r scanner.Report) scanner.SeverityScoreKind {
70-
maxSeverity := pie.SortUsing(r.Vulnerabilities, func(a, b scanner.Vulnerability) bool { return a.Severity > b.Severity })[0]
70+
maxSeverity := pie.SortUsing(r.Vulnerabilities, func(a, b scanner.Vulnerability) bool {
71+
return scanner.SeverityScoreThresholds[a.SeverityScoreKind] > scanner.SeverityScoreThresholds[b.SeverityScoreKind]
72+
})[0]
7173

7274
return maxSeverity.SeverityScoreKind
7375
})

internal/publish/to_slack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
func PublishAsGeneralSlackMessage(channelNames []string, reports []scanner.Report, paths []string, s slack.IService) error {
2121
var wg sync.WaitGroup
2222
errChan := make(chan error, len(channelNames))
23-
vulnerableReportsBySeverityKind := groupVulnReportsByMaxSeverityKind(reports)
23+
vulnerableReportsByMaxSeverityKind := groupVulnReportsByMaxSeverityKind(reports)
2424

25-
summary := formatSummary(vulnerableReportsBySeverityKind, len(reports), paths)
26-
threadMsgs := formatReportMessage(vulnerableReportsBySeverityKind)
25+
summary := formatSummary(vulnerableReportsByMaxSeverityKind, len(reports), paths)
26+
threadMsgs := formatReportMessage(vulnerableReportsByMaxSeverityKind)
2727
for _, slackChannel := range channelNames {
2828
log.Info().Str("slackChannel", slackChannel).Msg("Posting report to slack channel")
2929
wg.Add(1)

0 commit comments

Comments
 (0)