Skip to content

Modern Docker Management, Designed for Everyone

chore: update risk scoring

Kyle Mendell7b2ca2661fc3
diff --git a/backend/internal/vulnerability/service_test.go b/backend/internal/vulnerability/service_test.go
index 3ffc08846..3ac79c949 100644
--- a/backend/internal/vulnerability/service_test.go
+++ b/backend/internal/vulnerability/service_test.go
@@ -6,7 +6,6 @@ import (
"context"
"encoding/json"
"fmt"
- "math"
"net/http"
"net/http/httptest"
"strings"
@@ -708,168 +707,6 @@ func TestVulnerabilityService_ListAllVulnerabilities_PagesAndCountsWithInlineFil
require.EqualValues(t, 3, page.GrandTotalItems)
}
-func TestBuildScanInsightsInternal(t *testing.T) {
- vulns := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-LOW", PkgName: "zlib", InstalledVersion: "1.0.0", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 3}},
- {VulnerabilityID: "CVE-HIGH-1", PkgName: "openssl", InstalledVersion: "3.0.0", FixedVersion: "3.0.2", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 7.5}},
- {VulnerabilityID: "CVE-HIGH-2", PkgName: "openssl", InstalledVersion: "3.0.0", FixedVersion: "3.0.10", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V2Score: 7.8}},
- {VulnerabilityID: "CVE-MED", PkgName: "curl", InstalledVersion: "8.0.0", Severity: vulnerability.SeverityMedium},
- }
-
- insights := buildScanInsightsInternal(vulns, nil, vulnerability.ImageExposureUnknown, false)
-
- require.Equal(t, "CVE-HIGH-2", insights.HighestVulnerabilityID)
- require.InDelta(t, 7.8, insights.HighestCVSS, 0.001)
- require.Equal(t, 2, insights.FixableCount)
- // Only the two fixable findings enter the average: (37.5 + 39) / 2 with no threat data and unknown usage.
- require.Equal(t, 38, insights.RiskScore)
- require.Equal(t, vulnerability.RiskBandLow, insights.RiskBand)
- require.Equal(t, vulnerability.ScoreStatusProvisional, insights.ScoreStatus)
-
- require.Len(t, insights.TopPackages, 3)
- require.Equal(t, vulnerability.PackageInsight{PkgName: "openssl", Severity: vulnerability.SeverityHigh, Count: 2, InstalledVersion: "3.0.0", FixedVersion: "3.0.10"}, insights.TopPackages[0])
- require.Equal(t, "curl", insights.TopPackages[1].PkgName)
- require.Equal(t, "zlib", insights.TopPackages[2].PkgName)
-}
-
-func TestBuildScanInsightsInternal_VolumeDoesNotInflateScore(t *testing.T) {
- kev := func(n int) ([]vulnerability.Vulnerability, map[string]VulnerabilityThreatIntel) {
- vulns := make([]vulnerability.Vulnerability, 0, n)
- intel := map[string]VulnerabilityThreatIntel{}
- for i := range n {
- id := fmt.Sprintf("CVE-%d", i)
- vulns = append(vulns, vulnerability.Vulnerability{VulnerabilityID: id, PkgName: fmt.Sprintf("pkg-%d", i), FixedVersion: "1.0.1", Severity: vulnerability.SeverityCritical, CVSS: &vulnerability.CVSSInfo{V3Score: 9.8}})
- intel[id] = VulnerabilityThreatIntel{CVEID: id, KnownExploited: true}
- }
- return vulns, intel
- }
-
- oneVulns, oneIntel := kev(1)
- manyVulns, manyIntel := kev(8)
- one := buildScanInsightsInternal(oneVulns, oneIntel, vulnerability.ImageExposureRunning, false)
- many := buildScanInsightsInternal(manyVulns, manyIntel, vulnerability.ImageExposureRunning, false)
- // Identical findings average to the same priority regardless of how many there are.
- require.Equal(t, 98, one.RiskScore)
- require.Equal(t, one.RiskScore, many.RiskScore)
- require.Equal(t, vulnerability.RiskBandCritical, many.RiskBand)
- require.Equal(t, vulnerability.ScoreStatusComplete, many.ScoreStatus)
- require.Len(t, many.TopPackages, topPackageInsightLimit)
-}
-
-func TestBuildScanInsightsInternal_NoFixableFindings(t *testing.T) {
- vulns := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-KEV", PkgName: "openssl", Severity: vulnerability.SeverityCritical, CVSS: &vulnerability.CVSSInfo{V3Score: 9.8}},
- }
- intel := map[string]VulnerabilityThreatIntel{"CVE-KEV": {CVEID: "CVE-KEV", KnownExploited: true}}
-
- insights := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureRunning, false)
-
- // An unfixable KEV stays visible but does not set a patch priority.
- require.Equal(t, 1, insights.KnownExploitedCount)
- require.Zero(t, insights.RiskScore)
- require.Equal(t, vulnerability.RiskBandNone, insights.RiskBand)
- require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
-}
-
-func TestBuildScanInsightsInternal_DeduplicatesFixableFindings(t *testing.T) {
- vulns := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-DUP", PkgName: "libssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
- {VulnerabilityID: "CVE-DUP", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
- {VulnerabilityID: "CVE-DUP", PkgName: "openssl-dev", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
- {VulnerabilityID: "CVE-LOW", PkgName: "zlib", FixedVersion: "1.3", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 2}},
- }
- intel := map[string]VulnerabilityThreatIntel{
- "CVE-DUP": {CVEID: "CVE-DUP", EPSSScore: new(0.0)},
- "CVE-LOW": {CVEID: "CVE-LOW", EPSSScore: new(0.0)},
- }
-
- insights := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureRunning, false)
-
- // CVE-DUP counts once at 40 and CVE-LOW at 10: the three package rows do not triple its weight.
- require.Equal(t, 25, insights.RiskScore)
- require.Equal(t, 3, insights.FixableCount)
- require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
-}
-
-func TestBuildScanInsightsInternal_UnknownSeverity(t *testing.T) {
- unscored := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-UNK", PkgName: "foo", FixedVersion: "2.0", Severity: vulnerability.SeverityUnknown},
- }
- insights := buildScanInsightsInternal(unscored, nil, vulnerability.ImageExposureRunning, false)
- require.Equal(t, vulnerability.ScoreStatusUnavailable, insights.ScoreStatus)
- require.Zero(t, insights.RiskScore)
-
- mixed := append(unscored, vulnerability.Vulnerability{VulnerabilityID: "CVE-KEV", PkgName: "bar", FixedVersion: "1.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}})
- intel := map[string]VulnerabilityThreatIntel{"CVE-KEV": {CVEID: "CVE-KEV", KnownExploited: true}}
- insights = buildScanInsightsInternal(mixed, intel, vulnerability.ImageExposureRunning, false)
- // The unscored finding is left out of the average but marks the score provisional.
- require.Equal(t, 60, insights.RiskScore)
- require.Equal(t, vulnerability.ScoreStatusProvisional, insights.ScoreStatus)
-}
-
-func TestBuildScanInsightsInternal_StaleIntelIsProvisional(t *testing.T) {
- vulns := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-KEV", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}},
- }
- intel := map[string]VulnerabilityThreatIntel{"CVE-KEV": {CVEID: "CVE-KEV", KnownExploited: true}}
-
- fresh := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureRunning, false)
- stale := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureRunning, true)
- require.Equal(t, vulnerability.ScoreStatusComplete, fresh.ScoreStatus)
- require.Equal(t, vulnerability.ScoreStatusProvisional, stale.ScoreStatus)
- require.Equal(t, fresh.RiskScore, stale.RiskScore)
-}
-
-func TestFindingPriorityInternal(t *testing.T) {
- zeroEPSS, lowEPSS, highEPSS := 0.0, 0.01, 0.97
- tests := []struct {
- name string
- base float64
- knownExploited bool
- epss *float64
- exposure vulnerability.ImageExposure
- want float64
- wantProvisional bool
- }{
- {name: "no intel running", base: 7.5, exposure: vulnerability.ImageExposureRunning, want: 37.5, wantProvisional: true},
- {name: "epss zero is complete", base: 7.5, epss: &zeroEPSS, exposure: vulnerability.ImageExposureRunning, want: 37.5},
- {name: "unknown exposure is provisional", base: 7.5, epss: &zeroEPSS, exposure: vulnerability.ImageExposureUnknown, want: 37.5, wantProvisional: true},
- {name: "known exploited", base: 6, knownExploited: true, exposure: vulnerability.ImageExposureRunning, want: 60},
- {name: "low epss", base: 7.5, epss: &lowEPSS, exposure: vulnerability.ImageExposureRunning, want: 41.25},
- {name: "high epss", base: 6, epss: &highEPSS, exposure: vulnerability.ImageExposureRunning, want: 60 * (0.5 + 0.5*math.Sqrt(0.97))},
- {name: "stopped", base: 5, knownExploited: true, exposure: vulnerability.ImageExposureStopped, want: 40},
- {name: "unused", base: 9.8, knownExploited: true, exposure: vulnerability.ImageExposureUnused, want: 49},
- {name: "maximum", base: 10, knownExploited: true, exposure: vulnerability.ImageExposureRunning, want: 100},
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- got, provisional := findingPriorityInternal(tt.base, tt.knownExploited, tt.epss, tt.exposure)
- require.InDelta(t, tt.want, got, 0.001)
- require.Equal(t, tt.wantProvisional, provisional)
- })
- }
-}
-
-func TestBuildScanInsightsInternal_ThreatIntelAndExposure(t *testing.T) {
- vulns := []vulnerability.Vulnerability{
- {VulnerabilityID: "CVE-KEV", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}},
- {VulnerabilityID: "CVE-OTHER", PkgName: "zlib", FixedVersion: "1.3", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 3}},
- }
- intel := map[string]VulnerabilityThreatIntel{"CVE-KEV": {CVEID: "CVE-KEV", KnownExploited: true}}
-
- running := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureRunning, false)
- require.Equal(t, 1, running.KnownExploitedCount)
- require.Equal(t, vulnerability.ImageExposureRunning, running.Exposure)
- require.InDelta(t, 6.0, running.HighestCVSS, 0.001)
- // (60 + 15) / 2; CVE-OTHER has no threat data so the score is provisional.
- require.Equal(t, 38, running.RiskScore)
- require.Equal(t, vulnerability.ScoreStatusProvisional, running.ScoreStatus)
-
- unused := buildScanInsightsInternal(vulns, intel, vulnerability.ImageExposureUnused, false)
- require.Equal(t, 19, unused.RiskScore)
- require.Less(t, unused.RiskScore, running.RiskScore)
-}
-
func riskTestServiceInternal(t *testing.T) (*VulnerabilityService, *settings.SettingsService, *database.DB) {
t.Helper()
settingsSvc, db := featureSettingsInternal(t)
@@ -930,7 +767,7 @@ func TestVulnerabilityService_GetRiskOverview(t *testing.T) {
// The highlighted fix is the highest-priority fixable occurrence: the KEV in db:16, not the unfixable copy in web.
require.NotNil(t, overview.ScoreDriver)
- require.Equal(t, vulnerability.RiskScoreDriver{VulnerabilityID: "CVE-2024-0002", ImageName: "db:16", PkgName: "curl", FixedVersion: "8.1.0", Exposure: vulnerability.ImageExposureUnknown, KnownExploited: true, Risk: 5.3}, *overview.ScoreDriver)
+ require.Equal(t, vulnerability.RiskScoreDriver{VulnerabilityID: "CVE-2024-0002", ImageName: "db:16", PkgName: "curl", FixedVersion: "8.1.0", Exposure: vulnerability.ImageExposureUnknown, KnownExploited: true, Risk: 10}, *overview.ScoreDriver)
require.Len(t, overview.RiskiestFindings, 3, "findings are deduplicated by CVE")
kev := overview.RiskiestFindings[0]
@@ -940,23 +777,23 @@ func TestVulnerabilityService_GetRiskOverview(t *testing.T) {
require.Equal(t, 2, kev.ImagesAffected)
require.Equal(t, "8.1.0", kev.FixedVersion)
require.InDelta(t, 5.3, kev.CVSS, 0.001, "CVSS comes from the stored cvss_score column")
- require.InDelta(t, 5.3, kev.Risk, 0.001)
+ require.InDelta(t, 10, kev.Risk, 0.001, "known exploited takes the maximum priority")
require.Equal(t, "CVE-2024-0001", overview.RiskiestFindings[1].VulnerabilityID)
- require.InDelta(t, 3.8, overview.RiskiestFindings[1].Risk, 0.001, "no threat data halves the priority")
+ require.InDelta(t, 5.3, overview.RiskiestFindings[1].Risk, 0.001, "no threat data discounts the priority")
require.Equal(t, "GHSA-xxxx", overview.RiskiestFindings[2].VulnerabilityID)
require.Len(t, overview.PrevalentFindings, 3)
require.Equal(t, "CVE-2024-0002", overview.PrevalentFindings[0].VulnerabilityID, "the only CVE in two images leads by prevalence")
- // web averages its single fixable finding (37.5), db its KEV (53), clean contributes 0: 90.5 / 3.
- require.Equal(t, 30, overview.RiskScore)
- require.Equal(t, vulnerability.RiskBandLow, overview.RiskBand)
- require.Equal(t, vulnerability.ScoreStatusProvisional, overview.ScoreStatus, "unknown usage and missing threat data")
+ // The images average to 36 with clean at zero, but db's running KEV keeps the environment at the High floor.
+ require.Equal(t, 70, overview.RiskScore)
+ require.Equal(t, vulnerability.RiskBandHigh, overview.RiskBand)
+ require.Equal(t, vulnerability.ScoreStatusComplete, overview.ScoreStatus, "unknown usage and missing threat data do not withhold the score")
require.Len(t, overview.RiskiestImages, 2)
require.Equal(t, "db:16", overview.RiskiestImages[0].ImageName)
- require.Equal(t, 53, overview.RiskiestImages[0].RiskScore)
- require.Equal(t, vulnerability.ScoreStatusProvisional, overview.RiskiestImages[0].ScoreStatus)
+ require.Equal(t, 70, overview.RiskiestImages[0].RiskScore)
+ require.Equal(t, vulnerability.ScoreStatusComplete, overview.RiskiestImages[0].ScoreStatus)
require.Equal(t, "web:latest", overview.RiskiestImages[1].ImageName)
- require.Equal(t, 38, overview.RiskiestImages[1].RiskScore, "the unfixable CVE-2024-0002 in web does not enter its average")
+ require.Equal(t, 37, overview.RiskiestImages[1].RiskScore, "the unfixable CVE-2024-0002 in web does not enter its score")
require.Len(t, overview.Trend, 1)
require.Nil(t, overview.Delta7d)
}
@@ -988,8 +825,8 @@ func TestVulnerabilityService_RecordRiskSnapshot(t *testing.T) {
seedRiskScansInternal(t, svc)
now := time.Now().UTC()
require.NoError(t, db.Create(&[]VulnerabilityRiskSnapshot{
- {SnapshotDate: now.AddDate(0, 0, -500).Format(riskDateLayout), ScoringVersion: riskScoringVersion, RiskScore: 10, RiskBand: "low"},
- {SnapshotDate: now.AddDate(0, 0, -7).Format(riskDateLayout), ScoringVersion: riskScoringVersion, RiskScore: 60, RiskBand: "medium", KnownExploitedCount: 3},
+ {SnapshotDate: now.AddDate(0, 0, -500).Format(riskDateLayout), ScoringVersion: vuln.ScoringVersion, RiskScore: 10, RiskBand: "low"},
+ {SnapshotDate: now.AddDate(0, 0, -7).Format(riskDateLayout), ScoringVersion: vuln.ScoringVersion, RiskScore: 60, RiskBand: "medium", KnownExploitedCount: 3},
{SnapshotDate: now.AddDate(0, 0, -3).Format(riskDateLayout), ScoringVersion: 1, RiskScore: 95, RiskBand: "critical"},
}).Error)
@@ -1001,7 +838,7 @@ func TestVulnerabilityService_RecordRiskSnapshot(t *testing.T) {
require.Len(t, snapshots, 3, "old snapshot pruned and same-day runs upserted")
today := snapshots[2]
require.Equal(t, now.Format(riskDateLayout), today.SnapshotDate)
- require.Equal(t, riskScoringVersion, today.ScoringVersion)
+ require.Equal(t, vuln.ScoringVersion, today.ScoringVersion)
require.Equal(t, 5, today.FindingsCount)
require.Equal(t, 3, today.ScoredImages)
diff --git a/backend/internal/vulnerability/vulnerability_query.go b/backend/internal/vulnerability/vulnerability_query.go
index e5043cf33..583efac6d 100644
--- a/backend/internal/vulnerability/vulnerability_query.go
+++ b/backend/internal/vulnerability/vulnerability_query.go
@@ -23,6 +23,7 @@ import (
"gorm.io/gorm/clause"
"github.com/getarcaneapp/arcane/backend/v2/internal/common"
+ "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/vuln"
"github.com/getarcaneapp/arcane/backend/v2/pkg/pagination"
"github.com/getarcaneapp/arcane/types/v2/vulnerability"
)
@@ -38,7 +39,7 @@ func (s *VulnerabilityService) GetScanResult(ctx context.Context, envID, imageID
if err != nil {
return nil, errors.WrapIf(err, "failed to filter ignored vulnerabilities")
}
- intel := map[string]VulnerabilityThreatIntel{}
+ intel := map[string]vuln.ThreatIntel{}
intelStatus := s.threatIntelStatusInternal(ctx)
if intelStatus.Enabled {
cveIDs := make([]string, 0, len(vulns))
@@ -50,11 +51,11 @@ func (s *VulnerabilityService) GetScanResult(ctx context.Context, envID, imageID
slog.WarnContext(ctx, "failed to load threat intel for image insights", "error", err)
}
for _, row := range rows {
- intel[row.CVEID] = row
+ intel[row.CVEID] = vuln.ThreatIntel{KnownExploited: row.KnownExploited, EPSS: row.EPSSScore}
}
}
usage, usageOK := s.containerUsageInternal(ctx)
- result.Insights = buildScanInsightsInternal(vulns, intel, imageExposureInternal(usage, usageOK, result.ImageID), intelStatus.Stale)
+ result.Insights = vuln.BuildScanInsights(vulns, intel, imageExposureInternal(usage, usageOK, result.ImageID))
return result, nil
}
@@ -154,7 +155,7 @@ func (s *VulnerabilityService) ListVulnerabilities(ctx context.Context, imageID
{
Key: "severity",
Fn: func(a, b vulnerability.Vulnerability) int {
- return severityRankInternal(a.Severity) - severityRankInternal(b.Severity)
+ return vuln.SeverityRank(a.Severity) - vuln.SeverityRank(b.Severity)
},
},
{
@@ -637,23 +638,6 @@ func splitNonEmptyCSVInternal(value string) []string {
return parts
}
-func severityRankInternal(severity vulnerability.Severity) int {
- switch severity {
- case vulnerability.SeverityCritical:
- return 4
- case vulnerability.SeverityHigh:
- return 3
- case vulnerability.SeverityMedium:
- return 2
- case vulnerability.SeverityLow:
- return 1
- case vulnerability.SeverityUnknown:
- return 0
- default:
- return 0
- }
-}
-
// GetScanSummariesByImageIDs retrieves scan summaries for multiple images
func (s *VulnerabilityService) GetScanSummariesByImageIDs(ctx context.Context, imageIDs []string) (map[string]*vulnerability.ScanSummary, error) {
if !s.settingsService.IsFeatureEnabled(ctx, features.VulnerabilityManagement) || s.db == nil || len(imageIDs) == 0 {
@@ -770,7 +754,7 @@ type riskFindingRowInternal struct {
type riskImageAggInternal struct {
image vulnerability.RiskImage
- mean priorityMeanInternal
+ score vuln.RiskScore
}
type riskFindingAggInternal struct {
@@ -779,18 +763,11 @@ type riskFindingAggInternal struct {
runningImages map[string]struct{}
}
-func boolToIntInternal(b bool) int {
- if b {
- return 1
- }
- return 0
-}
-
// riskAccumulatorInternal aggregates scored findings into environment, per-image and per-CVE totals.
type riskAccumulatorInternal struct {
today string
- intelStale bool
scannedImageIDs []string
+ exposures map[string]vulnerability.ImageExposure
overview *vulnerability.RiskOverview
images map[string]*riskImageAggInternal
findings map[string]*riskFindingAggInternal
@@ -799,7 +776,7 @@ type riskAccumulatorInternal struct {
func (a *riskAccumulatorInternal) addInternal(row *riskFindingRowInternal, exposure vulnerability.ImageExposure, runningContainers int) {
severity := vulnerability.Severity(row.Severity)
- base := baseScoreInternal(*cmp.Or(row.CVSSScore, new(0.0)), severity)
+ base := vuln.BaseScore(*cmp.Or(row.CVSSScore, new(0.0)), severity)
fixable := strings.TrimSpace(row.FixedVersion) != ""
summary := &a.overview.Summary
@@ -836,12 +813,21 @@ func (a *riskAccumulatorInternal) addInternal(row *riskFindingRowInternal, expos
a.images[row.ImageID] = img
}
img.image.Findings++
- priority := img.mean.addFindingInternal(row.VulnerabilityID, fixable, base, row.KnownExploited, row.EPSSScore, exposure)
+ priority := img.score.AddFinding(row.VulnerabilityID, fixable, base, vuln.ThreatIntel{KnownExploited: row.KnownExploited, EPSS: row.EPSSScore}, exposure)
risk := priority / 10
- img.image.Critical += boolToIntInternal(severity == vulnerability.SeverityCritical)
- img.image.High += boolToIntInternal(severity == vulnerability.SeverityHigh)
- img.image.KnownExploited += boolToIntInternal(row.KnownExploited)
- img.image.Fixable += boolToIntInternal(fixable)
+ if severity == vulnerability.SeverityCritical {
+ img.image.Critical++
+ }
+ if severity == vulnerability.SeverityHigh {
+ img.image.High++
+ }
+ if row.KnownExploited {
+ img.image.KnownExploited++
+ }
+ if fixable {
+ img.image.Fixable++
+ a.overview.Drivers.Fixable++
+ }
if fixable && base > 0 {
a.considerDriverInternal(row, exposure, priority)
}
@@ -883,14 +869,19 @@ func (a *riskAccumulatorInternal) addInternal(row *riskFindingRowInternal, expos
func (a *riskAccumulatorInternal) considerDriverInternal(row *riskFindingRowInternal, exposure vulnerability.ImageExposure, priority float64) {
current := a.overview.ScoreDriver
if current != nil {
- order := cmp.Or(
- cmp.Compare(priority, a.driverPriority),
- cmp.Compare(boolToIntInternal(row.KnownExploited), boolToIntInternal(current.KnownExploited)),
- strings.Compare(current.VulnerabilityID, row.VulnerabilityID),
- strings.Compare(current.ImageName, row.ImageName),
- )
- if order <= 0 {
- return
+ switch {
+ case priority != a.driverPriority:
+ if priority < a.driverPriority {
+ return
+ }
+ case row.KnownExploited != current.KnownExploited:
+ if !row.KnownExploited {
+ return
+ }
+ default:
+ if cmp.Or(strings.Compare(current.VulnerabilityID, row.VulnerabilityID), strings.Compare(current.ImageName, row.ImageName)) <= 0 {
+ return
+ }
}
}
a.driverPriority = priority
@@ -905,7 +896,7 @@ func (a *riskAccumulatorInternal) considerDriverInternal(row *riskFindingRowInte
}
}
-// finishInternal derives the drivers and averages, and ranks findings and images.
+// finishInternal derives the drivers and scores, and ranks findings and images.
func (a *riskAccumulatorInternal) finishInternal() {
overview := a.overview
overview.Drivers.Findings = overview.Summary.Total
@@ -915,18 +906,33 @@ func (a *riskAccumulatorInternal) finishInternal() {
f := &agg.finding
f.ImagesAffected = len(agg.images)
f.RunningImagesAffected = len(agg.runningImages)
- overview.Drivers.KnownExploited += boolToIntInternal(f.KnownExploited)
- overview.Drivers.OverdueKnownExploited += boolToIntInternal(f.KnownExploited && f.KEVDueDate != "" && f.KEVDueDate < a.today)
- overview.Drivers.HighEPSS += boolToIntInternal(f.EPSS != nil && *f.EPSS >= highEPSSThreshold)
- overview.Drivers.ExposedCriticalHigh += boolToIntInternal(f.RunningImagesAffected > 0 && (f.Severity == vulnerability.SeverityCritical || f.Severity == vulnerability.SeverityHigh))
+ if f.KnownExploited {
+ overview.Drivers.KnownExploited++
+ if f.KEVDueDate != "" && f.KEVDueDate < a.today {
+ overview.Drivers.OverdueKnownExploited++
+ }
+ }
+ if f.EPSS != nil && *f.EPSS >= highEPSSThreshold {
+ overview.Drivers.HighEPSS++
+ }
+ if f.RunningImagesAffected > 0 && (f.Severity == vulnerability.SeverityCritical || f.Severity == vulnerability.SeverityHigh) {
+ overview.Drivers.ExposedCriticalHigh++
+ }
findings = append(findings, agg)
}
byRisk := slices.Clone(findings)
slices.SortFunc(byRisk, func(a, b *riskFindingAggInternal) int {
+ if a.finding.Risk != b.finding.Risk {
+ return cmp.Compare(b.finding.Risk, a.finding.Risk)
+ }
+ if a.finding.KnownExploited != b.finding.KnownExploited {
+ if b.finding.KnownExploited {
+ return 1
+ }
+ return -1
+ }
return cmp.Or(
- cmp.Compare(b.finding.Risk, a.finding.Risk),
- cmp.Compare(boolToIntInternal(b.finding.KnownExploited), boolToIntInternal(a.finding.KnownExploited)),
cmp.Compare(b.finding.RunningImagesAffected, a.finding.RunningImagesAffected),
cmp.Compare(*cmp.Or(b.finding.EPSS, new(0.0)), *cmp.Or(a.finding.EPSS, new(0.0))),
strings.Compare(a.finding.VulnerabilityID, b.finding.VulnerabilityID),
@@ -954,18 +960,18 @@ func (a *riskAccumulatorInternal) finishInternal() {
overview.RiskiestFindings = top(byRisk)
overview.PrevalentFindings = top(byPrevalence)
- // Every scanned image weighs the same; clean images count as zero and unavailable ones leave the denominator.
- var environment priorityMeanInternal
+ // Images average by exposure, clean ones at zero; unavailable images stay out.
+ var environment vuln.RiskScore
overview.RiskiestImages = make([]vulnerability.RiskImage, 0, len(a.images))
for _, id := range a.scannedImageIDs {
img, ok := a.images[id]
if !ok {
- environment.addScoreInternal(id, 0, vulnerability.ScoreStatusComplete)
+ environment.AddImage(id, 0, vulnerability.ScoreStatusComplete, a.exposures[id], false)
continue
}
- mean, priority := img.mean.scoreInternal(a.intelStale)
+ score, priority := img.score.ImageScore()
img.image.PatchPriority = priority
- environment.addScoreInternal(id, mean, priority.ScoreStatus)
+ environment.AddImage(id, score, priority.ScoreStatus, img.image.Exposure, img.score.ExploitedRunning())
overview.RiskiestImages = append(overview.RiskiestImages, img.image)
}
slices.SortFunc(overview.RiskiestImages, func(a, b vulnerability.RiskImage) int {
@@ -978,8 +984,8 @@ func (a *riskAccumulatorInternal) finishInternal() {
})
overview.RiskiestImages = overview.RiskiestImages[:min(len(overview.RiskiestImages), riskiestImageLimit)]
- _, overview.PatchPriority = environment.scoreInternal(false)
- overview.Drivers.ScoredImages = len(environment.scores)
+ _, overview.PatchPriority = environment.EnvironmentScore()
+ overview.Drivers.ScoredImages = environment.Scored()
if overview.Drivers.ScoredImages == 0 {
overview.ScoreStatus = vulnerability.ScoreStatusUnavailable
}
@@ -1020,12 +1026,15 @@ func (s *VulnerabilityService) computeRiskInternal(ctx context.Context, envID st
acc := &riskAccumulatorInternal{
today: s.riskNowInternal().Format(riskDateLayout),
- intelStale: intelStatus.Stale,
scannedImageIDs: scannedIDs,
+ exposures: make(map[string]vulnerability.ImageExposure, len(scannedIDs)),
overview: &vulnerability.RiskOverview{Trend: []vulnerability.RiskTrendPoint{}, ThreatIntel: intelStatus},
images: map[string]*riskImageAggInternal{},
findings: map[string]*riskFindingAggInternal{},
}
+ for _, id := range scannedIDs {
+ acc.exposures[id] = imageExposureInternal(usage, usageOK, id)
+ }
acc.overview.Drivers.ImagesScanned = len(scannedIDs)
acc.overview.Drivers.ImagesTotal = len(scannedIDs)
if imageIDsOK {
@@ -1036,8 +1045,7 @@ func (s *VulnerabilityService) computeRiskInternal(ctx context.Context, envID st
if !intelStatus.Enabled {
row.KnownExploited, row.KEVRansomware, row.KEVDueDate, row.EPSSScore = false, false, "", nil
}
- acc.addInternal(row, imageExposureInternal(usage, usageOK, row.ImageID), usage[row.ImageID].running)
- acc.overview.Drivers.Fixable += boolToIntInternal(strings.TrimSpace(row.FixedVersion) != "")
+ acc.addInternal(row, acc.exposures[row.ImageID], usage[row.ImageID].running)
}
acc.finishInternal()
@@ -1067,7 +1075,7 @@ func (s *VulnerabilityService) GetRiskOverview(ctx context.Context, envID string
today := now.Format(riskDateLayout)
var snapshots []VulnerabilityRiskSnapshot
if err := s.db.WithContext(ctx).
- Where("scoring_version = ?", riskScoringVersion).
+ Where("scoring_version = ?", vuln.ScoringVersion).
Where("snapshot_date >= ?", now.AddDate(0, 0, -(riskTrendDays-1)).Format(riskDateLayout)).
Order("snapshot_date ASC").
Find(&snapshots).Error; err != nil {
diff --git a/backend/internal/vulnerability/vulnerability_store.go b/backend/internal/vulnerability/vulnerability_store.go
index 11ef2f294..0914b3019 100644
--- a/backend/internal/vulnerability/vulnerability_store.go
+++ b/backend/internal/vulnerability/vulnerability_store.go
@@ -9,10 +9,8 @@ import (
"io"
"io/fs"
"log/slog"
- "math"
"net/http"
"os"
- "slices"
"strconv"
"strings"
"time"
@@ -20,12 +18,10 @@ import (
"emperror.dev/errors"
"go.getarcane.app/acfs"
- "golang.org/x/mod/semver"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/vuln"
- "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/dbutil"
"github.com/getarcaneapp/arcane/types/v2"
"github.com/getarcaneapp/arcane/types/v2/features"
@@ -106,12 +102,12 @@ func buildScanItemsInternal(imageID string, vulns []vulnerability.Vulnerability)
InstalledVersion: v.InstalledVersion,
FixedVersion: v.FixedVersion,
Severity: string(v.Severity),
- SeverityRank: severityRankInternal(v.Severity),
+ SeverityRank: vuln.SeverityRank(v.Severity),
PkgClass: v.Class,
PkgType: v.Type,
Title: v.Title,
}
- if score := rawCVSSInternal(v.CVSS); score > 0 {
+ if score := vuln.CVSSScore(v.CVSS); score > 0 {
item.CVSSScore = new(score)
}
if v.Description != "" || len(v.References) > 0 || v.CVSS != nil || v.PublishedDate != nil || v.LastModifiedDate != nil {
@@ -509,240 +505,7 @@ func (s *VulnerabilityService) ensureSummary(result *vulnerability.ScanResult) {
return
}
- result.Summary = buildSeveritySummaryFromVulnerabilitiesInternal(result.Vulnerabilities)
-}
-
-func buildSeveritySummaryFromVulnerabilitiesInternal(vulns []vulnerability.Vulnerability) *vulnerability.SeveritySummary {
- summary := &vulnerability.SeveritySummary{}
- for _, vulnEntry := range vulns {
- switch vulnEntry.Severity {
- case vulnerability.SeverityCritical:
- summary.Critical++
- case vulnerability.SeverityHigh:
- summary.High++
- case vulnerability.SeverityMedium:
- summary.Medium++
- case vulnerability.SeverityLow:
- summary.Low++
- case vulnerability.SeverityUnknown:
- summary.Unknown++
- default:
- summary.Unknown++
- }
- summary.Total++
- }
- return summary
-}
-
-const (
- topPackageInsightLimit = 5
- threatFactorNoData = 0.5
- usageFactorStopped = 0.8
- usageFactorUnused = 0.5
- // riskScoringVersion tags snapshots; trends only read the current formula.
- riskScoringVersion = 2
-)
-
-// rawCVSSInternal returns the CVSS v3 score, else v2, else 0.
-func rawCVSSInternal(cvss *vulnerability.CVSSInfo) float64 {
- if cvss == nil {
- return 0
- }
- if cvss.V3Score > 0 {
- return cvss.V3Score
- }
- return cvss.V2Score
-}
-
-// baseScoreInternal returns the CVSS score, falling back to a severity midpoint when unscored.
-func baseScoreInternal(cvss float64, severity vulnerability.Severity) float64 {
- if cvss > 0 {
- return cvss
- }
- switch severity {
- case vulnerability.SeverityCritical:
- return 9.5
- case vulnerability.SeverityHigh:
- return 8
- case vulnerability.SeverityMedium:
- return 5.5
- case vulnerability.SeverityLow:
- return 2.5
- case vulnerability.SeverityUnknown:
- return 0
- default:
- return 0
- }
-}
-
-// findingPriorityInternal maps a 0-10 severity onto a 0-100 patch priority using exploitation evidence and container usage.
-// provisional reports that threat data was missing or usage was unknown.
-func findingPriorityInternal(base float64, knownExploited bool, epss *float64, exposure vulnerability.ImageExposure) (priority float64, provisional bool) {
- threat := threatFactorNoData
- switch {
- case knownExploited:
- threat = 1
- case epss != nil:
- threat = 0.5 + 0.5*math.Sqrt(*epss)
- default:
- provisional = true
- }
- usage := 1.0
- switch exposure {
- case vulnerability.ImageExposureStopped:
- usage = usageFactorStopped
- case vulnerability.ImageExposureUnused:
- usage = usageFactorUnused
- case vulnerability.ImageExposureUnknown:
- provisional = true
- case vulnerability.ImageExposureRunning:
- }
- return min(100, 10*base*threat*usage), provisional
-}
-
-// priorityMeanInternal averages member scores keyed by ID: distinct fixable findings for an image, scanned images for an environment.
-type priorityMeanInternal struct {
- scores map[string]float64
- unscored map[string]struct{}
- provisional bool
-}
-
-// addFindingInternal scores one finding occurrence, records it when fixable, and returns its 0-100 priority.
-func (p *priorityMeanInternal) addFindingInternal(vulnerabilityID string, fixable bool, base float64, knownExploited bool, epss *float64, exposure vulnerability.ImageExposure) float64 {
- priority, provisional := findingPriorityInternal(base, knownExploited, epss, exposure)
- if !fixable {
- return priority
- }
- status := vulnerability.ScoreStatusComplete
- switch {
- case base <= 0:
- status = vulnerability.ScoreStatusUnavailable
- case provisional:
- status = vulnerability.ScoreStatusProvisional
- }
- p.addScoreInternal(vulnerabilityID, priority, status)
- return priority
-}
-
-// addScoreInternal records a member's score; the highest score per ID wins and unavailable members stay out of the denominator.
-func (p *priorityMeanInternal) addScoreInternal(id string, score float64, status vulnerability.ScoreStatus) {
- if p.scores == nil {
- p.scores, p.unscored = map[string]float64{}, map[string]struct{}{}
- }
- if status == vulnerability.ScoreStatusUnavailable {
- if _, ok := p.scores[id]; !ok {
- p.unscored[id] = struct{}{}
- }
- return
- }
- delete(p.unscored, id)
- if current, ok := p.scores[id]; !ok || score > current {
- p.scores[id] = score
- }
- p.provisional = p.provisional || status == vulnerability.ScoreStatusProvisional
-}
-
-// scoreInternal returns the unrounded 0-100 mean and the rounded API score; only unscorable members make it unavailable.
-func (p *priorityMeanInternal) scoreInternal(intelStale bool) (float64, vulnerability.PatchPriority) {
- sum := 0.0
- for _, score := range p.scores {
- sum += score
- }
- mean := 0.0
- if len(p.scores) > 0 {
- mean = sum / float64(len(p.scores))
- }
- result := vulnerability.PatchPriority{RiskScore: int(math.Round(mean)), ScoreStatus: vulnerability.ScoreStatusComplete}
- result.RiskBand = riskBandInternal(result.RiskScore)
- switch {
- case len(p.scores) == 0 && len(p.unscored) > 0:
- result.ScoreStatus = vulnerability.ScoreStatusUnavailable
- case len(p.scores) > 0 && (p.provisional || intelStale || len(p.unscored) > 0):
- result.ScoreStatus = vulnerability.ScoreStatusProvisional
- }
- return mean, result
-}
-
-func riskBandInternal(score int) vulnerability.RiskBand {
- switch {
- case score >= 90:
- return vulnerability.RiskBandCritical
- case score >= 70:
- return vulnerability.RiskBandHigh
- case score >= 40:
- return vulnerability.RiskBandMedium
- case score > 0:
- return vulnerability.RiskBandLow
- default:
- return vulnerability.RiskBandNone
- }
-}
-
-// isNewerFixedVersionInternal reports whether candidate supersedes current; non-semver fixes keep the first (most severe) one.
-func isNewerFixedVersionInternal(candidate, current string) bool {
- if current == "" {
- return true
- }
- a, b := utils.EnsureVPrefix(candidate), utils.EnsureVPrefix(current)
- return semver.IsValid(a) && semver.IsValid(b) && semver.Compare(a, b) > 0
-}
-
-// buildScanInsightsInternal scores an image's findings using threat intel (keyed by CVE) and the image's exposure.
-func buildScanInsightsInternal(vulns []vulnerability.Vulnerability, intel map[string]VulnerabilityThreatIntel, exposure vulnerability.ImageExposure, intelStale bool) *vulnerability.ScanInsights {
- sorted := slices.Clone(vulns)
- slices.SortStableFunc(sorted, func(a, b vulnerability.Vulnerability) int {
- return severityRankInternal(b.Severity) - severityRankInternal(a.Severity)
- })
-
- insights := &vulnerability.ScanInsights{Exposure: exposure, TopPackages: []vulnerability.PackageInsight{}}
- var mean priorityMeanInternal
- packages := map[string]*vulnerability.PackageInsight{}
- var packageOrder []string
-
- for _, v := range sorted {
- base := baseScoreInternal(rawCVSSInternal(v.CVSS), v.Severity)
- if insights.HighestVulnerabilityID == "" || base > insights.HighestCVSS {
- insights.HighestCVSS = base
- insights.HighestVulnerabilityID = v.VulnerabilityID
- }
- threat := intel[v.VulnerabilityID]
- if threat.KnownExploited {
- insights.KnownExploitedCount++
- }
- fixedVersion := strings.TrimSpace(v.FixedVersion)
- if fixedVersion != "" {
- insights.FixableCount++
- }
- mean.addFindingInternal(v.VulnerabilityID, fixedVersion != "", base, threat.KnownExploited, threat.EPSSScore, exposure)
-
- pkg, ok := packages[v.PkgName]
- if !ok {
- pkg = &vulnerability.PackageInsight{PkgName: v.PkgName, Severity: v.Severity, InstalledVersion: v.InstalledVersion}
- packages[v.PkgName] = pkg
- packageOrder = append(packageOrder, v.PkgName)
- }
- pkg.Count++
- if fixedVersion != "" && isNewerFixedVersionInternal(fixedVersion, pkg.FixedVersion) {
- pkg.FixedVersion = fixedVersion
- }
- }
-
- _, insights.PatchPriority = mean.scoreInternal(intelStale)
-
- for _, name := range packageOrder {
- insights.TopPackages = append(insights.TopPackages, *packages[name])
- }
- slices.SortStableFunc(insights.TopPackages, func(a, b vulnerability.PackageInsight) int {
- if rank := severityRankInternal(b.Severity) - severityRankInternal(a.Severity); rank != 0 {
- return rank
- }
- return b.Count - a.Count
- })
- if len(insights.TopPackages) > topPackageInsightLimit {
- insights.TopPackages = insights.TopPackages[:topPackageInsightLimit]
- }
-
- return insights
+ result.Summary = vuln.SeveritySummary(result.Vulnerabilities)
}
const (
@@ -1022,7 +785,7 @@ func (s *VulnerabilityService) RecordRiskSnapshot(ctx context.Context) error {
now := s.riskNowInternal()
snapshot := VulnerabilityRiskSnapshot{
SnapshotDate: now.Format(riskDateLayout),
- ScoringVersion: riskScoringVersion,
+ ScoringVersion: vuln.ScoringVersion,
RiskScore: overview.RiskScore,
RiskBand: string(overview.RiskBand),
CriticalCount: overview.Summary.Critical,
diff --git a/backend/pkg/libarcane/vuln/risk.go b/backend/pkg/libarcane/vuln/risk.go
new file mode 100644
index 000000000..c016d2b49
--- /dev/null
+++ b/backend/pkg/libarcane/vuln/risk.go
@@ -0,0 +1,335 @@
+package vuln
+
+import (
+ "maps"
+ "math"
+ "slices"
+ "strings"
+
+ "golang.org/x/mod/semver"
+
+ "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
+ "github.com/getarcaneapp/arcane/types/v2/vulnerability"
+)
+
+const (
+ // ScoringVersion tags risk snapshots; trends only read the current formula.
+ ScoringVersion = 3
+ // TopPackageInsightLimit caps the packages listed in scan insights.
+ TopPackageInsightLimit = 5
+
+ threatFactorNoDataInternal = 0.7
+ usageFactorStoppedInternal = 0.8
+ usageFactorUnusedInternal = 0.5
+ // concentrationPenaltyInternal is the most the fixable finding count adds to an image; it saturates over concentrationScaleInternal findings.
+ concentrationPenaltyInternal = 8
+ concentrationScaleInternal = 40
+ // exposureWeight*Internal set how much a scanned image counts in the environment average; unused and unknown images count once.
+ exposureWeightRunningInternal = 3
+ exposureWeightStoppedInternal = 2
+ // exploitedRunningFloorInternal is the lowest environment score while a fixable known-exploited finding is running.
+ exploitedRunningFloorInternal = 70
+)
+
+// rankWeightsInternal is the share of each of an image's worst fixable findings that enters its score, worst first.
+var rankWeightsInternal = [...]float64{0.70, 0.15, 0.05, 0.02}
+
+// ThreatIntel is the exploitation evidence known for one CVE.
+type ThreatIntel struct {
+ KnownExploited bool
+ EPSS *float64
+}
+
+// CVSSScore returns the CVSS v3 score, else v2, else 0.
+func CVSSScore(cvss *vulnerability.CVSSInfo) float64 {
+ if cvss == nil {
+ return 0
+ }
+ if cvss.V3Score > 0 {
+ return cvss.V3Score
+ }
+ return cvss.V2Score
+}
+
+// BaseScore returns the CVSS score, falling back to a severity midpoint when unscored.
+func BaseScore(cvss float64, severity vulnerability.Severity) float64 {
+ if cvss > 0 {
+ return cvss
+ }
+ switch severity {
+ case vulnerability.SeverityCritical:
+ return 9.5
+ case vulnerability.SeverityHigh:
+ return 8
+ case vulnerability.SeverityMedium:
+ return 5.5
+ case vulnerability.SeverityLow:
+ return 2.5
+ case vulnerability.SeverityUnknown:
+ return 0
+ default:
+ return 0
+ }
+}
+
+// SeverityRank orders severities from unknown (0) to critical (4).
+func SeverityRank(severity vulnerability.Severity) int {
+ switch severity {
+ case vulnerability.SeverityCritical:
+ return 4
+ case vulnerability.SeverityHigh:
+ return 3
+ case vulnerability.SeverityMedium:
+ return 2
+ case vulnerability.SeverityLow:
+ return 1
+ case vulnerability.SeverityUnknown:
+ return 0
+ default:
+ return 0
+ }
+}
+
+// SeveritySummary counts findings per severity.
+func SeveritySummary(vulns []vulnerability.Vulnerability) *vulnerability.SeveritySummary {
+ summary := &vulnerability.SeveritySummary{}
+ for _, v := range vulns {
+ switch v.Severity {
+ case vulnerability.SeverityCritical:
+ summary.Critical++
+ case vulnerability.SeverityHigh:
+ summary.High++
+ case vulnerability.SeverityMedium:
+ summary.Medium++
+ case vulnerability.SeverityLow:
+ summary.Low++
+ case vulnerability.SeverityUnknown:
+ summary.Unknown++
+ default:
+ summary.Unknown++
+ }
+ summary.Total++
+ }
+ return summary
+}
+
+// IsCVE reports whether an advisory ID can carry KEV/EPSS data; GHSA, DLA, DSA and similar IDs never do.
+func IsCVE(vulnerabilityID string) bool {
+ return strings.HasPrefix(strings.ToUpper(vulnerabilityID), "CVE-")
+}
+
+// FindingPriority maps a 0-10 severity onto a 0-100 patch priority using exploitation evidence and container usage.
+// A known-exploited finding takes the maximum rating regardless of CVSS, as RS³ does for threats seen in the wild.
+func FindingPriority(base float64, intel ThreatIntel, exposure vulnerability.ImageExposure) float64 {
+ threat := threatFactorNoDataInternal
+ switch {
+ case intel.KnownExploited:
+ base, threat = 10, 1
+ case intel.EPSS != nil:
+ threat = threatFactorNoDataInternal + (1-threatFactorNoDataInternal)*math.Sqrt(*intel.EPSS)
+ }
+ usage := 1.0
+ switch exposure {
+ case vulnerability.ImageExposureStopped:
+ usage = usageFactorStoppedInternal
+ case vulnerability.ImageExposureUnused:
+ usage = usageFactorUnusedInternal
+ case vulnerability.ImageExposureRunning, vulnerability.ImageExposureUnknown:
+ }
+ return min(100, 10*base*threat*usage)
+}
+
+// RiskScore collects scored members keyed by ID: distinct fixable findings for an image, scanned images for an environment.
+type RiskScore struct {
+ scores map[string]float64
+ weights map[string]float64
+ unscored map[string]struct{}
+ // exploitedRunning records a fixable known-exploited finding on a running (or unknown) image.
+ exploitedRunning bool
+}
+
+// AddFinding scores one finding occurrence, records it when fixable, and returns its 0-100 priority.
+// An unrated non-CVE advisory is left out entirely: it has no CVSS to score and no rating to wait for.
+func (r *RiskScore) AddFinding(vulnerabilityID string, fixable bool, base float64, intel ThreatIntel, exposure vulnerability.ImageExposure) float64 {
+ priority := FindingPriority(base, intel, exposure)
+ if !fixable || (priority <= 0 && !IsCVE(vulnerabilityID)) {
+ return priority
+ }
+ status := vulnerability.ScoreStatusComplete
+ if priority <= 0 {
+ status = vulnerability.ScoreStatusUnavailable
+ }
+ r.addScoreInternal(vulnerabilityID, priority, 1, status)
+ if intel.KnownExploited && (exposure == vulnerability.ImageExposureRunning || exposure == vulnerability.ImageExposureUnknown) {
+ r.exploitedRunning = true
+ }
+ return priority
+}
+
+// AddImage records a scanned image's score for the environment, weighted by how exposed the image is.
+func (r *RiskScore) AddImage(imageID string, score float64, status vulnerability.ScoreStatus, exposure vulnerability.ImageExposure, exploitedRunning bool) {
+ weight := 1.0
+ switch exposure {
+ case vulnerability.ImageExposureRunning:
+ weight = exposureWeightRunningInternal
+ case vulnerability.ImageExposureStopped:
+ weight = exposureWeightStoppedInternal
+ case vulnerability.ImageExposureUnused, vulnerability.ImageExposureUnknown:
+ }
+ r.addScoreInternal(imageID, score, weight, status)
+ r.exploitedRunning = r.exploitedRunning || exploitedRunning
+}
+
+// addScoreInternal records a member's score; the highest score per ID wins and unavailable members stay out of the total.
+func (r *RiskScore) addScoreInternal(id string, score, weight float64, status vulnerability.ScoreStatus) {
+ if r.scores == nil {
+ r.scores, r.weights, r.unscored = map[string]float64{}, map[string]float64{}, map[string]struct{}{}
+ }
+ if status == vulnerability.ScoreStatusUnavailable {
+ if _, ok := r.scores[id]; !ok {
+ r.unscored[id] = struct{}{}
+ }
+ return
+ }
+ delete(r.unscored, id)
+ if current, ok := r.scores[id]; !ok || score > current {
+ r.scores[id] = score
+ }
+ r.weights[id] = weight
+}
+
+// Scored returns how many members entered the score.
+func (r *RiskScore) Scored() int {
+ return len(r.scores)
+}
+
+// ExploitedRunning reports whether a fixable known-exploited finding was recorded on a running image.
+func (r *RiskScore) ExploitedRunning() bool {
+ return r.exploitedRunning
+}
+
+// ImageScore returns an image's unrounded 0-100 score and the rounded API score.
+// Modeled on the RS³ security risk: the worst findings count with shrinking weights and the fixable count adds a little on top.
+func (r *RiskScore) ImageScore() (float64, vulnerability.PatchPriority) {
+ values := slices.Sorted(maps.Values(r.scores))
+ slices.Reverse(values)
+ total := 0.0
+ for i, score := range values[:min(len(values), len(rankWeightsInternal))] {
+ total += rankWeightsInternal[i] * score
+ }
+ if len(values) > 0 {
+ total += concentrationPenaltyInternal * (1 - math.Exp(-float64(len(values))/concentrationScaleInternal))
+ }
+ return total, r.resultInternal(total)
+}
+
+// EnvironmentScore returns the environment's unrounded 0-100 score and the rounded API score.
+// Modeled on the overall RS³: an exposure-weighted average of image scores that stays in the High band while a fixable known-exploited finding is running.
+func (r *RiskScore) EnvironmentScore() (float64, vulnerability.PatchPriority) {
+ sum, weight := 0.0, 0.0
+ for id, score := range r.scores {
+ sum += score * r.weights[id]
+ weight += r.weights[id]
+ }
+ total := 0.0
+ if weight > 0 {
+ total = sum / weight
+ }
+ if r.exploitedRunning {
+ total = max(total, exploitedRunningFloorInternal)
+ }
+ return total, r.resultInternal(total)
+}
+
+// resultInternal rounds a score into the API shape; only unscorable members make it unavailable.
+func (r *RiskScore) resultInternal(total float64) vulnerability.PatchPriority {
+ result := vulnerability.PatchPriority{RiskScore: int(math.Round(total)), ScoreStatus: vulnerability.ScoreStatusComplete}
+ result.RiskBand = RiskBand(result.RiskScore)
+ if len(r.scores) == 0 && len(r.unscored) > 0 {
+ result.ScoreStatus = vulnerability.ScoreStatusUnavailable
+ }
+ return result
+}
+
+// RiskBand labels a 0-100 score.
+func RiskBand(score int) vulnerability.RiskBand {
+ switch {
+ case score >= 90:
+ return vulnerability.RiskBandCritical
+ case score >= 70:
+ return vulnerability.RiskBandHigh
+ case score >= 40:
+ return vulnerability.RiskBandMedium
+ case score > 0:
+ return vulnerability.RiskBandLow
+ default:
+ return vulnerability.RiskBandNone
+ }
+}
+
+// isNewerFixedVersionInternal reports whether candidate supersedes current; non-semver fixes keep the first (most severe) one.
+func isNewerFixedVersionInternal(candidate, current string) bool {
+ if current == "" {
+ return true
+ }
+ a, b := utils.EnsureVPrefix(candidate), utils.EnsureVPrefix(current)
+ return semver.IsValid(a) && semver.IsValid(b) && semver.Compare(a, b) > 0
+}
+
+// BuildScanInsights scores an image's findings using threat intel (keyed by CVE) and the image's exposure.
+func BuildScanInsights(vulns []vulnerability.Vulnerability, intel map[string]ThreatIntel, exposure vulnerability.ImageExposure) *vulnerability.ScanInsights {
+ sorted := slices.Clone(vulns)
+ slices.SortStableFunc(sorted, func(a, b vulnerability.Vulnerability) int {
+ return SeverityRank(b.Severity) - SeverityRank(a.Severity)
+ })
+
+ insights := &vulnerability.ScanInsights{Exposure: exposure, TopPackages: []vulnerability.PackageInsight{}}
+ var score RiskScore
+ packages := map[string]*vulnerability.PackageInsight{}
+ var packageOrder []string
+
+ for _, v := range sorted {
+ base := BaseScore(CVSSScore(v.CVSS), v.Severity)
+ if insights.HighestVulnerabilityID == "" || base > insights.HighestCVSS {
+ insights.HighestCVSS = base
+ insights.HighestVulnerabilityID = v.VulnerabilityID
+ }
+ threat := intel[v.VulnerabilityID]
+ if threat.KnownExploited {
+ insights.KnownExploitedCount++
+ }
+ fixedVersion := strings.TrimSpace(v.FixedVersion)
+ if fixedVersion != "" {
+ insights.FixableCount++
+ }
+ score.AddFinding(v.VulnerabilityID, fixedVersion != "", base, threat, exposure)
+
+ pkg, ok := packages[v.PkgName]
+ if !ok {
+ pkg = &vulnerability.PackageInsight{PkgName: v.PkgName, Severity: v.Severity, InstalledVersion: v.InstalledVersion}
+ packages[v.PkgName] = pkg
+ packageOrder = append(packageOrder, v.PkgName)
+ }
+ pkg.Count++
+ if fixedVersion != "" && isNewerFixedVersionInternal(fixedVersion, pkg.FixedVersion) {
+ pkg.FixedVersion = fixedVersion
+ }
+ }
+
+ _, insights.PatchPriority = score.ImageScore()
+
+ for _, name := range packageOrder {
+ insights.TopPackages = append(insights.TopPackages, *packages[name])
+ }
+ slices.SortStableFunc(insights.TopPackages, func(a, b vulnerability.PackageInsight) int {
+ if rank := SeverityRank(b.Severity) - SeverityRank(a.Severity); rank != 0 {
+ return rank
+ }
+ return b.Count - a.Count
+ })
+ if len(insights.TopPackages) > TopPackageInsightLimit {
+ insights.TopPackages = insights.TopPackages[:TopPackageInsightLimit]
+ }
+
+ return insights
+}
diff --git a/backend/pkg/libarcane/vuln/risk_test.go b/backend/pkg/libarcane/vuln/risk_test.go
new file mode 100644
index 000000000..e8ccead43
--- /dev/null
+++ b/backend/pkg/libarcane/vuln/risk_test.go
@@ -0,0 +1,182 @@
+package vuln
+
+import (
+ "fmt"
+ "math"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/getarcaneapp/arcane/types/v2/vulnerability"
+)
+
+func TestBuildScanInsights(t *testing.T) {
+ vulns := []vulnerability.Vulnerability{
+ {VulnerabilityID: "CVE-LOW", PkgName: "zlib", InstalledVersion: "1.0.0", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 3}},
+ {VulnerabilityID: "CVE-HIGH-1", PkgName: "openssl", InstalledVersion: "3.0.0", FixedVersion: "3.0.2", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 7.5}},
+ {VulnerabilityID: "CVE-HIGH-2", PkgName: "openssl", InstalledVersion: "3.0.0", FixedVersion: "3.0.10", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V2Score: 7.8}},
+ {VulnerabilityID: "CVE-MED", PkgName: "curl", InstalledVersion: "8.0.0", Severity: vulnerability.SeverityMedium},
+ }
+
+ insights := BuildScanInsights(vulns, nil, vulnerability.ImageExposureUnknown)
+
+ require.Equal(t, "CVE-HIGH-2", insights.HighestVulnerabilityID)
+ require.InDelta(t, 7.8, insights.HighestCVSS, 0.001)
+ require.Equal(t, 2, insights.FixableCount)
+ // Only the two fixable findings count: 0.7 x 54.6 + 0.15 x 52.5 plus a sliver for volume, with no threat data and unknown usage.
+ require.Equal(t, 46, insights.RiskScore)
+ require.Equal(t, vulnerability.RiskBandMedium, insights.RiskBand)
+ require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
+
+ require.Len(t, insights.TopPackages, 3)
+ require.Equal(t, vulnerability.PackageInsight{PkgName: "openssl", Severity: vulnerability.SeverityHigh, Count: 2, InstalledVersion: "3.0.0", FixedVersion: "3.0.10"}, insights.TopPackages[0])
+ require.Equal(t, "curl", insights.TopPackages[1].PkgName)
+ require.Equal(t, "zlib", insights.TopPackages[2].PkgName)
+}
+
+func TestBuildScanInsights_VolumeSaturatesWithDiminishingReturns(t *testing.T) {
+ build := func(n int, severity vulnerability.Severity, cvss float64, knownExploited bool) ([]vulnerability.Vulnerability, map[string]ThreatIntel) {
+ vulns := make([]vulnerability.Vulnerability, 0, n)
+ intel := map[string]ThreatIntel{}
+ for i := range n {
+ id := fmt.Sprintf("CVE-%d", i)
+ vulns = append(vulns, vulnerability.Vulnerability{VulnerabilityID: id, PkgName: fmt.Sprintf("pkg-%d", i), FixedVersion: "1.0.1", Severity: severity, CVSS: &vulnerability.CVSSInfo{V3Score: cvss}})
+ intel[id] = ThreatIntel{KnownExploited: knownExploited, EPSS: new(0.0)}
+ }
+ return vulns, intel
+ }
+
+ oneVulns, oneIntel := build(1, vulnerability.SeverityCritical, 9.8, true)
+ manyVulns, manyIntel := build(8, vulnerability.SeverityCritical, 9.8, true)
+ lowVulns, lowIntel := build(8, vulnerability.SeverityLow, 3, false)
+ one := BuildScanInsights(oneVulns, oneIntel, vulnerability.ImageExposureRunning)
+ many := BuildScanInsights(manyVulns, manyIntel, vulnerability.ImageExposureRunning)
+ lows := BuildScanInsights(lowVulns, lowIntel, vulnerability.ImageExposureRunning)
+ // One running KEV lands at the High floor; seven more add their shrinking shares and volume, and eight lows stay Low.
+ require.Equal(t, 70, one.RiskScore)
+ require.Equal(t, vulnerability.RiskBandHigh, one.RiskBand)
+ require.Equal(t, 93, many.RiskScore)
+ require.Equal(t, vulnerability.RiskBandCritical, many.RiskBand)
+ require.Equal(t, 21, lows.RiskScore)
+ require.Equal(t, vulnerability.RiskBandLow, lows.RiskBand)
+ require.Equal(t, vulnerability.ScoreStatusComplete, many.ScoreStatus)
+ require.Len(t, many.TopPackages, TopPackageInsightLimit)
+}
+
+func TestBuildScanInsights_NoFixableFindings(t *testing.T) {
+ vulns := []vulnerability.Vulnerability{
+ {VulnerabilityID: "CVE-KEV", PkgName: "openssl", Severity: vulnerability.SeverityCritical, CVSS: &vulnerability.CVSSInfo{V3Score: 9.8}},
+ }
+ intel := map[string]ThreatIntel{"CVE-KEV": {KnownExploited: true}}
+
+ insights := BuildScanInsights(vulns, intel, vulnerability.ImageExposureRunning)
+
+ // An unfixable KEV stays visible but does not set a patch priority.
+ require.Equal(t, 1, insights.KnownExploitedCount)
+ require.Zero(t, insights.RiskScore)
+ require.Equal(t, vulnerability.RiskBandNone, insights.RiskBand)
+ require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
+}
+
+func TestBuildScanInsights_DeduplicatesFixableFindings(t *testing.T) {
+ vulns := []vulnerability.Vulnerability{
+ {VulnerabilityID: "CVE-DUP", PkgName: "libssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
+ {VulnerabilityID: "CVE-DUP", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
+ {VulnerabilityID: "CVE-DUP", PkgName: "openssl-dev", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 8}},
+ {VulnerabilityID: "CVE-LOW", PkgName: "zlib", FixedVersion: "1.3", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 2}},
+ }
+ intel := map[string]ThreatIntel{
+ "CVE-DUP": {EPSS: new(0.0)},
+ "CVE-LOW": {EPSS: new(0.0)},
+ }
+
+ insights := BuildScanInsights(vulns, intel, vulnerability.ImageExposureRunning)
+
+ // CVE-DUP counts once at 56 and CVE-LOW at 14 takes the second rank: the three package rows do not stack.
+ require.Equal(t, 42, insights.RiskScore)
+ require.Equal(t, 3, insights.FixableCount)
+ require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
+}
+
+func TestBuildScanInsights_UnknownSeverity(t *testing.T) {
+ unscored := []vulnerability.Vulnerability{
+ {VulnerabilityID: "CVE-UNK", PkgName: "foo", FixedVersion: "2.0", Severity: vulnerability.SeverityUnknown},
+ }
+ insights := BuildScanInsights(unscored, nil, vulnerability.ImageExposureRunning)
+ require.Equal(t, vulnerability.ScoreStatusUnavailable, insights.ScoreStatus)
+ require.Zero(t, insights.RiskScore)
+
+ mixed := append(unscored, vulnerability.Vulnerability{VulnerabilityID: "CVE-KEV", PkgName: "bar", FixedVersion: "1.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}})
+ intel := map[string]ThreatIntel{"CVE-KEV": {KnownExploited: true}}
+ insights = BuildScanInsights(mixed, intel, vulnerability.ImageExposureRunning)
+ // The unscored finding is left out of the score.
+ require.Equal(t, 70, insights.RiskScore)
+ require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
+}
+
+func TestBuildScanInsights_NonCVEAdvisories(t *testing.T) {
+ vulns := []vulnerability.Vulnerability{
+ {VulnerabilityID: "GHSA-xxxx-yyyy-zzzz", PkgName: "lodash", FixedVersion: "4.17.21", Severity: vulnerability.SeverityHigh, CVSS: &vulnerability.CVSSInfo{V3Score: 7.5}},
+ {VulnerabilityID: "DLA-2424-1", PkgName: "tzdata", FixedVersion: "2020d-0+deb9u1", Severity: vulnerability.SeverityUnknown},
+ {VulnerabilityID: "CVE-KEV", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}},
+ }
+ intel := map[string]ThreatIntel{"CVE-KEV": {KnownExploited: true}}
+
+ insights := BuildScanInsights(vulns, intel, vulnerability.ImageExposureRunning)
+
+ // KEV and EPSS never cover GHSA/DLA IDs: the GHSA scores with the no-data factor and the unrated DLA is skipped.
+ require.Equal(t, 3, insights.FixableCount)
+ require.Equal(t, 78, insights.RiskScore)
+ require.Equal(t, vulnerability.ScoreStatusComplete, insights.ScoreStatus)
+
+ unrated := BuildScanInsights(vulns[1:2], nil, vulnerability.ImageExposureRunning)
+ require.Zero(t, unrated.RiskScore)
+ require.Equal(t, vulnerability.ScoreStatusComplete, unrated.ScoreStatus)
+}
+
+func TestFindingPriority(t *testing.T) {
+ zeroEPSS, lowEPSS, highEPSS := 0.0, 0.01, 0.97
+ tests := []struct {
+ name string
+ base float64
+ knownExploited bool
+ epss *float64
+ exposure vulnerability.ImageExposure
+ want float64
+ }{
+ {name: "no intel running", base: 7.5, exposure: vulnerability.ImageExposureRunning, want: 52.5},
+ {name: "epss zero", base: 7.5, epss: &zeroEPSS, exposure: vulnerability.ImageExposureRunning, want: 52.5},
+ {name: "unknown exposure counts as running", base: 7.5, epss: &zeroEPSS, exposure: vulnerability.ImageExposureUnknown, want: 52.5},
+ {name: "known exploited takes the maximum", base: 6, knownExploited: true, exposure: vulnerability.ImageExposureRunning, want: 100},
+ {name: "low epss", base: 7.5, epss: &lowEPSS, exposure: vulnerability.ImageExposureRunning, want: 54.75},
+ {name: "high epss", base: 6, epss: &highEPSS, exposure: vulnerability.ImageExposureRunning, want: 60 * (0.7 + 0.3*math.Sqrt(0.97))},
+ {name: "stopped", base: 5, knownExploited: true, exposure: vulnerability.ImageExposureStopped, want: 80},
+ {name: "unused", base: 9.8, knownExploited: true, exposure: vulnerability.ImageExposureUnused, want: 50},
+ {name: "maximum", base: 10, knownExploited: true, exposure: vulnerability.ImageExposureRunning, want: 100},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ require.InDelta(t, tt.want, FindingPriority(tt.base, ThreatIntel{KnownExploited: tt.knownExploited, EPSS: tt.epss}, tt.exposure), 0.001)
+ })
+ }
+}
+
+func TestBuildScanInsights_ThreatIntelAndExposure(t *testing.T) {
+ vulns := []vulnerability.Vulnerability{
+ {VulnerabilityID: "CVE-KEV", PkgName: "openssl", FixedVersion: "3.0.1", Severity: vulnerability.SeverityMedium, CVSS: &vulnerability.CVSSInfo{V3Score: 6}},
+ {VulnerabilityID: "CVE-OTHER", PkgName: "zlib", FixedVersion: "1.3", Severity: vulnerability.SeverityLow, CVSS: &vulnerability.CVSSInfo{V3Score: 3}},
+ }
+ intel := map[string]ThreatIntel{"CVE-KEV": {KnownExploited: true}}
+
+ running := BuildScanInsights(vulns, intel, vulnerability.ImageExposureRunning)
+ require.Equal(t, 1, running.KnownExploitedCount)
+ require.Equal(t, vulnerability.ImageExposureRunning, running.Exposure)
+ require.InDelta(t, 6.0, running.HighestCVSS, 0.001)
+ // The KEV counts at 100 and CVE-OTHER, with no threat data, at 21 takes the second rank.
+ require.Equal(t, 74, running.RiskScore)
+ require.Equal(t, vulnerability.ScoreStatusComplete, running.ScoreStatus)
+
+ unused := BuildScanInsights(vulns, intel, vulnerability.ImageExposureUnused)
+ require.Equal(t, 37, unused.RiskScore)
+ require.Less(t, unused.RiskScore, running.RiskScore)
+}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 0e36ea27c..e65512e5b 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -993,13 +993,10 @@
"vuln_risk_band_medium": "Medium priority",
"vuln_risk_band_high": "High priority",
"vuln_risk_band_critical": "Critical priority",
- "vuln_risk_score_help": "Average priority of this image's fixable findings, from 0 to 100. Each finding's severity is weighted by known exploitation, exploit probability and container usage. Findings without a fix stay listed but do not enter the average.",
+ "vuln_risk_score_help": "Patch priority of this image's fixable findings, from 0 to 100. Each finding's severity is weighted by exploit probability and container usage, and a known-exploited finding takes the maximum priority. The worst finding sets most of the score, the next three worst add shrinking shares, and the number of fixable findings adds a little on top. Findings without a fix stay listed but do not count.",
"vuln_priority_none": "No fixable findings",
"vuln_priority_unavailable": "Priority unavailable",
"vuln_score_denominator": "/100",
- "vuln_score_provisional": "Provisional",
- "vuln_score_provisional_title": "Provisional score",
- "vuln_score_provisional_help": "Threat data or container usage is missing or out of date. The score may change once it is available.",
"vuln_highest_cvss": "Highest CVSS",
"vuln_cvss": "CVSS",
"vuln_top_packages": "Top packages to update",
@@ -1026,9 +1023,7 @@
"security_driver_overdue_kev_help": "Known exploited CVEs past the remediation due date set by CISA.",
"security_driver_unavailable": "Unavailable until threat data has synced",
"security_score_driver": "Highest-priority fix: {cve} in {image}",
- "security_patch_priority_help": "Average patch priority of fixable findings across scanned images, from 0 to 100. Every scanned image counts equally and images with no fixable findings count as 0. An average describes the current mix of findings, so it can rise when lower-priority findings are removed while urgent findings stay listed below.",
- "security_patch_priority_basis": "Average across {count} scanned images",
- "security_patch_priority_basis_one": "Based on 1 scanned image",
+ "security_patch_priority_help": "Patch priority across scanned images, from 0 to 100. Image scores are averaged with running images counting most, and the environment stays at least High while a fixable, known-exploited vulnerability is running. It falls as findings are fixed.",
"security_severity_breakdown": "Findings by severity",
"security_exposure_breakdown": "Findings by exposure",
"security_exposure_breakdown_help": "Findings in images used by running containers carry full weight; images used only by stopped containers, or by none, count less.",
@@ -1036,7 +1031,7 @@
"security_driver_images_scanned_help": "Current images with a completed vulnerability scan.",
"security_driver_of_images": "of {count} images",
"security_top_vulnerabilities": "Top vulnerabilities",
- "security_top_vulnerabilities_risk_help": "Ranked by priority: severity weighted by known exploitation, exploit probability and container usage. Findings without a fix stay listed here but do not enter the patch priority average.",
+ "security_top_vulnerabilities_risk_help": "Ranked by priority: severity weighted by known exploitation, exploit probability and container usage. Findings without a fix stay listed here but do not enter the patch priority.",
"security_top_vulnerabilities_prevalence_help": "Ranked by how many images contain the CVE, then by risk.",
"security_rank_risk": "Priority",
"security_rank_prevalence": "Prevalence",
@@ -1052,7 +1047,7 @@
"security_threat_intel_updated": "Threat data from CISA KEV and FIRST EPSS, updated {time}",
"security_threat_intel_stale": "Threat data from CISA KEV and FIRST EPSS is out of date (last updated {time})",
"security_threat_intel_pending": "Threat data from CISA KEV and FIRST EPSS has not synced yet",
- "security_threat_intel_disabled": "Threat intelligence is off; scores use severity and container usage only and stay provisional",
+ "security_threat_intel_disabled": "Threat intelligence is off; scores use severity and container usage only",
"security_threat_intel_enabled_label": "Threat Intelligence",
"security_threat_intel_enabled_description": "Fetch the CISA KEV catalog and FIRST EPSS scores to prioritize vulnerabilities that are exploited in the wild. Disable for air-gapped installs.",
"published": "Published",
diff --git a/frontend/src/lib/components/vulnerability/risk-gauge.svelte b/frontend/src/lib/components/vulnerability/risk-gauge.svelte
index a4741d342..d6de865b6 100644
--- a/frontend/src/lib/components/vulnerability/risk-gauge.svelte
+++ b/frontend/src/lib/components/vulnerability/risk-gauge.svelte
@@ -1,7 +1,6 @@
<script lang="ts">
import * as ArcaneTooltip from '#lib/components/arcane-tooltip/index.js';
import { InfoIcon } from '#lib/icons/index.js';
- import { Badge } from '#lib/components/ui/badge/index.js';
import { m } from '#lib/paraglide/messages.js';
import type { VulnerabilityRiskBand, VulnerabilityScoreStatus } from '#lib/types/environment.js';
import { getRiskBandDisplay } from '#lib/utils/vulnerability.js';
@@ -11,7 +10,7 @@
score: number;
band: VulnerabilityRiskBand;
status: VulnerabilityScoreStatus;
- /** Tooltip body explaining what the score averages. */
+ /** Tooltip body explaining the score. */
help?: string;
/** Maximum width in px; the gauge shrinks to fit narrower containers. */
size?: number;
@@ -85,17 +84,6 @@
<p class="text-xs">{help}</p>
</ArcaneTooltip.Content>
</ArcaneTooltip.Root>
- {#if status === 'provisional'}
- <ArcaneTooltip.Root>
- <ArcaneTooltip.Trigger>
- <Badge variant="gray" size="xs">{m.vuln_score_provisional()}</Badge>
- </ArcaneTooltip.Trigger>
- <ArcaneTooltip.Content side="bottom" class="max-w-56">
- <p class="mb-1 text-sm font-medium">{m.vuln_score_provisional_title()}</p>
- <p class="text-xs">{m.vuln_score_provisional_help()}</p>
- </ArcaneTooltip.Content>
- </ArcaneTooltip.Root>
- {/if}
</span>
</div>
</div>
diff --git a/frontend/src/lib/types/environment.ts b/frontend/src/lib/types/environment.ts
index 277352891..4be736276 100644
--- a/frontend/src/lib/types/environment.ts
+++ b/frontend/src/lib/types/environment.ts
@@ -143,7 +143,7 @@ export interface VulnerabilityWithImage extends Vulnerability {
}
export type VulnerabilityRiskBand = 'none' | 'low' | 'medium' | 'high' | 'critical';
-export type VulnerabilityScoreStatus = 'complete' | 'provisional' | 'unavailable';
+export type VulnerabilityScoreStatus = 'complete' | 'unavailable';
export interface VulnerabilityPackageInsight {
pkgName: string;
diff --git a/frontend/src/routes/(app)/security/security-overview.svelte b/frontend/src/routes/(app)/security/security-overview.svelte
index 438f526d4..f8d4868ea 100644
--- a/frontend/src/routes/(app)/security/security-overview.svelte
+++ b/frontend/src/routes/(app)/security/security-overview.svelte
@@ -57,11 +57,6 @@
};
const threatDataUnavailable = $derived(!overview.threatIntel.enabled || !overview.threatIntel.lastSyncedAt);
- const scoreBasis = $derived(
- overview.drivers.scoredImages === 1
- ? m.security_patch_priority_basis_one()
- : m.security_patch_priority_basis({ count: overview.drivers.scoredImages })
- );
const drivers = $derived<Driver[]>([
{
@@ -188,7 +183,6 @@
size={460}
stroke={22}
/>
- <p class="text-xs text-muted-foreground">{scoreBasis}</p>
{#if overview.scoreDriver}
{@const driver = overview.scoreDriver}
<button
diff --git a/types/vulnerability/vulnerability.go b/types/vulnerability/vulnerability.go
index f1fb92d2d..386b85c86 100644
--- a/types/vulnerability/vulnerability.go
+++ b/types/vulnerability/vulnerability.go
@@ -265,17 +265,15 @@ const (
type ScoreStatus string
const (
- // ScoreStatusComplete means every contributing finding had threat and usage data.
+ // ScoreStatusComplete means a score was computed.
ScoreStatusComplete ScoreStatus = "complete"
- // ScoreStatusProvisional means threat data was missing or stale, usage was unknown, or some fixable findings could not be scored.
- ScoreStatusProvisional ScoreStatus = "provisional"
// ScoreStatusUnavailable means no score could be computed.
ScoreStatusUnavailable ScoreStatus = "unavailable"
)
-// PatchPriority is a 0-100 average of finding priorities with its label and data status.
+// PatchPriority is a 0-100 risk score with its label and data status.
type PatchPriority struct {
- // RiskScore is the 0-100 patch priority: for an image the mean of its distinct fixable finding priorities, for an environment the mean of its scored images.
+ // RiskScore is the 0-100 patch priority. An image weighs its worst fixable findings plus their count; an environment averages images by exposure and stays in the High band while a known-exploited fix is running.
//
// Required: true
RiskScore int `json:"riskScore"`
@@ -285,7 +283,7 @@ type PatchPriority struct {
// Required: true
RiskBand RiskBand `json:"riskBand"`
- // ScoreStatus reports whether RiskScore is complete, provisional or unavailable.
+ // ScoreStatus reports whether RiskScore is complete or unavailable.
//
// Required: true
ScoreStatus ScoreStatus `json:"scoreStatus"`
@@ -831,7 +829,7 @@ type RiskDrivers struct {
// Required: true
ImagesTotal int `json:"imagesTotal"`
- // ScoredImages is the number of scanned images that enter the patch priority average.
+ // ScoredImages is the number of scanned images that enter the patch priority score.
//
// Required: true
ScoredImages int `json:"scoredImages"`