6262 required = False ,
6363 default = False ,
6464 is_flag = True ,
65- help = "Reduce the size of the HTML Report by pulling the Cloudsplaining Javascript code over the internet."
65+ help = "Reduce the size of the HTML Report by pulling the Cloudsplaining Javascript code over the internet." ,
6666)
6767@click .option (
68- '--verbose' ,'-v' ,
69- type = click .Choice (['critical' , 'error' , 'warning' , 'info' , 'debug' ],
70- case_sensitive = False ))
68+ "--verbose" ,
69+ "-v" ,
70+ type = click .Choice (
71+ ["critical" , "error" , "warning" , "info" , "debug" ], case_sensitive = False
72+ ),
73+ )
7174# pylint: disable=redefined-builtin
7275def scan (
73- input_file , exclusions_file , output , skip_open_report , minimize , verbose ): # pragma: no cover
76+ input_file , exclusions_file , output , skip_open_report , minimize , verbose
77+ ): # pragma: no cover
7478 """
7579 Given the path to account authorization details files and the exclusions config file, scan all inline and
7680 managed policies in the account to identify actions that do not leverage resource constraints.
@@ -95,8 +99,12 @@ def scan(
9599 contents = f .read ()
96100 account_authorization_details_cfg = json .loads (contents )
97101 rendered_html_report = scan_account_authorization_details (
98- account_authorization_details_cfg , exclusions , account_name , output , write_data_files = True ,
99- minimize = minimize
102+ account_authorization_details_cfg ,
103+ exclusions ,
104+ account_name ,
105+ output ,
106+ write_data_files = True ,
107+ minimize = minimize ,
100108 )
101109 html_output_file = os .path .join (output , f"iam-report-{ account_name } .html" )
102110 logger .info ("Saving the report to %s" , html_output_file )
@@ -128,8 +136,12 @@ def scan(
128136 account_name = Path (file ).stem
129137 # Scan the Account Authorization Details config
130138 rendered_html_report = scan_account_authorization_details (
131- account_authorization_details_cfg , exclusions , account_name , output , write_data_files = True ,
132- minimize = minimize
139+ account_authorization_details_cfg ,
140+ exclusions ,
141+ account_name ,
142+ output ,
143+ write_data_files = True ,
144+ minimize = minimize ,
133145 )
134146 html_output_file = os .path .join (output , f"iam-report-{ account_name } .html" )
135147 logger .info ("Saving the report to %s" , html_output_file )
@@ -149,8 +161,12 @@ def scan(
149161
150162
151163def scan_account_authorization_details (
152- account_authorization_details_cfg , exclusions , account_name = "default" , output_directory = os .getcwd (),
153- write_data_files = False , minimize = False
164+ account_authorization_details_cfg ,
165+ exclusions ,
166+ account_name = "default" ,
167+ output_directory = os .getcwd (),
168+ write_data_files = False ,
169+ minimize = False ,
154170): # pragma: no cover
155171 """
156172 Given the path to account authorization details files and the exclusions config file, scan all inline and
@@ -162,7 +178,9 @@ def scan_account_authorization_details(
162178 "resource constraints..."
163179 )
164180 check_authorization_details_schema (account_authorization_details_cfg )
165- authorization_details = AuthorizationDetails (account_authorization_details_cfg , exclusions )
181+ authorization_details = AuthorizationDetails (
182+ account_authorization_details_cfg , exclusions
183+ )
166184 results = authorization_details .results
167185
168186 # Lazy method to get an account ID
@@ -176,7 +194,7 @@ def scan_account_authorization_details(
176194 account_id = account_id ,
177195 account_name = account_name ,
178196 results = results ,
179- minimize = minimize
197+ minimize = minimize ,
180198 )
181199 rendered_report = html_report .get_html_report ()
182200
@@ -185,11 +203,17 @@ def scan_account_authorization_details(
185203 if output_directory is None :
186204 output_directory = os .getcwd ()
187205
188- results_data_file = os .path .join (output_directory , f"iam-results-{ account_name } .json" )
189- results_data_filepath = write_results_data_file (authorization_details .results , results_data_file )
206+ results_data_file = os .path .join (
207+ output_directory , f"iam-results-{ account_name } .json"
208+ )
209+ results_data_filepath = write_results_data_file (
210+ authorization_details .results , results_data_file
211+ )
190212 print (f"Results data saved: { str (results_data_filepath )} " )
191213
192- findings_data_file = os .path .join (output_directory , f"iam-findings-{ account_name } .json" )
214+ findings_data_file = os .path .join (
215+ output_directory , f"iam-findings-{ account_name } .json"
216+ )
193217 findings_data_filepath = write_results_data_file (results , findings_data_file )
194218 print (f"Findings data file saved: { str (findings_data_filepath )} " )
195219
0 commit comments