diff --git a/generate_report.py b/generate_report.py index b22a1e8..c94ec71 100644 --- a/generate_report.py +++ b/generate_report.py @@ -11,7 +11,11 @@ def run(): 'scan_results': [], 'passes': [], 'fails': [], - 'infos': [] + 'infos': [], + 'all_by_sev': {}, + 'passes_by_sev': {}, + 'fails_by_sev': {}, + 'infos_by_sev': {}, } with open('template.html') as f: @@ -39,6 +43,8 @@ def run(): d = csv_data[idx] t = totals + + if d['account_id'] not in t['accounts']: t['accounts'].append(d['account_id']) @@ -54,8 +60,14 @@ def run(): elif d['result'] == 'INFO': t['infos'].append(idx) - t = Template(tpl) - rendered = t.render(data=csv_data, totals=totals) + l = d['severity'].lower() + if l not in t['all_by_sev']: + t['all_by_sev'][l] = list() + if idx not in t['all_by_sev'][l]: + t['all_by_sev'][l].append(idx) + + tpl = Template(tpl) + rendered = tpl.render(data=csv_data, totals=totals) with open('report.html', 'w') as f: f.write(rendered) diff --git a/template.html b/template.html index c60e585..0cb1e46 100644 --- a/template.html +++ b/template.html @@ -1,76 +1,183 @@ - +
-Accounts: {{ totals['accounts'] | length }}
-Regions: {{ totals['regions'] | length }}
-Total Scans: {{ totals['scan_results'] | length }}
-Passes: {{ totals['passes'] | length }}
-Fails: {{ totals['fails'] | length }}
-Infos: {{ totals['infos'] | length }}
-Account ID | -Region | -Title ID | -Title Text | -Score | -Result | -Notes | -Compliance | -Severity | -Service Name | -
---|---|---|---|---|---|---|---|---|---|
{{ d['account_id'] }} | -{{ d['region'] }} | -{{ d['title_id'] }} | -{{ d['title_text'] }} | -{{ d['scored'] }} | -{{ d['result'] }} | -{{ d['notes'] }} | -{{ d['compliance'] }} | -{{ d['severity'] }} | -{{ d['service_name'] }} | -
Account ID | +Region | +ID | +Text | +Notes | +Compliance | +Severity | +Service Name | +
---|---|---|---|---|---|---|---|
{{ d['account_id'] }} | +{{ d['region'] | truncate(12) }} | +{{ d['title_id'] }} | +{{ d['title_text'] }} | +{{ d['notes'] }} | +{{ d['compliance'] }} | +{{ d['severity'] }} | +{{ d['service_name'] }} | +
Account ID | +Region | +ID | +Text | +Notes | +Compliance | +Severity | +Service Name | +
---|---|---|---|---|---|---|---|
{{ d['account_id'] }} | +{{ d['region'] | truncate(12) }} | +{{ d['title_id'] }} | +{{ d['title_text'] }} | +{{ d['notes'] }} | +{{ d['compliance'] }} | +{{ d['severity'] }} | +{{ d['service_name'] }} | +
Account ID | +Region | +ID | +Text | +Notes | +Compliance | +Severity | +Service Name | +
---|---|---|---|---|---|---|---|
{{ d['account_id'] }} | +{{ d['region'] | truncate(12) }} | +{{ d['title_id'] }} | +{{ d['title_text'] }} | +{{ d['notes'] }} | +{{ d['compliance'] }} | +{{ d['severity'] }} | +{{ d['service_name'] }} | +