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(rds): add new check rds_instance_inside_vpc #5029

Conversation

danibarranqueroo
Copy link
Member

@danibarranqueroo danibarranqueroo commented Sep 13, 2024

Context

Implemented a check to ensure that Amazon RDS instances are deployed within a Virtual Private Cloud (VPC). This check helps enhance security and network isolation by verifying that RDS instances are not publicly accessible and are properly integrated within a VPC for controlled access.

The way to know if an instance is deployed in a VPC comes across the DBSubnetGroup parameter of the Amazon RDS API, it allows to know if an instance is within a VPC, as this group defines the subnets within a VPC where an RDS instance can be deployed. If the field is present, the instance is in a VPC, and if it's absent, the instance is likely in EC2-Classic.

Another problem that came up during testing of the check is that AWS no longer allows creating an instance outside of a VPC. So, this check would only be useful for verifying old RDS instances, but all new ones will be in a VPC.

This issue also affects the unit test to verify instances not in a VPC because neither boto nor Moto allows me to create an instance outside of a VPC or in the old EC2-Classic environment. Therefore, this unit test needs to be mocked using MagicMock.

Description

Added new check rds_instance_inside_vpc 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.

@danibarranqueroo danibarranqueroo requested review from a team as code owners September 13, 2024 10:10
@github-actions github-actions bot added the provider/aws Issues/PRs related with the AWS provider label Sep 13, 2024
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.95%. Comparing base (1298620) to head (e301a29).
Report is 1245 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5029      +/-   ##
==========================================
+ Coverage   88.90%   88.95%   +0.05%     
==========================================
  Files         946      958      +12     
  Lines       29061    29360     +299     
==========================================
+ Hits        25837    26118     +281     
- Misses       3224     3242      +18     
Components Coverage Δ
prowler 88.95% <87.50%> (+0.05%) ⬆️
api ∅ <ø> (∅)

@MrCloudSec MrCloudSec changed the title feat(rds): add new check rds_instance_in_vpc feat(rds): add new check rds_instance_inside_vpc Sep 13, 2024
@MrCloudSec MrCloudSec self-requested a review September 13, 2024 15:27
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 job! Please, see my changes to the code, you have to make sure that the check is working as expected. The db_subnet_group variable was never empty since you were always adding the keys name and vpc_id making the check to always reporting a PASS.

@MrCloudSec MrCloudSec merged commit f54b64f into prowler-cloud:master Sep 16, 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