-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseverity.go
More file actions
44 lines (37 loc) · 859 Bytes
/
severity.go
File metadata and controls
44 lines (37 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package inspect
import "strings"
// Severity represents the impact level of a finding.
type Severity int
const (
SeverityInfo Severity = iota
SeverityLow
SeverityMedium
SeverityHigh
SeverityCritical
)
var severityNames = [...]string{"info", "low", "medium", "high", "critical"}
func (s Severity) String() string {
if int(s) < len(severityNames) {
return severityNames[s]
}
return "unknown"
}
// ParseSeverity converts a string to a Severity.
func ParseSeverity(s string) Severity {
switch strings.ToLower(strings.TrimSpace(s)) {
case "critical":
return SeverityCritical
case "high":
return SeverityHigh
case "medium":
return SeverityMedium
case "low":
return SeverityLow
default:
return SeverityInfo
}
}
// AtLeast returns true if s >= threshold.
func (s Severity) AtLeast(threshold Severity) bool {
return s >= threshold
}