-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiam_audit.py
More file actions
29 lines (22 loc) · 817 Bytes
/
Copy pathiam_audit.py
File metadata and controls
29 lines (22 loc) · 817 Bytes
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
import boto3
from policyuniverse.policy import Policy
def audit_iam_policies():
iam = boto3.client('iam')
findings = []
# Get all IAM policies
policies = iam.list_policies(Scope='Local')['Policies']
for policy in policies:
policy_version = iam.get_policy_version(
PolicyArn=policy['Arn'],
VersionId=policy['DefaultVersionId']
)['PolicyVersion']
document = policy_version['Document']
policy_analysis = Policy(document)
if policy_analysis.is_internet_accessible():
findings.append({
'type': 'IAM',
'severity': 'HIGH',
'policy': policy['PolicyName'],
'issue': 'Overly permissive policy'
})
return findings