186 lines
5.9 KiB
Django/Jinja
186 lines
5.9 KiB
Django/Jinja
{#
|
|
The SAST/SCA report, after the design sample in `sample_report_template/`.
|
|
|
|
This file places content and nothing else: every dimension, colour and rule lives in `report.css`.
|
|
Each section is guarded by the data it needs, so a report of a scan that ran half the pipeline is
|
|
the same document with fewer sections rather than a document full of empty tables.
|
|
|
|
The context this expects is described by `layout.CONTEXT`, and `sample.sample_context()` builds a
|
|
complete one.
|
|
#}
|
|
{# A value is drawn by what it is, not by where it sits: an identifier, a path or a CVSS vector is
|
|
set in the monospace face wherever it appears, and a severity carries its colour. #}
|
|
{% macro value(row) %}
|
|
{% if row.token %}<span class="token">{{ row.token }}</span> — {% endif %}
|
|
{% if row.kind == "severity" %}
|
|
<span class="sev sev-{{ row.value|lower }}">{{ row.value }}</span>
|
|
{% elif row.kind == "mono" %}
|
|
<span class="mono">{{ row.value }}</span>
|
|
{% else %}
|
|
{{ row.value }}
|
|
{% endif %}
|
|
{% endmacro %}
|
|
|
|
{% macro facts(rows, wide=false) %}
|
|
<table class="facts{% if wide %} wide{% endif %}">
|
|
{% for row in rows %}
|
|
<tr{% if row.gap %} class="gap"{% endif %}>
|
|
<td>{{ row.label }}:</td>
|
|
<td>{{ value(row) }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
{% endmacro %}
|
|
|
|
{% macro card(title, rows, note="") %}
|
|
{# Wrapped, because break-inside on the table does not hold its caption: the title would stay on
|
|
one page while the rows it titles moved to the next. #}
|
|
<div class="block">
|
|
<table class="card">
|
|
<caption>{{ title }}</caption>
|
|
{% for row in rows %}
|
|
<tr{% if row.aside %} class="aside"{% endif %}>
|
|
<th>{{ row.label }}</th>
|
|
<td>{{ value(row) }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
{% if note %}<p class="note card-note">{{ note }}</p>{% endif %}
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{# Scaled against the busiest row, not against the total: what is read off a row of these is which
|
|
one is the outlier, and a scale set by the sum flattens all of them. #}
|
|
{% macro distribution(rows, legend) %}
|
|
{# The bars and the legend that decodes them are one thing; a break between them leaves a reader
|
|
with coloured segments and no key. #}
|
|
<div class="block">
|
|
<table class="bars">
|
|
{% for row in rows %}
|
|
<tr>
|
|
<td{% if row.mono %} class="mono"{% endif %}>{{ row.label }}</td>
|
|
<td class="count">{{ row.count }}</td>
|
|
<td class="track">
|
|
<div class="bar">
|
|
{% for part in row.parts %}
|
|
<span class="seg-{{ part.severity|lower }}" style="width: {{ part.share }}%"></span>
|
|
{% endfor %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
<div class="legend">
|
|
{% for item in legend.entries %}
|
|
<span class="item"><span class="key seg-{{ item.severity|lower }}"></span>{{ item.label }}</span>
|
|
{% endfor %}
|
|
{% if legend.caveat %}<span class="caveat">— {{ legend.caveat }}</span>{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endmacro %}
|
|
|
|
{% macro grid(table) %}
|
|
<table class="grid">
|
|
<thead>
|
|
<tr>{% for column in table.columns %}<th>{{ column }}</th>{% endfor %}</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for row in table.rows %}
|
|
<tr{% if row.total %} class="total"{% endif %}>
|
|
{% for cell in row.cells %}
|
|
<td>{% if cell is mapping %}{{ value(cell) }}{% else %}{{ cell }}{% endif %}</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
{% endmacro %}
|
|
|
|
{# ------------------------------------------------------------------------------------------ #}
|
|
|
|
<span class="footer-scan">Scan: {{ cover.scan_id }}</span>
|
|
<span class="footer-date">{{ cover.footer_date }}</span>
|
|
|
|
<div class="cover-mark">
|
|
<img src="{{ cover.logo }}" alt="CipherCell" />
|
|
</div>
|
|
|
|
<div class="cover-title">{{ cover.title }}</div>
|
|
|
|
{{ facts(cover.identity) }}
|
|
|
|
{% if cover.severity_ledger %}
|
|
<h2>{{ cover.severity_ledger.title }}</h2>
|
|
<table class="ledger">
|
|
{% for row in cover.severity_ledger.rows %}
|
|
<tr{% if row.total %} class="total"{% endif %}>
|
|
<td>{{ row.label }}</td>
|
|
<td>{{ row.count }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
{% endif %}
|
|
|
|
{% if contents %}
|
|
<h1 style="break-before: page">Table of Contents</h1>
|
|
<ol class="toc">
|
|
{% for entry in contents %}
|
|
<li><a href="#{{ entry.id }}">{{ entry.title }}</a></li>
|
|
{% endfor %}
|
|
</ol>
|
|
{% endif %}
|
|
|
|
{% if project %}
|
|
<h1 id="{{ project.id }}" style="break-before: page">{{ project.title }}</h1>
|
|
{{ facts(project.overview, wide=true) }}
|
|
|
|
{% if project.languages %}
|
|
<h2>{{ project.languages.title }}</h2>
|
|
<table class="ledger">
|
|
{% for row in project.languages.rows %}
|
|
<tr{% if row.total %} class="total"{% endif %}>
|
|
<td>{{ row.label }}</td>
|
|
<td>{{ row.share }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</table>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% if summary %}
|
|
<h1 id="{{ summary.id }}"{% if not project %} style="break-before: page"{% endif %}>{{ summary.title }}</h1>
|
|
{{ facts(summary.overview, wide=true) }}
|
|
|
|
{% for block in summary.distributions %}
|
|
<h2>{{ block.title }}</h2>
|
|
{{ distribution(block.rows, block.legend) }}
|
|
{% endfor %}
|
|
|
|
{% for metric in summary.metrics or [] %}
|
|
{{ card(metric.title, metric.rows, metric.note) }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% if critical %}
|
|
<h2 id="{{ critical.id }}" style="break-before: page">{{ critical.title }}</h2>
|
|
{{ grid(critical.table) }}
|
|
{% endif %}
|
|
|
|
{% for section in sections %}
|
|
<h1{% if section.id %} id="{{ section.id }}"{% endif %}{% if section.new_page %} style="break-before: page"{% endif %}>{{ section.title }}</h1>
|
|
|
|
{% for group in section.groups %}
|
|
<h2>{{ group.title }}</h2>
|
|
{% if group.note %}<p class="note">{{ group.note }}</p>{% endif %}
|
|
|
|
{% for entry in group.cards %}
|
|
{{ card(entry.title, entry.rows) }}
|
|
{% endfor %}
|
|
|
|
{% if group.table %}
|
|
{% if group.table.title %}<h2>{{ group.table.title }}</h2>{% endif %}
|
|
{{ grid(group.table) }}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endfor %}
|