-
Notifications
You must be signed in to change notification settings - Fork 25
/
interface.go
115 lines (95 loc) · 2.77 KB
/
interface.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package reportsummary
import (
"time"
"github.com/kubescape/opa-utils/reporthandling/apis"
helpersv1 "github.com/kubescape/opa-utils/reporthandling/helpers/v1"
)
type ControlCriteria string
const (
EControlCriteriaID ControlCriteria = "ID"
EControlCriteriaName ControlCriteria = "name"
)
type IBasicPostureReport interface {
GetCustomerGUID() string
GetClusterName() string
GetReportGUID() string
GetJobID() string
GetTimestamp() *time.Time
//todo GetISummaryDetails
}
type IFrameworkSummary interface {
IPolicies
ListControls() []IControlSummary
NumberOfControls() ICounters
}
type IControlSummary interface {
IPolicies
GetScoreFactor() float32
// GetID get control ID
GetID() string
// GetRemediation get control remediation
GetRemediation() string
// GetDescription get control description
GetDescription() string
}
type IControlsSummaries interface {
GetControl(criteria ControlCriteria, value string) IControlSummary
NumberOfControls() ICounters
ListControlsIDs() *helpersv1.AllLists
ListResourcesIDs() *helpersv1.AllLists
}
type IPolicies interface {
GetStatus() apis.IStatus
CalculateStatus()
ListResourcesIDs() *helpersv1.AllLists
// Counters
NumberOfResources() ICounters
// Score
GetScore() float32
// Name
GetName() string
}
type ListPolicies struct {
passed []IPolicies
excluded []IPolicies
failed []IPolicies
skipped []IPolicies
other []IPolicies
}
func (all *ListPolicies) Failed() []IPolicies { return all.failed }
func (all *ListPolicies) Passed() []IPolicies { return all.passed }
func (all *ListPolicies) Excluded() []IPolicies { return all.excluded }
func (all *ListPolicies) Skipped() []IPolicies { return all.skipped }
func (all *ListPolicies) Other() []IPolicies { return all.other }
func (all *ListPolicies) All() []IPolicies {
l := []IPolicies{}
l = append(l, all.failed...)
l = append(l, all.excluded...)
l = append(l, all.passed...)
l = append(l, all.skipped...)
l = append(l, all.other...)
return l
}
// Append append single string to matching status list
func (all *ListPolicies) Append(status apis.ScanningStatus, policy IPolicies) {
switch status {
case apis.StatusPassed:
all.passed = append(all.passed, policy)
case apis.StatusFailed:
all.failed = append(all.failed, policy)
case apis.StatusExcluded:
all.excluded = append(all.excluded, policy)
case apis.StatusSkipped:
all.skipped = append(all.skipped, policy)
default:
all.other = append(all.other, policy)
}
}
// Update AllLists objects with
func (all *ListPolicies) Update(all2 *ListPolicies) {
all.passed = append(all.passed, all2.passed...)
all.failed = append(all.failed, all2.failed...)
all.excluded = append(all.excluded, all2.excluded...)
all.skipped = append(all.skipped, all2.skipped...)
all.other = append(all.other, all2.other...)
}