-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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(fixer): add Prowler Fixer feature! #3634
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ca6506e
feat(fixer): add fixer flag
MrCloudSec 9d47288
solve comments
MrCloudSec 85078ee
Merge branch 'prowler-4.0-dev' into prowler-fixer
MrCloudSec 5e18a82
add changes to other PR
MrCloudSec 059ba69
solve comments
MrCloudSec eafc33f
Merge branch 'prowler-4.0-dev' into prowler-fixer
MrCloudSec aeae83b
solve comments
MrCloudSec cdd1a9b
exit when fixing
MrCloudSec 6fdec63
execute fix after scan
MrCloudSec 387ba70
solve comments
MrCloudSec 8c75b1a
clean code
MrCloudSec a7a4ce9
solve comments
MrCloudSec 37f5874
do not create outputs in fix and put verbose
MrCloudSec 170e301
add last changes
MrCloudSec d5518a9
fix other providers
MrCloudSec 2b6ec76
remove getattr
MrCloudSec 31e6108
Merge branch 'prowler-4.0-dev' into prowler-fixer
MrCloudSec 99fb615
final version
MrCloudSec e59245a
fixes
MrCloudSec 87949b6
fix test
MrCloudSec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...providers/aws/services/ec2/ec2_ebs_default_encryption/ec2_ebs_default_encryption_fixer.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from prowler.lib.logger import logger | ||
from prowler.providers.aws.services.ec2.ec2_client import ec2_client | ||
|
||
|
||
def fixer(region): | ||
""" | ||
Enable EBS encryption by default in a region. | ||
Requires the ec2:EnableEbsEncryptionByDefault permission: | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": "ec2:EnableEbsEncryptionByDefault", | ||
"Resource": "*" | ||
} | ||
] | ||
} | ||
Args: | ||
region (str): AWS region | ||
Returns: | ||
bool: True if EBS encryption by default is enabled, False otherwise | ||
""" | ||
try: | ||
regional_client = ec2_client.regional_clients[region] | ||
return regional_client.enable_ebs_encryption_by_default()[ | ||
"EbsEncryptionByDefault" | ||
] | ||
except Exception as error: | ||
logger.error( | ||
f"{region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}" | ||
) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If this needs to be done force the
verbose
to beTrue
if thefix
is set, I think is more than enough to have one argument to control the outputs.