Skip to content

Commit

Permalink
Improved isCrossAccount condition
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrogonzalez3 committed Mar 3, 2020
1 parent f1d1949 commit 18b633a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ScoutSuite/core/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def pass_condition(b, test, a):
if type(b) != list:
b = [b]
for c in b:
if type(c) == dict and 'AWS' in c:
c = c['AWS']
if c != a and not re.match(r'arn:aws:iam:.*?:%s:.*' % a, c):
result = True
break
Expand Down
6 changes: 6 additions & 0 deletions tests/test-utils-conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ def test_pass_condition(self):
assert pass_condition('123456789012', 'isCrossAccount', '123456789013') == True
assert pass_condition(['123456789013', '123456789012'], 'isCrossAccount', '123456789013') == True
assert pass_condition('arn:aws:iam::123456789012:root', 'isCrossAccount', '123456789013') == True
assert pass_condition({'AWS': 'arn:aws:iam::123456789012:root'}, 'isCrossAccount', '123456789013')
assert pass_condition(
[{'AWS': 'arn:aws:iam::123456789013:root'}, {'AWS': 'arn:aws:iam::123456789012:root'}],
'isCrossAccount',
'123456789013'
)

try:
pass_condition('foo', 'bar', 'baz')
Expand Down

0 comments on commit 18b633a

Please sign in to comment.