severityutils

package
v1.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MinCveScore = 0.0
	MaxCveScore = 10.0
	// When parsing Sarif level to severity,
	// If the level is not provided, the value is defaulted to be 'Medium'
	SeverityDefaultValue      = Medium
	SarifSeverityRuleProperty = "security-severity"
)

Variables

View Source
var Severities = map[Severity]map[jasutils.ApplicabilityStatus]*SeverityDetails{
	Critical: {
		jasutils.Applicable:                &SeverityDetails{Priority: 25, Score: MaxCveScore, Emoji: "💀", style: color.New(color.BgLightRed, color.LightWhite)},
		jasutils.ApplicabilityUndetermined: &SeverityDetails{Priority: 24, Score: MaxCveScore, Emoji: "💀", style: color.New(color.BgLightRed, color.LightWhite)},
		jasutils.MissingContext:            &SeverityDetails{Priority: 23, Score: MaxCveScore, Emoji: "💀", style: color.New(color.BgLightRed, color.LightWhite)},
		jasutils.NotCovered:                &SeverityDetails{Priority: 22, Score: MaxCveScore, Emoji: "💀", style: color.New(color.BgLightRed, color.LightWhite)},
		jasutils.NotApplicable:             &SeverityDetails{Priority: 5, Score: MaxCveScore, Emoji: "💀", style: color.New(color.Gray)},
	},
	High: {
		jasutils.Applicable:                &SeverityDetails{Priority: 21, Score: 8.9, Emoji: "🔥", style: color.New(color.Red)},
		jasutils.ApplicabilityUndetermined: &SeverityDetails{Priority: 20, Score: 8.9, Emoji: "🔥", style: color.New(color.Red)},
		jasutils.MissingContext:            &SeverityDetails{Priority: 19, Score: 8.9, Emoji: "🔥", style: color.New(color.Red)},
		jasutils.NotCovered:                &SeverityDetails{Priority: 18, Score: 8.9, Emoji: "🔥", style: color.New(color.Red)},
		jasutils.NotApplicable:             &SeverityDetails{Priority: 4, Score: 8.9, Emoji: "🔥", style: color.New(color.Gray)},
	},
	Medium: {
		jasutils.Applicable:                &SeverityDetails{Priority: 17, Score: 6.9, Emoji: "🎃", style: color.New(color.Yellow)},
		jasutils.ApplicabilityUndetermined: &SeverityDetails{Priority: 16, Score: 6.9, Emoji: "🎃", style: color.New(color.Yellow)},
		jasutils.MissingContext:            &SeverityDetails{Priority: 15, Score: 6.9, Emoji: "🎃", style: color.New(color.Yellow)},
		jasutils.NotCovered:                &SeverityDetails{Priority: 14, Score: 6.9, Emoji: "🎃", style: color.New(color.Yellow)},
		jasutils.NotApplicable:             &SeverityDetails{Priority: 3, Score: 6.9, Emoji: "🎃", style: color.New(color.Gray)},
	},
	Low: {
		jasutils.Applicable:                &SeverityDetails{Priority: 13, Score: 3.9, Emoji: "👻"},
		jasutils.ApplicabilityUndetermined: &SeverityDetails{Priority: 12, Score: 3.9, Emoji: "👻"},
		jasutils.MissingContext:            &SeverityDetails{Priority: 11, Score: 3.9, Emoji: "👻"},
		jasutils.NotCovered:                &SeverityDetails{Priority: 10, Score: 3.9, Emoji: "👻"},
		jasutils.NotApplicable:             &SeverityDetails{Priority: 2, Score: 3.9, Emoji: "👻", style: color.New(color.Gray)},
	},
	Unknown: {
		jasutils.Applicable:                &SeverityDetails{Priority: 9, Score: MinCveScore, Emoji: "😐"},
		jasutils.ApplicabilityUndetermined: &SeverityDetails{Priority: 8, Score: MinCveScore, Emoji: "😐"},
		jasutils.MissingContext:            &SeverityDetails{Priority: 7, Score: MinCveScore, Emoji: "😐"},
		jasutils.NotCovered:                &SeverityDetails{Priority: 6, Score: MinCveScore, Emoji: "😐"},
		jasutils.NotApplicable:             &SeverityDetails{Priority: 1, Score: MinCveScore, Emoji: "😐", style: color.New(color.Gray)},
	},
}

Functions

func CompareSeverity

func CompareSeverity(severity1, severity2 Severity) int

CompareSeverity compares two severities and returns the difference in priority If severity1 is more severe than severity2, the result will be positive

func GetAsDetails

func GetAsDetails(severity Severity, applicabilityStatus jasutils.ApplicabilityStatus, pretty bool) formats.SeverityDetails

func GetSeverityIcon added in v1.7.2

func GetSeverityIcon(severity Severity) string

func GetSeverityPriority

func GetSeverityPriority(severity Severity, applicabilityStatus jasutils.ApplicabilityStatus) int

func GetSeverityScore

func GetSeverityScore(severity Severity, applicabilityStatus jasutils.ApplicabilityStatus) float32

func ParseToSeverityDetails

func ParseToSeverityDetails(severity string, sarifSeverity, pretty bool, applicabilityStatus jasutils.ApplicabilityStatus) (out formats.SeverityDetails, err error)

Types

type SarifSeverityLevel

type SarifSeverityLevel string
const (
	LevelError   SarifSeverityLevel = "error"
	LevelWarning SarifSeverityLevel = "warning"
	LevelInfo    SarifSeverityLevel = "info"
	LevelNote    SarifSeverityLevel = "note"
	LevelNone    SarifSeverityLevel = "none"
)

func GetSarifSeverityLevel

func GetSarifSeverityLevel(severity string) SarifSeverityLevel

func ParseToSarifSeverityLevel

func ParseToSarifSeverityLevel(sarifSeverity string) (parsed SarifSeverityLevel, err error)

func SeverityToSarifSeverityLevel

func SeverityToSarifSeverityLevel(severity Severity) SarifSeverityLevel

func (SarifSeverityLevel) String

func (s SarifSeverityLevel) String() string

type Severity

type Severity string
const (
	Critical Severity = "Critical"
	High     Severity = "High"
	Medium   Severity = "Medium"
	Low      Severity = "Low"
	Unknown  Severity = "Unknown"
)

func GetSeverity

func GetSeverity(severity string) Severity

func ParseSeverity

func ParseSeverity(severity string, sarifSeverity bool) (parsed Severity, err error)

func ParseToSeverity

func ParseToSeverity(severity string) (parsed Severity, err error)

func (Severity) String

func (s Severity) String() string

type SeverityDetails

type SeverityDetails struct {
	Priority int
	// for GitHub Security Alerts
	Score float32
	// Pretty format
	Emoji string
	// contains filtered or unexported fields
}

func GetSeverityDetails

func GetSeverityDetails(severity Severity, applicabilityStatus jasutils.ApplicabilityStatus) *SeverityDetails

func ParseForDetails

func ParseForDetails(severity string, sarifSeverity bool, applicabilityStatus jasutils.ApplicabilityStatus) (details *SeverityDetails, err error)

func (SeverityDetails) ToDetails

func (sd SeverityDetails) ToDetails(severity Severity, pretty bool) formats.SeverityDetails

func (SeverityDetails) ToString

func (sd SeverityDetails) ToString(severity Severity, pretty bool) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL