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(aws): SNS threw IndexError if SubscriptionArn is PendingConfirmation #6896

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

kagahd
Copy link
Contributor

@kagahd kagahd commented Feb 11, 2025

Context

The sns_service.py threw the error IndexError[100]: list index out of range upon extracting the region from the field SubscriptionArn of a subscription if the field SubscriptionArn was not an ARN but the value PendingConfirmation.

Description

This PR fixes it by verifying that the SubscriptionArn has at least 4 parts after the split by the character : in order to extract the 4th part, which is the region. If it doesn't, the region is set to unkown. Instead of unknown it could have been set also to regional_client.region or topic.region but I'm not sure if they can differ from the region of a subscription. Feel free to adapt it.

Checklist

API

  • Verify if API specs need to be regenerated.
  • Check if version updates are required (e.g., specs, Poetry, etc.).
  • Ensure new entries are added to CHANGELOG.md, if applicable.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kagahd kagahd requested review from a team as code owners February 11, 2025 19:15
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Feb 11, 2025
Copy link

codecov bot commented Feb 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.70%. Comparing base (43cae66) to head (5587536).
Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6896      +/-   ##
==========================================
- Coverage   88.73%   88.70%   -0.03%     
==========================================
  Files        1200     1200              
  Lines       34609    34609              
==========================================
- Hits        30710    30701       -9     
- Misses       3899     3908       +9     
Flag Coverage Δ
prowler 88.70% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
prowler 88.70% <ø> (-0.03%) ⬇️
api ∅ <ø> (∅)

@MrCloudSec MrCloudSec added backport-to-v4.6 Backport PR to the v4.6 branch backport-to-v5.3 Backport PR to the v5.3 branch labels Feb 11, 2025
@jfagoagas jfagoagas changed the title fix(aws) sns_service threw IndexError if SubscriptionArn is PendingConfirmation fix(aws): sns_service threw IndexError if SubscriptionArn is PendingConfirmation Feb 12, 2025
@MrCloudSec MrCloudSec changed the title fix(aws): sns_service threw IndexError if SubscriptionArn is PendingConfirmation fix(aws): SNS threw IndexError if SubscriptionArn is PendingConfirmation Feb 13, 2025
Copy link
Member

@MrCloudSec MrCloudSec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @kagahd !!

@MrCloudSec MrCloudSec merged commit 0ff4df0 into prowler-cloud:master Feb 13, 2025
10 of 11 checks passed
@prowler-bot prowler-bot added the was-backported The PR was successfully backported to the target branch label Feb 13, 2025
@prowler-bot
Copy link
Collaborator

💚 All backports created successfully

Status Branch Result
v4.6
v5.3

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-v4.6 Backport PR to the v4.6 branch backport-to-v5.3 Backport PR to the v5.3 branch provider/aws Issues/PRs related with the AWS provider was-backported The PR was successfully backported to the target branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants