Documentation
¶
Overview ¶
Package severity provides unified severity level definitions and mappings for security findings across SDK and Backend.
IMPORTANT: This package is shared between sdk and api. Any changes must be backward compatible or coordinated across both projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CountBySeverity ¶
type CountBySeverity struct {
Critical int `json:"critical"`
High int `json:"high"`
Medium int `json:"medium"`
Low int `json:"low"`
Info int `json:"info"`
Unknown int `json:"unknown"`
Total int `json:"total"`
}
CountBySeverity counts findings by severity level.
func (*CountBySeverity) HighestSeverity ¶
func (c *CountBySeverity) HighestSeverity() Level
HighestSeverity returns the highest severity level that has a non-zero count.
func (*CountBySeverity) Increment ¶
func (c *CountBySeverity) Increment(level Level)
Increment increases the count for the given severity.
type Level ¶
type Level string
Level represents a severity level for security findings.
const ( // Critical - Immediate action required. Actively exploited or trivially exploitable. Critical Level = "critical" // High - Serious vulnerability that should be addressed urgently. High Level = "high" // Medium - Moderate risk, should be addressed in normal development cycle. Medium Level = "medium" // Low - Minor issue, address when convenient. Low Level = "low" // Info - Informational finding, no security impact. Info Level = "info" // Unknown - Severity could not be determined. Unknown Level = "unknown" )
func AllLevels ¶
func AllLevels() []Level
AllLevels returns all severity levels in order of priority (highest first).
func FromCVSS ¶
FromCVSS converts a CVSS score (0.0-10.0) to a severity level. Based on CVSS v3.0 severity ratings:
- 9.0-10.0: Critical
- 7.0-8.9: High
- 4.0-6.9: Medium
- 0.1-3.9: Low
- 0.0: Info
func FromString ¶
FromString normalizes various severity string formats to a standard Level. Handles common formats from different scanners:
- Semgrep: ERROR, WARNING, INFO
- Trivy: CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN
- Gitleaks: (uses rule-based)
- SARIF: error, warning, note
func (Level) IsHigherThan ¶
IsHigherThan returns true if this severity is higher than the other.
func (Level) Priority ¶
Priority returns the numeric priority of the severity level. Higher numbers = higher priority.
func (Level) ToCVSSRange ¶
ToCVSSRange returns the CVSS score range for a severity level. Returns (min, max) where min is inclusive and max is exclusive.