Skip to content

Commit cb22af2

Browse files
fix(db_event): Handle other events (#6757)
Co-authored-by: Pepe Fagoaga <[email protected]>
1 parent a534b94 commit cb22af2

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

prowler/providers/aws/services/rds/rds_instance_critical_event_subscription/rds_instance_critical_event_subscription.py

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def execute(self):
5454
}:
5555
report.status = "FAIL"
5656
report.status_extended = "RDS instance event category of maintenance is not subscribed."
57+
else:
58+
report.status = "FAIL"
59+
report.status_extended = "RDS instance event categories of maintenance, configuration change, and failure are not subscribed."
5760
findings.append(report)
5861

5962
return findings

tests/providers/aws/services/rds/rds_instance_critical_event_subscription/rds_instance_critical_event_subscription_test.py

+49
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,52 @@ def test_rds_instance_event_failure_and_maintenance(self):
483483
== f"arn:aws:rds:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:es:TestSub"
484484
)
485485
assert result[0].resource_tags == []
486+
487+
@mock_aws
488+
def test_rds_instance_event_invalid(self):
489+
conn = client("rds", region_name=AWS_REGION_US_EAST_1)
490+
conn.create_db_parameter_group(
491+
DBParameterGroupName="test",
492+
DBParameterGroupFamily="default.aurora-postgresql14",
493+
Description="test parameter group",
494+
)
495+
conn.create_event_subscription(
496+
SubscriptionName="TestSub",
497+
SnsTopicArn=f"arn:aws:sns:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:test",
498+
SourceType="db-instance",
499+
EventCategories=["invalid"],
500+
Enabled=True,
501+
)
502+
from prowler.providers.aws.services.rds.rds_service import RDS
503+
504+
aws_provider = set_mocked_aws_provider([AWS_REGION_US_EAST_1])
505+
506+
with mock.patch(
507+
"prowler.providers.common.provider.Provider.get_global_provider",
508+
return_value=aws_provider,
509+
):
510+
with mock.patch(
511+
"prowler.providers.aws.services.rds.rds_instance_critical_event_subscription.rds_instance_critical_event_subscription.rds_client",
512+
new=RDS(aws_provider),
513+
):
514+
# Test Check
515+
from prowler.providers.aws.services.rds.rds_instance_critical_event_subscription.rds_instance_critical_event_subscription import (
516+
rds_instance_critical_event_subscription,
517+
)
518+
519+
check = rds_instance_critical_event_subscription()
520+
result = check.execute()
521+
522+
assert len(result) == 1
523+
assert result[0].status == "FAIL"
524+
assert (
525+
result[0].status_extended
526+
== "RDS instance event categories of maintenance, configuration change, and failure are not subscribed."
527+
)
528+
assert result[0].resource_id == "TestSub"
529+
assert result[0].region == AWS_REGION_US_EAST_1
530+
assert (
531+
result[0].resource_arn
532+
== f"arn:aws:rds:{AWS_REGION_US_EAST_1}:{AWS_ACCOUNT_NUMBER}:es:TestSub"
533+
)
534+
assert result[0].resource_tags == []

0 commit comments

Comments
 (0)