-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
110 additions
and
70 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
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 |
---|---|---|
@@ -1,44 +1,41 @@ | ||
""" | ||
Text operations specific to IAM actions | ||
""" | ||
from __future__ import annotations | ||
|
||
|
||
def get_service_from_action(action): | ||
def get_service_from_action(action: str) -> str: | ||
""" | ||
Returns the service name from a service:action combination | ||
:param action: ec2:DescribeInstance | ||
:return: ec2 | ||
""" | ||
service, action_name = action.split(":") # pylint: disable=unused-variable | ||
return str.lower(service) | ||
service = action.split(":")[0] | ||
return service.lower() | ||
|
||
|
||
def get_action_name_from_action(action): | ||
def get_action_name_from_action(action: str) -> str: | ||
""" | ||
Returns the lowercase action name from a service:action combination | ||
:param action: ec2:DescribeInstance | ||
:return: describeinstance | ||
""" | ||
service, action_name = action.split(":") # pylint: disable=unused-variable | ||
return str.lower(action_name) | ||
action_name = action.split(":")[1] | ||
return action_name.lower() | ||
|
||
|
||
def get_lowercase_action_list(action_list): | ||
def get_lowercase_action_list(action_list: list[str]) -> list[str]: | ||
""" | ||
Given a list of actions, return the list but in lowercase format | ||
""" | ||
new_action_list = [] | ||
for action in action_list: | ||
new_action_list.append(str.lower(action)) | ||
return new_action_list | ||
return [action.lower() for action in action_list] | ||
|
||
|
||
def get_full_action_name(service, action_name): | ||
def get_full_action_name(service: str, action_name: str) -> str: | ||
""" | ||
Gets the proper formatting for an action - the service, plus colon, plus action name. | ||
:param service: service name, like s3 | ||
:param action_name: action name, like createbucket | ||
:return: the resulting string | ||
""" | ||
action = service + ":" + action_name | ||
return action | ||
return f"{service}:{action_name}" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[tool.mypy] | ||
files = "policy_sentry" | ||
strict = true | ||
|
||
exclude = [ | ||
'^policy_sentry/analysis', | ||
'^policy_sentry/bin', | ||
'^policy_sentry/command', | ||
'^policy_sentry/querying', | ||
'^policy_sentry/shared', | ||
'^policy_sentry/util/(arns|policy_files)', | ||
'^policy_sentry/writing', | ||
] |
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