-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathutils.go
More file actions
42 lines (36 loc) · 1.26 KB
/
utils.go
File metadata and controls
42 lines (36 loc) · 1.26 KB
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
package alert
import (
"github.com/stackrox/rox/generated/internalapi/central"
"github.com/stackrox/rox/generated/storage"
)
// IsDeployTimeAttemptedAlert indicates whether an alert is an attempted deploy-time alert.
func IsDeployTimeAttemptedAlert(alert *storage.Alert) bool {
return IsAttemptedAlert(alert) &&
alert.GetLifecycleStage() == storage.LifecycleStage_DEPLOY
}
// IsAttemptedAlert indicates whether an alert is an attempted alert.
func IsAttemptedAlert(alert *storage.Alert) bool {
return alert.GetState() == storage.ViolationState_ATTEMPTED
}
// AnyAttemptedAlert indicates whether any alert is an attempted alert.
func AnyAttemptedAlert(alerts ...*storage.Alert) bool {
for _, alert := range alerts {
if IsAttemptedAlert(alert) {
return true
}
}
return false
}
// IsRuntimeAlertResult returns whether or not the passed results are from a runtime policy
func IsRuntimeAlertResult(alert *central.AlertResults) bool {
return alert.GetStage() == storage.LifecycleStage_RUNTIME
}
// IsAlertResultResolved returns if there is a resolved alert within the alert result
func IsAlertResultResolved(alert *central.AlertResults) bool {
for _, a := range alert.GetAlerts() {
if a.GetState() == storage.ViolationState_RESOLVED {
return true
}
}
return false
}