62
62
required = False ,
63
63
default = False ,
64
64
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." ,
66
66
)
67
67
@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
+ )
71
74
# pylint: disable=redefined-builtin
72
75
def 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
74
78
"""
75
79
Given the path to account authorization details files and the exclusions config file, scan all inline and
76
80
managed policies in the account to identify actions that do not leverage resource constraints.
@@ -95,8 +99,12 @@ def scan(
95
99
contents = f .read ()
96
100
account_authorization_details_cfg = json .loads (contents )
97
101
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 ,
100
108
)
101
109
html_output_file = os .path .join (output , f"iam-report-{ account_name } .html" )
102
110
logger .info ("Saving the report to %s" , html_output_file )
@@ -128,8 +136,12 @@ def scan(
128
136
account_name = Path (file ).stem
129
137
# Scan the Account Authorization Details config
130
138
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 ,
133
145
)
134
146
html_output_file = os .path .join (output , f"iam-report-{ account_name } .html" )
135
147
logger .info ("Saving the report to %s" , html_output_file )
@@ -149,8 +161,12 @@ def scan(
149
161
150
162
151
163
def 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 ,
154
170
): # pragma: no cover
155
171
"""
156
172
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(
162
178
"resource constraints..."
163
179
)
164
180
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
+ )
166
184
results = authorization_details .results
167
185
168
186
# Lazy method to get an account ID
@@ -176,7 +194,7 @@ def scan_account_authorization_details(
176
194
account_id = account_id ,
177
195
account_name = account_name ,
178
196
results = results ,
179
- minimize = minimize
197
+ minimize = minimize ,
180
198
)
181
199
rendered_report = html_report .get_html_report ()
182
200
@@ -185,11 +203,17 @@ def scan_account_authorization_details(
185
203
if output_directory is None :
186
204
output_directory = os .getcwd ()
187
205
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
+ )
190
212
print (f"Results data saved: { str (results_data_filepath )} " )
191
213
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
+ )
193
217
findings_data_filepath = write_results_data_file (results , findings_data_file )
194
218
print (f"Findings data file saved: { str (findings_data_filepath )} " )
195
219
0 commit comments