adding code so far
parent
08aeef9d1c
commit
e572f4056e
@ -1,2 +1,20 @@
|
||||
# prowler-report
|
||||
Quick prototype for rendering Prowler scan CSV exports in pretty HTML
|
||||
|
||||
## Setup
|
||||
|
||||
```
|
||||
git clone https://github.com/lalanza808/prowler-report
|
||||
cd prowler-report
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
## Running
|
||||
|
||||
I've hardcoded paths for now. Make sure your CSV export is stored in this directory as "prowler-test.csv"
|
||||
|
||||
```
|
||||
.venv/bin/python generate_report.py
|
||||
```
|
||||
|
@ -0,0 +1,39 @@
|
||||
from jinja2 import Template
|
||||
from os import path
|
||||
from csv import reader
|
||||
|
||||
|
||||
def run():
|
||||
csv_data = {}
|
||||
|
||||
with open('template.html') as f:
|
||||
tpl = f.read()
|
||||
|
||||
with open('prowler-test.csv') as csv_file:
|
||||
csv_reader = reader(csv_file, delimiter=',')
|
||||
for idx, row in enumerate(csv_reader):
|
||||
csv_data[idx] = {
|
||||
'profile': row[0],
|
||||
'account_id': row[1],
|
||||
'region': row[2],
|
||||
'title_id': row[3],
|
||||
'result': row[4],
|
||||
'scored': row[5],
|
||||
'level': row[6],
|
||||
'title_text': row[7],
|
||||
'notes': row[8],
|
||||
'compliance': row[9],
|
||||
'severity': row[10],
|
||||
'service_name': row[11],
|
||||
}
|
||||
|
||||
t = Template(tpl)
|
||||
rendered = t.render(data=csv_data)
|
||||
|
||||
with open('report.html', 'w') as f:
|
||||
f.write(rendered)
|
||||
print('Generated report as "report.html"')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
@ -0,0 +1 @@
|
||||
jinja2
|
@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Jinja2 Template Example</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||
<style type="text/css">
|
||||
.container {
|
||||
max-width: 500px;
|
||||
padding-top: 100px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<p>Loop through the list:</p>
|
||||
<ul>
|
||||
{% for i in data %}
|
||||
{% set d = data[i] %}
|
||||
<li>{{ d['account_id'] }} - {{ d['title_id'] }} - {{ d['region'] }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
||||
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue