diff --git a/.gitignore b/.gitignore index 58e4800..957da38 100644 --- a/.gitignore +++ b/.gitignore @@ -131,3 +131,4 @@ dmypy.json # Dont store CSV files or reports *.csv report.html +*.json diff --git a/generate_report.py b/generate_report.py index aede838..44c57cb 100644 --- a/generate_report.py +++ b/generate_report.py @@ -16,6 +16,7 @@ def run(): 'passes_by_sev': {}, 'fails_by_sev': {}, 'infos_by_sev': {}, + 'results_by_check_id': {} } with open('template.html') as f: @@ -43,6 +44,18 @@ def run(): d = csv_data[idx] t = totals + # Capture results summary + rs = 'results_summary' + rl = d['result'].lower() + if rs not in totals: + t[rs] = dict() + if rl not in t[rs]: + t[rs][rl] = list() + t[rs][rl].append(d) + + if d['title_id'] not in t['results_by_check_id']: + t['results_by_check_id'][d['title_id']] = csv_data[idx] + if d['account_id'] not in t['accounts']: t['accounts'].append(d['account_id']) @@ -51,19 +64,16 @@ def run(): t['scan_results'].append(idx) - if d['result'] == 'PASS': - t['passes'].append(idx) - elif d['result'] == 'FAIL': - t['fails'].append(idx) - elif d['result'] == 'INFO': - t['infos'].append(idx) - 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) + # list(OrderedDict.fromkeys([x['severity'].lower() for x in data.values() if x['severity'].lower()])) + + # print(totals['results_summary']) + tpl = Template(tpl) rendered = tpl.render(data=csv_data, totals=totals) diff --git a/template.html b/template.html index 8957369..50ba42c 100644 --- a/template.html +++ b/template.html @@ -13,14 +13,17 @@ padding-top: 80px; max-width: 1400px; } - .bg-green { - background-color: rgba(102,178,102,.2); + .b-pass, .b-pass:focus, .b-pass:active { + color: black; + background-color: rgba(102,178,102,.2) !important; } - .bg-red { - background-color: rgba(255,76,76,.2); + .b-fail, .b-fail:focus, .b-fail:active { + color: black; + background-color: rgba(255,76,76,.2) !important; } - .bg-blue { - background-color: rgba(127,127,255,.2); + .b-info, .b-info:focus, .b-info:active { + color: black; + background-color: rgba(128,163,221,.2) !important; } .totals { display: inline-block; @@ -47,18 +50,14 @@