-
Notifications
You must be signed in to change notification settings - Fork 130
/
Copy pathFalseNodeConditionsRule.rego
49 lines (41 loc) · 1.65 KB
/
FalseNodeConditionsRule.rego
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 kubeeye_nodes_rego
deny[msg] {
resource := input
type := resource.Object.kind
resourcename := resource.Object.metadata.name
type == "Node"
level := "waring"
resource.Object.status.conditions[i].status == "False"
contains(resource.Object.status.conditions[i].message, "has")
not contains(resource.Object.status.conditions[i].message, "has no")
Message := replace(resource.Object.status.conditions[i].message,"has", "has no")
contains(resource.Object.status.conditions[i].reason, "Has")
not contains(resource.Object.status.conditions[i].reason, "HasNo")
Reason := replace(resource.Object.status.conditions[i].reason,"Has", "HasNo")
msg := {
"Name": sprintf("%v", [resourcename]),
"Type": sprintf("%v", [type]),
"Level": sprintf("%v", [level]),
"Message": sprintf("%v", [Reason]),
"Reason": sprintf("%v", [Message]),
}
}
deny[msg] {
resource := input
type := resource.Object.kind
resourcename := resource.Object.metadata.name
type == "Node"
level := "waring"
resource.Object.status.conditions[i].status == "False"
contains(resource.Object.status.conditions[i].message, "has no")
Message := replace(resource.Object.status.conditions[i].message,"has no", "has")
contains(resource.Object.status.conditions[i].reason, "HasNo")
Reason := replace(resource.Object.status.conditions[i].reason,"HasNo", "Has")
msg := {
"Name": sprintf("%v", [resourcename]),
"Type": sprintf("%v", [type]),
"Level": sprintf("%v", [level]),
"Message": sprintf("%v", [Reason]),
"Reason": sprintf("%v", [Message]),
}
}