Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sns): Add region to subscriptions #6731

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions prowler/providers/aws/services/sns/sns_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _list_subscriptions_by_topic(self):
owner=sub["Owner"],
protocol=sub["Protocol"],
endpoint=sub["Endpoint"],
region=sub["SubscriptionArn"].split(":")[3],
)
for sub in response["Subscriptions"]
]
Expand All @@ -117,6 +118,7 @@ class Subscription(BaseModel):
owner: str
protocol: str
endpoint: str
region: str


class Topic(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def test_subscriptions_with_pending_confirmation(self):
owner=AWS_ACCOUNT_NUMBER,
protocol="https",
endpoint="https://www.endpoint.com",
region=AWS_REGION_EU_WEST_1,
)
)
sns_client.topics = []
Expand Down Expand Up @@ -100,6 +101,7 @@ def test_subscriptions_with_https(self):
owner=AWS_ACCOUNT_NUMBER,
protocol="https",
endpoint="https://www.endpoint.com",
region=AWS_REGION_EU_WEST_1,
)
)
sns_client.topics = []
Expand Down Expand Up @@ -131,6 +133,7 @@ def test_subscriptions_with_https(self):
)
assert result[0].resource_id == subscription_id_1
assert result[0].resource_arn == subscription_arn_1
assert result[0].region == AWS_REGION_EU_WEST_1

def test_subscriptions_with_http(self):
sns_client = mock.MagicMock
Expand All @@ -142,6 +145,7 @@ def test_subscriptions_with_http(self):
owner=AWS_ACCOUNT_NUMBER,
protocol="http",
endpoint="http://www.endpoint.com",
region=AWS_REGION_EU_WEST_1,
)
)
sns_client.topics = []
Expand Down Expand Up @@ -173,6 +177,7 @@ def test_subscriptions_with_http(self):
)
assert result[0].resource_id == subscription_id_2
assert result[0].resource_arn == subscription_arn_2
assert result[0].region == AWS_REGION_EU_WEST_1

def test_subscriptions_with_http_and_https(self):
sns_client = mock.MagicMock
Expand All @@ -184,6 +189,7 @@ def test_subscriptions_with_http_and_https(self):
owner=AWS_ACCOUNT_NUMBER,
protocol="https",
endpoint="https://www.endpoint.com",
region=AWS_REGION_EU_WEST_1,
)
)
subscriptions.append(
Expand All @@ -193,6 +199,7 @@ def test_subscriptions_with_http_and_https(self):
owner=AWS_ACCOUNT_NUMBER,
protocol="http",
endpoint="http://www.endpoint.com",
region=AWS_REGION_EU_WEST_1,
)
)
sns_client.topics = []
Expand Down Expand Up @@ -224,6 +231,7 @@ def test_subscriptions_with_http_and_https(self):
)
assert result[0].resource_id == subscription_id_1
assert result[0].resource_arn == subscription_arn_1
assert result[0].region == AWS_REGION_EU_WEST_1

assert result[1].status == "FAIL"
assert (
Expand All @@ -232,3 +240,4 @@ def test_subscriptions_with_http_and_https(self):
)
assert result[1].resource_id == subscription_id_2
assert result[1].resource_arn == subscription_arn_2
assert result[1].region == AWS_REGION_EU_WEST_1