-
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
chore(fixer): improve fixer logic and include more #3750
Conversation
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
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.
Thats a great improvement @sergargar !!! 👏
Please review my comments and add tests for all the new included fixers, thanks!
``` | ||
|
||
## Writing a Fixer | ||
To write a fixer, you need to create a file called `<check_id>_fixer.py` inside the check folder, with a function called `fixer` that receives either the region or the resource to be fixed as a parameter, and returns a boolean value indicating if the fix was successful or not. |
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.
What if the fixer needs the region
and the resource_id
?
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.
It is not contemplated, but good point...
@@ -462,15 +468,18 @@ def run_check(check: Check, output_options) -> list: | |||
return findings | |||
|
|||
|
|||
def run_fixer(check_findings: list): | |||
def run_fixer(check_findings: list) -> int: |
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.
Do we have tests for this function? If not please add some.
fixed_findings += 1 | ||
print(f"\t{Fore.GREEN}DONE{Style.RESET_ALL}") | ||
else: | ||
print(f"\t{Fore.RED}ERROR{Style.RESET_ALL}") |
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.
Can you move this to a function not to repeat it? Something like print_fixer_result
.
...er/providers/aws/services/iam/iam_password_policy_number/iam_password_policy_number_fixer.py
Show resolved
Hide resolved
...roviders/aws/services/iam/iam_password_policy_reuse_24/iam_password_policy_reuse_24_fixer.py
Show resolved
Hide resolved
...er/providers/aws/services/iam/iam_password_policy_symbol/iam_password_policy_symbol_fixer.py
Show resolved
Hide resolved
...viders/aws/services/iam/iam_password_policy_uppercase/iam_password_policy_uppercase_fixer.py
Show resolved
Hide resolved
bool: True if S3 Block Public Access is enabled, False otherwise | ||
""" | ||
try: | ||
s3control_client.client.put_public_access_block( |
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.
Please add a test for this function.
You can check the documentation for this PR here -> SaaS Documentation |
Co-authored-by: Pepe Fagoaga <[email protected]>
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
...within_90_days_or_less/iam_password_policy_expires_passwords_within_90_days_or_less_fixer.py
Outdated
Show resolved
Hide resolved
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
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.
Awesome! Thanks for taking care of the comments 🚀
Co-authored-by: sergargar <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pepe Fagoaga <[email protected]>
Co-authored-by: pedrooot <[email protected]>
…er guide (#3749) Co-authored-by: Pepe Fagoaga <[email protected]>
Co-authored-by: sergargar <[email protected]>
…#3756) Co-authored-by: Pepe Fagoaga <[email protected]>
Co-authored-by: Pepe Fagoaga <[email protected]>
You can check the documentation for this PR here -> SaaS Documentation |
You can check the documentation for this PR here -> SaaS Documentation |
@@ -1,3 +1,5 @@ | |||
# TODO: UPDATE YAML |
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.
What is this?
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.
To update the config yaml with the latest changes, meaning that we have to update the tests.
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 didn't saw that it was the fixtures one, thanks!
Description
• Add 8 fixers
• Add fixer config file among
--config-fixer
flag.• Improve fixer execution
• Add documentation
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.