-
Notifications
You must be signed in to change notification settings - Fork 16
/
test.rego
96 lines (85 loc) · 1.75 KB
/
test.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
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
package compliance.cis_aws.rules.cis_5_1
import data.cis_aws.test_data
import data.compliance.cis_aws.data_adapter
import data.lib.test
test_violation {
eval_fail with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"PortRange": {
"From": 0,
"To": 1024,
},
"Protocol": "6",
"RuleAction": "allow",
"RuleNumber": 100,
})
eval_fail with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"PortRange": {
"From": 40,
"To": 80,
},
"Protocol": "6",
"RuleAction": "allow",
"RuleNumber": 100,
})
eval_fail with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"Protocol": "-1",
"RuleAction": "allow",
"RuleNumber": 32767,
})
eval_fail with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"PortRange": {
"From": 3389,
"To": 3390,
},
"Protocol": "6",
"RuleAction": "allow",
"RuleNumber": 100,
})
}
test_pass {
eval_pass with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": true,
"Protocol": "-1",
"RuleAction": "deny",
"RuleNumber": 32767,
})
eval_pass with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"PortRange": {
"From": 8080,
"To": 8181,
},
"Protocol": "6",
"RuleAction": "allow",
"RuleNumber": 100,
})
eval_pass with input as rule_input({})
eval_pass with input as rule_input({
"CidrBlock": "0.0.0.0/0",
"Egress": false,
"PortRange": {
"From": 40,
"To": 41,
},
"Protocol": "6",
"RuleAction": "allow",
"RuleNumber": 100,
})
}
rule_input(entry) = test_data.generate_nacl(entry)
eval_fail {
test.assert_fail(finding) with data.benchmark_data_adapter as data_adapter
}
eval_pass {
test.assert_pass(finding) with data.benchmark_data_adapter as data_adapter
}