Skip to content

Commit a648b4f

Browse files
authored
Merge pull request #347 from kmcquade/fix/service-authz-url-in-iam-definition
Adds per-Service Authorization URL to IAM Definition and associated query method
2 parents 22737a8 + 034a599 commit a648b4f

File tree

7 files changed

+285
-3
lines changed

7 files changed

+285
-3
lines changed

policy_sentry/bin/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# pylint: disable=missing-module-docstring
2-
__version__ = "0.11.6"
2+
__version__ = "0.11.7"

policy_sentry/querying/all.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@ def get_all_actions(lowercase=False):
5050
# results = list(set(results))
5151
# results.sort()
5252
return all_actions
53+
54+
55+
def get_service_authorization_url(service_prefix: str) -> str:
56+
"""
57+
Gets the URL to the Actions, Resources, and Condition Keys page for a particular service.
58+
"""
59+
result = iam_definition.get(service_prefix).get("service_authorization_url")
60+
return result

policy_sentry/shared/awsdocs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,13 @@ def create_database(destination_directory, access_level_overrides_file):
198198
prefix = prefix.split('<code class="code">')[1]
199199
prefix = chomp(prefix.split("</code>")[0])
200200
break
201+
# The URL to that service's Actions, Resources, and Condition Keys page
202+
service_authorization_url_prefix = "https://docs.aws.amazon.com/service-authorization/latest/reference"
203+
service_authorization_url = f"{service_authorization_url_prefix}/{filename}"
201204
service_schema = {
202205
"service_name": service_name,
203206
"prefix": prefix,
207+
"service_authorization_url": service_authorization_url,
204208
"privileges": {},
205209
"resources": {},
206210
"conditions": {},

policy_sentry/shared/data/iam-definition.json

Lines changed: 260 additions & 0 deletions
Large diffs are not rendered by default.

policy_sentry/shared/iam_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def get_service_prefix_data(service_prefix):
2525
result = iam_definition.get(service_prefix, None)
2626
try:
2727
return result
28-
# pylint: disable=bare-except
28+
# pylint: disable=bare-except, inconsistent-return-statements
2929
except:
3030
logger.debug("Service prefix not %s found.", service_prefix)
31+
return None

test/querying/test_all.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import json
33
from policy_sentry.querying.all import (
44
get_all_service_prefixes,
5-
get_all_actions
5+
get_all_actions,
6+
get_service_authorization_url
67
)
78
from policy_sentry.command.query import query_action_table
89

@@ -50,3 +51,10 @@ def test_GH_296_query_all_actions_with_wildcard_resources(self):
5051
condition=None
5152
)
5253
self.assertTrue(len(result) > 3000)
54+
55+
def test_get_service_authorization_url(self):
56+
result = get_service_authorization_url("a4b")
57+
print(result)
58+
expected_result = "https://docs.aws.amazon.com/service-authorization/latest/reference/list_alexaforbusiness.html"
59+
self.assertTrue(result == expected_result)
60+

test/querying/test_query_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def test_get_service_prefix_data(self):
3030
desired_output_schema = Schema(
3131
{
3232
"service_name": "AWS Cloud9",
33+
"service_authorization_url": "https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscloud9.html",
3334
"prefix": "cloud9",
3435
"privileges": dict,
3536
"resources": dict,

0 commit comments

Comments
 (0)