{#- Small shared pieces: icons, badges, buttons. Every coloured badge carries a word; every value is autoescaped. -#} {% macro icon(name, cls="ico") %}{% endmacro %} {% macro lvl(level) -%} {%- set l = (level or '')|lower -%} {%- if l in ('critical', 'high', 'medium', 'low', 'informational') -%}{{ l }}{%- endif -%} {%- endmacro %} {% macro st(status) -%} {%- set s = (status or '')|lower -%} {%- if s -%}{{ s }}{%- endif -%} {%- endmacro %} {% macro lic(info) -%} {{ info.label }} {%- endmacro %} {% macro lic_class(cls) -%} {{ LIC_WORDS.get(cls, cls) }} {%- endmacro %} {% macro val(v, show_ok=false) -%} {%- if v == 'ok' and show_ok %}{{ icon('check') }}valid {%- elif v == 'warning' %}warnings {%- elif v == 'error' %}invalid {%- elif not v and show_ok %}not validated{% endif -%} {%- endmacro %} {% macro tech(tid, title='') -%} {{ tid }} {%- endmacro %} {% macro when(dt) -%} {%- if dt %}{% else %}never{% endif -%} {%- endmacro %} {% macro copy_btn(target, label="Copy", cls="btn btn-sm") -%} {%- endmacro %} {% macro cmd(id, command) -%}
{{ command }}{{ copy_btn('#' ~ id) }}
{%- endmacro %} {% macro crumbs(items) -%}
    {% for label, href in items %}{% if href %}{{ label }}{% else %}{{ label }}{% endif %}{% endfor %}
{%- endmacro %} {% macro logsource(g) -%} {{ [g.product, g.category, g.service]|select|join(' / ') or 'any log source' }} {%- endmacro %} {#- One cell per installed backend; the class names are fixed, never built from rule data. -#} {% macro strip(g) -%} {%- set statuses = conv_statuses(g) -%} {#- Nothing converted yet (queries are converted on demand): a row of grey cells says nothing, so show none. -#} {%- if statuses -%} {%- for b in backends %}{% set x = statuses.get(b, '') %}{% endfor -%} {%- endif -%} {%- endmacro %} {% macro pager(page, pages, href) -%} {% if pages > 1 %} {% endif %} {%- endmacro %} {#- A search result card (search, changes, source pages). r: a row from web.cards. -#} {% macro card(r, terms=[], selectable=true) -%}
  • {% if selectable %}{% else %}{% endif %} {{ r.title|mark(terms) if r.title else '(untitled)' }}
    {{ lvl(r.level) }}{{ lic(r.licence) }}
    {% if r.description %}

    {{ r.description|mark(terms) }}

    {% endif %}
    {{ logsource(r) }}{{ st(r.status) }} {%- if r.techniques %}{% for tid, name in r.techniques[:3] %}{{ tech(tid, name) }}{% endfor %}{% if r.techniques|length > 3 %}+{{ r.techniques|length - 3 }}{% endif %}{% endif %} {{ r.copies }} {{ 'copy' if r.copies == 1 else 'copies' }} · {{ r.n_sources }} {{ 'source' if r.n_sources == 1 else 'sources' }} from {{ r.canonical_source }} {%- if r.family_size > 1 %}{{ r.family_size }} variants{% endif %} {{ val(r.validation) }} {%- if backends %}{{ strip(r) }}{% endif %}
    {%- if caller is defined %}
    {{ caller() }}
    {% endif %}
  • {%- endmacro %} {#- Overview charts (shared with suriharvest). ages: present.age_chart; t: present.spark. SVG geometry only, no inline style. -#} {% macro age_chart(ages, noun='rules') -%}
    Last changed {{ ages.share }}% of the {{ noun }} in the last 12 months
    {%- for c in ages.cols %}{{ c.label }}: {{ c.n|num }} {{ noun if c.n != 1 else noun[:-1] }}{% endfor %}
    {% if ages.unknown %}

    {{ ages.unknown|num }} {{ noun ~ ' carry' if ages.unknown != 1 else noun[:-1] ~ ' carries' }} no date.

    {% endif %}
    {%- endmacro %} {% macro spark(t, label) -%} {%- if t %}{{ label }}{% endif -%} {%- endmacro %} {#- A 100% bar of the corpus split by one dimension (level, severity); parts: present.composition. -#} {% macro composition(parts, caption) -%} {%- if parts %}

    {{ caption }}

    {% endif -%} {%- endmacro %}