-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
def execute(self): | ||
findings = [] | ||
for db_cluster_arn, db_cluster in rds_client.db_clusters.items(): | ||
if db_cluster.engine == "aurora-mysql": |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏼
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.