{#
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 %}{{ row.token }} — {% endif %}
{% if row.kind == "severity" %}
{{ row.value }}
{% elif row.kind == "mono" %}
{{ row.value }}
{% else %}
{{ row.value }}
{% endif %}
{% endmacro %}
{% macro facts(rows, wide=false) %}
{% for row in rows %}
| {{ row.label }}: |
{{ value(row) }} |
{% endfor %}
{% 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. #}
{{ title }}
{% for row in rows %}
| {{ row.label }} |
{{ value(row) }} |
{% endfor %}
{% if note %}
{{ note }}
{% endif %}
{% 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. #}
{% for row in rows %}
| {{ row.label }} |
{{ row.count }} |
{% for part in row.parts %}
{% endfor %}
|
{% endfor %}
{% for item in legend.entries %}
{{ item.label }}
{% endfor %}
{% if legend.caveat %}— {{ legend.caveat }}{% endif %}
{% endmacro %}
{% macro grid(table) %}
{% for column in table.columns %}| {{ column }} | {% endfor %}
{% for row in table.rows %}
{% for cell in row.cells %}
| {% if cell is mapping %}{{ value(cell) }}{% else %}{{ cell }}{% endif %} |
{% endfor %}
{% endfor %}
{% endmacro %}
{# ------------------------------------------------------------------------------------------ #}
{{ cover.title }}
{{ facts(cover.identity) }}
{% if cover.severity_ledger %}
{{ cover.severity_ledger.title }}
{% for row in cover.severity_ledger.rows %}
| {{ row.label }} |
{{ row.count }} |
{% endfor %}
{% endif %}
{% if contents %}
Table of Contents
{% for entry in contents %}
- {{ entry.title }}
{% endfor %}
{% endif %}
{% if project %}
{{ project.title }}
{{ facts(project.overview, wide=true) }}
{% if project.languages %}
{{ project.languages.title }}
{% for row in project.languages.rows %}
| {{ row.label }} |
{{ row.share }} |
{% endfor %}
{% endif %}
{% endif %}
{% if summary %}
{{ summary.title }}
{{ facts(summary.overview, wide=true) }}
{% for block in summary.distributions %}
{{ block.title }}
{{ distribution(block.rows, block.legend) }}
{% endfor %}
{% for metric in summary.metrics or [] %}
{{ card(metric.title, metric.rows, metric.note) }}
{% endfor %}
{% endif %}
{% if critical %}
{{ critical.title }}
{{ grid(critical.table) }}
{% endif %}
{% for section in sections %}
{{ section.title }}
{% for group in section.groups %}
{{ group.title }}
{% if group.note %}{{ group.note }}
{% endif %}
{% for entry in group.cards %}
{{ card(entry.title, entry.rows) }}
{% endfor %}
{% if group.table %}
{% if group.table.title %}{{ group.table.title }}
{% endif %}
{{ grid(group.table) }}
{% endif %}
{% endfor %}
{% endfor %}