From 5e681a7c17ed01c8d72bad5f7539dfb53046a6e4 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Tue, 9 Feb 2021 22:19:54 -0800 Subject: [PATCH] ui improvements, adding more tables/sorting options --- generate_report.py | 18 +++- template.html | 239 ++++++++++++++++++++++++++++++++------------- 2 files changed, 188 insertions(+), 69 deletions(-) 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 @@ - + - Jinja2 Template Example + + - - + + Prowler Scan Results + + +
-

Totals

-

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 }}

-

Findings

- - - - - - - - - - - - - - - - - {% for i in data %} - {% set d = data[i] %} - {% if d['result'] == 'PASS' %} - {% set color = 'green' %} - {% elif d['result'] == 'FAIL' %} - {% set color = 'red' %} - {% elif d['result'] == 'INFO' %} - {% set color = 'blue' %} - {% else %} - {% set color = 'white' %} - {% endif %} - - - - - - - - - - - - - {% endfor %} - -
Account IDRegionTitle IDTitle TextScoreResultNotesComplianceSeverityService 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'] }}
+

Prowler Scan Results

+
+

Summary

+
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 }}
+
+
+

Findings

+
+
+

+ +

+
+
+ + + + + + + + + + + + + + + {% for i in totals['fails'] %} + {% set d = data[i] %} + + + + + + + + + + + {% endfor %} + +
Account IDRegionIDTextNotesComplianceSeverityService Name
{{ d['account_id'] }}{{ d['region'] | truncate(12) }}{{ d['title_id'] }}{{ d['title_text'] }}{{ d['notes'] }}{{ d['compliance'] }}{{ d['severity'] }}{{ d['service_name'] }}
+
+
+
+
+

+ +

+
+
+ + + + + + + + + + + + + + + {% for i in totals['infos'] %} + {% set d = data[i] %} + + + + + + + + + + + {% endfor %} + +
Account IDRegionIDTextNotesComplianceSeverityService Name
{{ d['account_id'] }}{{ d['region'] | truncate(12) }}{{ d['title_id'] }}{{ d['title_text'] }}{{ d['notes'] }}{{ d['compliance'] }}{{ d['severity'] }}{{ d['service_name'] }}
+
+
+
+
+

+ +

+
+
+ + + + + + + + + + + + + + + {% for i in totals['passes'] %} + {% set d = data[i] %} + + + + + + + + + + + {% endfor %} + +
Account IDRegionIDTextNotesComplianceSeverityService Name
{{ d['account_id'] }}{{ d['region'] | truncate(12) }}{{ d['title_id'] }}{{ d['title_text'] }}{{ d['notes'] }}{{ d['compliance'] }}{{ d['severity'] }}{{ d['service_name'] }}
+
+
+
+
+
- - + +