Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_exception_bad_service(self):
try:
expand_action("333:listallmybuckets")
assert False
except UnknownPrefixException as e:
assert True
expanded_actions = []
for action in actions:
# Handle special case where all actions are allowed
if action == "*" or action == "*:*":
# TODO Should ensure the resource is "*" with this action
continue
try:
# Given an action such as "s3:List*", return all the possible values it could have
expanded_actions.extend(expand_action(action))
except UnknownActionException as e:
self.add_finding(
"UNKNOWN_ACTION", detail=str(e), location={"unknown_action": action, "statement": self.stmt}
)
return False
except UnknownPrefixException as e:
self.add_finding(
"UNKNOWN_PREFIX", detail=str(e), location={"statement": self.stmt}
)
return False
except Exception as e:
self.add_finding(
"EXCEPTION", detail=str(e), location={"statement": self.stmt}
)
return False
# Check the resources are correct formatted correctly
has_malformed_resource = False
for resource in resources:
if resource == "*":
continue
parts = resource.split(":")