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

feat(aws): Add new check to ensure Aurora MySQL DB Clusters publish audit logs to CloudWatch logs #4916

Conversation

danibarranqueroo
Copy link
Member

Context

This new check verifies that Amazon Aurora MySQL DB clusters are configured to publish audit logs to Amazon CloudWatch Logs. Audit logs are vital for tracking database activity such as login attempts, data modifications, and schema changes. Configuring audit logs to publish to CloudWatch enables real-time analysis, durable storage of logs, and the creation of alarms and metrics for enhanced monitoring and compliance.

I have done this new check following the SH implementation, but there is an option of doing it as it’s done for instances, the option done is mirroring the existing AWS Security Hub control, focusing only on Aurora MySQL clusters, which have specific and robust support for audit log exports.
The other option would be doing as the RDS.9 control but for clusters, the problem here is that some clusters needs plugins to publish audit and they are not as complete as the Aurora MySQL ones.

So, in conclusion, I've done this check only for the Aurora MySQL clusters but the option of changing it is available and I’ll be open to listen any suggestion.

Description

Added new rds_cluster_integration_cloudwatch_logs check with its unit tests.

Checklist

License

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

@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Sep 2, 2024
Copy link

codecov bot commented Sep 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.91%. Comparing base (163027a) to head (0f2e5f4).
Report is 46 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4916      +/-   ##
==========================================
- Coverage   89.03%   88.91%   -0.12%     
==========================================
  Files         937      947      +10     
  Lines       28709    29081     +372     
==========================================
+ Hits        25560    25857     +297     
- Misses       3149     3224      +75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

def execute(self):
findings = []
for db_cluster_arn, db_cluster in rds_client.db_clusters.items():
if db_cluster.engine == "aurora-mysql":
Copy link
Member

Choose a reason for hiding this comment

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

According to https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBCluster.html, it is valid for:

Valid for Cluster Type: Aurora DB clusters and Multi-AZ DB clusters

The following values are valid for each DB engine:

Aurora MySQL - audit | error | general | slowquery

Aurora PostgreSQL - postgresql

RDS for MySQL - error | general | slowquery

RDS for PostgreSQL - postgresql | upgrade

Please, make the check look for these engines too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

report.resource_tags = db_cluster.tags
if db_cluster.cloudwatch_logs:
report.status = "PASS"
report.status_extended = f"Aurora MySQL Cluster {db_cluster.id} is shipping {', '.join(db_cluster.cloudwatch_logs)} logs to CloudWatch Logs."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
report.status_extended = f"Aurora MySQL Cluster {db_cluster.id} is shipping {', '.join(db_cluster.cloudwatch_logs)} logs to CloudWatch Logs."
report.status_extended = f"RDS Cluster {db_cluster.id} is shipping {', '.join(db_cluster.cloudwatch_logs)} logs to CloudWatch Logs."

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

report.status_extended = f"Aurora MySQL Cluster {db_cluster.id} is shipping {', '.join(db_cluster.cloudwatch_logs)} logs to CloudWatch Logs."
else:
report.status = "FAIL"
report.status_extended = f"Aurora MySQL Cluster {db_cluster.id} does not have CloudWatch Logs enabled."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
report.status_extended = f"Aurora MySQL Cluster {db_cluster.id} does not have CloudWatch Logs enabled."
report.status_extended = f"RDS Cluster {db_cluster.id} does not have CloudWatch Logs enabled."

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

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.

👏🏼

@MrCloudSec MrCloudSec merged commit 0ae3374 into prowler-cloud:master Sep 11, 2024
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
provider/aws Issues/PRs related with the AWS provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants