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

Enhance SecurityHub Automation Rule Listing and Saving Script #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sam-fakhreddine
Copy link

This change request introduces significant improvements to the script used for listing and saving AWS SecurityHub automation rules across regions. The modified script not only lists the rules but also provides an option to save these rules as JSON files. Additionally, it includes error handling improvements and utilizes a custom Boto3 configuration for adaptive retry strategies.

Changes

  • Custom Boto3 Config: Introduced a custom configuration for Boto3 with an adaptive retry strategy to handle API rate limits and network issues more effectively.
  • Extended Argument Parsing: Added a new command-line argument --save-rules-json to enable the saving of rules as JSON files.
  • Rule Saving Functionality: Implemented a new function save_rule_to_json that takes a rule name, its data, and region to save the rule as a JSON file in the current directory.
  • Enhanced Rule Retrieval Logic: Modified the loop for listing automation rules to handle pagination correctly, ensuring all rules are retrieved even when they exceed the single request limit.
  • Full Rule Definitions Retrieval: Added functionality to fetch full definitions of each automation rule using the batch_get_automation_rules method and the list of rule ARNs.
  • Rule Definition Saving: Integrated the rule saving functionality within the main loop, allowing for each rule's full definition to be saved if the --save-rules-json flag is set.
  • Improved Error Handling: Enhanced error handling with more descriptive messages, especially for regional processing errors.

Benefits

  • Enhanced Functionality: Users can now not only list but also save the rule definitions, aiding in configuration management and documentation.
  • Improved Robustness: Custom Boto3 configuration and better error handling make the script more reliable in various network and API conditions.
  • Efficient Data Retrieval: Pagination handling ensures comprehensive data retrieval without missing any rules due to API response limits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant