-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic filtering by role-arn (#3)
- Loading branch information
Showing
10 changed files
with
129 additions
and
25 deletions.
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 0.1.0 | ||
current_version = 0.2.0 | ||
commit = True | ||
tag = True | ||
|
||
|
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 |
---|---|---|
@@ -1,19 +1,50 @@ | ||
from tests.test_utils_testdata import cloudtrail_data, cloudtrail_data_dir | ||
from trailscraper.cloudtrail import _parse_records_from_gzipped_file, load_from_dir | ||
from trailscraper.cloudtrail import Record | ||
from trailscraper.cloudtrail import _parse_records_from_gzipped_file, load_from_dir, _parse_record, \ | ||
_parse_records | ||
|
||
|
||
def test_parse_records_from_gzipped_file(): | ||
parsed_records = _parse_records_from_gzipped_file(cloudtrail_data("someRecords.json.gz")) | ||
assert parsed_records == [ | ||
Record("autoscaling.amazonaws.com", "DescribeLaunchConfigurations"), | ||
Record("sts.amazonaws.com", "AssumeRole", ["arn:aws:iam::111111111111:role/someRole"]) | ||
Record("autoscaling.amazonaws.com", "DescribeLaunchConfigurations", | ||
assumed_role_arn="arn:aws:iam::111111111111:role/someRole"), | ||
Record("sts.amazonaws.com", "AssumeRole", | ||
resource_arns=["arn:aws:iam::111111111111:role/someRole"]) | ||
] | ||
|
||
|
||
def test_load_all_gzipped_files_from_dir(): | ||
records = load_from_dir(cloudtrail_data_dir()) | ||
assert records == [ | ||
Record("autoscaling.amazonaws.com", "DescribeLaunchConfigurations"), | ||
Record("sts.amazonaws.com", "AssumeRole", ["arn:aws:iam::111111111111:role/someRole"]) | ||
Record("autoscaling.amazonaws.com", "DescribeLaunchConfigurations", | ||
assumed_role_arn="arn:aws:iam::111111111111:role/someRole"), | ||
Record("sts.amazonaws.com", "AssumeRole", | ||
resource_arns=["arn:aws:iam::111111111111:role/someRole"]) | ||
] | ||
|
||
|
||
def test_parse_record_should_be_able_to_cope_with_missing_type(): | ||
assert _parse_record({'userIdentity': {'accountId': '111111111111'}, | ||
'eventSource': 'kms.amazonaws.com', | ||
'eventName': 'DeleteKey'}) == \ | ||
Record('kms.amazonaws.com', 'DeleteKey') | ||
|
||
|
||
def test_parse_record_should_be_able_to_cope_with_missing_session_context_in_assumed_role(): | ||
assert _parse_record({'eventVersion': '1.05', | ||
'userIdentity': {'type': 'AssumedRole', 'principalId': 'some-key:some-user', | ||
'arn': 'arn:aws:sts::111111111111:assumed-role/some-role/some-user', | ||
'accountId': '111111111111'}, | ||
'eventSource': 'signin.amazonaws.com', | ||
'eventName': 'RenewRole'}) == \ | ||
Record('signin.amazonaws.com', 'RenewRole') | ||
|
||
|
||
def test_parse_records_should_ignore_records_that_cant_be_parsed(): | ||
assert _parse_records([{}, | ||
{'eventVersion': '1.05', | ||
'userIdentity': {'type': 'SomeType'}, | ||
'eventSource': 'someSource', | ||
'eventName': 'SomeEvent'}]) == \ | ||
[Record('someSource', 'SomeEvent')] |
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
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