-
Notifications
You must be signed in to change notification settings - Fork 193
/
common_types.go
49 lines (40 loc) · 1.24 KB
/
common_types.go
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
45
46
47
48
49
package v1alpha1
import (
"fmt"
"strings"
)
const (
TTLReportAnnotation = "trivy-operator.aquasecurity.github.io/report-ttl"
)
// Severity level of a vulnerability or a configuration audit check.
// +enum
type Severity string
const (
SeverityCritical Severity = "CRITICAL"
SeverityHigh Severity = "HIGH"
SeverityMedium Severity = "MEDIUM"
SeverityLow Severity = "LOW"
SeverityNone Severity = "NONE"
SeverityUnknown Severity = "UNKNOWN"
)
// StringToSeverity returns the enum constant of Severity with the specified
// name. The name must match exactly an identifier used to declare an enum
// constant. (Extraneous whitespace characters are not permitted.)
func StringToSeverity(name string) (Severity, error) {
s := strings.ToUpper(name)
switch s {
case "CRITICAL", "HIGH", "MEDIUM", "LOW", "NONE", "UNKNOWN":
return Severity(s), nil
default:
return "", fmt.Errorf("unrecognized name literal: %s", name)
}
}
// Scanner is the spec for a scanner generating a security assessment report.
type Scanner struct {
// Name the name of the scanner.
Name string `json:"name"`
// Vendor the name of the vendor providing the scanner.
Vendor string `json:"vendor"`
// Version the version of the scanner.
Version string `json:"version"`
}