-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for passing private auditors (#5)
- Loading branch information
Showing
7 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SENSITIVE_BUCKET_ACCESS: | ||
title: Sensitive bucket access | ||
description: Allows read access to an important S3 bucket | ||
severity: MEDIUM | ||
group: CUSTOM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from parliament import is_arn_match, expand_action | ||
|
||
|
||
def audit(policy): | ||
action_resources = {} | ||
for action in expand_action("s3:*"): | ||
# Iterates through a list of containing elements such as | ||
# {'service': 's3', 'action': 'GetObject'} | ||
action_name = "{}:{}".format(action["service"], action["action"]) | ||
action_resources[action_name] = policy.get_allowed_resources( | ||
action["service"], action["action"] | ||
) | ||
|
||
for action_name in action_resources: | ||
resources = action_resources[action_name] | ||
for r in resources: | ||
if is_arn_match("object", "arn:aws:s3:::secretbucket*", r) or is_arn_match( | ||
"object", "arn:aws:s3:::othersecretbucket*", r | ||
): | ||
policy.add_finding( | ||
"SENSITIVE_BUCKET_ACCESS", | ||
location={"action": action_name, "resource": r}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": { | ||
"Effect": "Allow", | ||
"Action": "s3:GetObject", | ||
"Resource": "arn:aws:s3:::secretbucket/*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters