From 0ea289e2ce4c8f68a8ba3f9987a365d0aa5683ba Mon Sep 17 00:00:00 2001 From: Tyler Ramsbey <86263907+TeneBrae93@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:06:16 -0500 Subject: [PATCH] Fixes "cloudformation__download_data" module Fixes "cloudformation__download_data" module so it properly uses the "--region" flag when passed by the user. --- pacu/modules/cloudformation__download_data/main.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pacu/modules/cloudformation__download_data/main.py b/pacu/modules/cloudformation__download_data/main.py index c8500322..b8af5c1a 100755 --- a/pacu/modules/cloudformation__download_data/main.py +++ b/pacu/modules/cloudformation__download_data/main.py @@ -25,14 +25,24 @@ parser = argparse.ArgumentParser(add_help=False, description=(module_info['description'])) -parser.add_argument('--regions', required=False, default=None, help='One or more (comma separated) AWS regions in the format ' +parser.add_argument('--regions', required=False, default=None, help='One or more comma-separated AWS regions in the format ' 'us-east-1. Defaults to all regions.') def main(args, pacu_main): + # Parse the arguments using argparse + args = parser.parse_args(args) + session = pacu_main.get_active_session() print = pacu_main.print get_regions = pacu_main.get_regions - regions = get_regions('cloudformation') + + # Fixing the code so it accepts the regions flag without scanning all regions + if args.regions: + # Process the regions provided by the user + regions = [region.strip() for region in args.regions.split(',')] + else: + # Use all regions if none are specified + regions = get_regions('cloudformation') def find_secrets(string): detections = regex_checker(string)