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
# This rule will return
# 1) FAIL if any IAM policy has a wildcard action
# 2) PASS if there are no IAM policies or IAM policies have no wildcard actions
#
rule assert_no_wildcard_actions {
Roles[*] empty or
Roles[*] {
# if there are no policies - PASS
Policies[*] empty or
Policies[*].Policy.Statement[*] {
Action[*] != '*'
}
}
# if there are no users - PASS
Users[*] empty or
Users[*] {
# if there are no policies - PASS
Policies[*] empty or
Policies[*].Policy.Statement[*] {
Action[*] != '*'
}
}
# if there are no groups - PASS
Groups[*] empty or
Groups[*] {
# if there are no policies - PASS
Policies[*] empty or
Policies[*].Policy.Statement[*] {
Action[*] != '*'
}
}
# if there are no resources - PASS
Resources[*] empty or
Resources[*] {
# resources only have a single policy
Policy.Policy.Statement[*] {
Action[*] != '*'
}
}
# if there are no permission sets - PASS
PermissionSets[*] empty or
PermissionSets[*] {
# if there are no policies - PASS
Policies[*] empty or
Policies[*].Policy.Statement[*] {
Action[*] != '*'
}
}
# if there are no orphaned policies - PASS
OrphanedPolicies[*] empty or
OrphanedPolicies[*] {
# orphaned policies have direct policy elements, no need to traverse to Policies[*]
Policy.Statement[*] {
Action[*] != '*'
}
}
}