-
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 RDS instances are not using default database engine ports #4973
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4973 +/- ##
==========================================
+ Coverage 89.05% 89.10% +0.04%
==========================================
Files 968 969 +1
Lines 29618 29642 +24
==========================================
+ Hits 26376 26412 +36
+ Misses 3242 3230 -12 ☔ View full report in Codecov by Sentry. |
@@ -0,0 +1,32 @@ | |||
{ | |||
"Provider": "aws", | |||
"CheckID": "rds_instance_not_default_port", |
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.
"CheckID": "rds_instance_not_default_port", | |
"CheckID": "rds_instance_non_default_port", |
"CheckID": "rds_instance_not_default_port", | ||
"CheckTitle": "Check if RDS instances are using non-default ports.", | ||
"CheckType": [ | ||
"Software and Configuration Checks, AWS Security Best Practices" |
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.
"Software and Configuration Checks, AWS Security Best Practices" | |
"Software and Configuration Checks", "AWS Security Best Practices" |
if check_security_group( | ||
ingress_rule, | ||
"tcp", | ||
[db_instance.port], | ||
any_address=True, | ||
): |
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.
This will only check if the port is public, not if it can be accessed by an IP address, is that what we want?
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.
I would only check the ports for each instance in db_instance.port
.
class rds_instance_not_default_port(Check): | ||
def execute(self): | ||
findings = [] | ||
default_ports = { |
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.
Where did you get this list from?
Context
This new check verifies if an instance uses a port other than the default port of the database engine. The control fails if the RDS instance uses the default port or a non-default port that is not configured in the security group.
Since RDS instances belong to VPC Security Groups, which are managed by EC2, I've used this service to iterate over all the security groups and verify if an instance belongs to any of them. If so, I've checked that the security group has the port that the instance is listening to open. With this implementation, I can verify that if the instance uses a non-default port, it's configured correctly in the security group.
Description
Added
rds_instance_not_default_port
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.