Skip to content

🛠️ Remediation

The remediation module produces upgrade advice for a component given its vulnerability findings — the recommended fixed version, whether the upgrade is breaking, the affected CVE IDs, and a priority level. It declares the RemediationAdvice struct and the FindRemediation constructor plus the two inspection methods on RemediationAdvice.

Type: RemediationAdvice

go
type RemediationAdvice struct {
    Component          *SBOMComponent `json:"component"`
    CurrentVersion     string         `json:"currentVersion"`
    RecommendedVersion string         `json:"recommendedVersion"`
    BreakingChange     bool           `json:"breakingChange"`
    CVEIDs             []string       `json:"cveIDs"`
    Priority           int            `json:"priority"`
    Summary            string         `json:"summary"`
}
FieldTypeDescription
Component*SBOMComponentThe component needing remediation
CurrentVersionstringCurrent version
RecommendedVersionstringRecommended fix version (empty if none found)
BreakingChangeboolWhether the upgrade is a breaking change
CVEIDs[]stringCVE IDs this remediation addresses
PriorityintRemediation priority (0=highest, 1=high, 2=medium, 3=low)
SummarystringRemediation advice summary

🔎 FindRemediation

go
func FindRemediation(component *SBOMComponent, findings []*VulnerabilityFinding) *RemediationAdvice

Builds remediation advice for component based on its findings. It collects fixed versions from each finding (including OSV data), picks the most frequently suggested version, flags a breaking change when the major version differs, gathers CVE IDs, and sets the priority from the highest severity seen (Critical → 0, High → 1, Medium → 2, else → 3).

ParameterTypeDescription
component*SBOMComponentThe component to remediate
findings[]*VulnerabilityFindingThe vulnerability findings for the component
ReturnTypeDescription
#1*RemediationAdviceThe remediation advice (never nil)
go
advice := cpeskills.FindRemediation(component, findings)
fmt.Printf("upgrade %s -> %s (priority %d): %s\n",
    advice.CurrentVersion, advice.RecommendedVersion, advice.Priority, advice.Summary)

✅ HasFixAvailable

go
func (r *RemediationAdvice) HasFixAvailable() bool

Reports whether a recommended fix version was found.

ReturnTypeDescription
#1booltrue if RecommendedVersion != ""
go
if advice.HasFixAvailable() {
    fmt.Println("fix:", advice.RecommendedVersion)
}

🚨 IsUrgent

go
func (r *RemediationAdvice) IsUrgent(findings []*VulnerabilityFinding) bool

Reports whether remediation is urgent — the priority must be 0 (Critical) and at least one finding must be listed in the Known Exploited Vulnerabilities (KEV) catalog.

ParameterTypeDescription
findings[]*VulnerabilityFindingThe findings to check for KEV listing
ReturnTypeDescription
#1booltrue if priority is 0 and any finding is KEV-listed
go
if advice.IsUrgent(findings) {
    fmt.Println("URGENT: Critical + KEV-listed, remediate immediately")
}

📐 Remediation Flow Diagram

Released under the MIT License.