From bcf48eebe86863e58f15dc0a4bc0003b7954e11d Mon Sep 17 00:00:00 2001 From: arobbins Date: Mon, 8 Jul 2024 10:26:09 -0400 Subject: [PATCH 1/2] create pages for techniques without mappings --- src/mappings_explorer/site_builder.py | 19 +++++++++++++++++++ .../templates/macros.html.j2 | 11 ++++++++++- .../templates/technique.html.j2 | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/mappings_explorer/site_builder.py b/src/mappings_explorer/site_builder.py index 76003144..bd6b4e27 100644 --- a/src/mappings_explorer/site_builder.py +++ b/src/mappings_explorer/site_builder.py @@ -1364,6 +1364,25 @@ def build_attack_pages(projects: list, url_prefix: str, breadcrumbs: list): breadcrumbs=breadcrumbs, non_mappables=non_mappables, ) + # Build technique pages that don't have mappings to fix any linking errors + for technique in non_mappables: + external_dir = ( + PUBLIC_DIR + / "attack" + / ("attack-" + attack_version) + / ("domain-" + attack_domain.lower()) + / "techniques" + ) + + if technique.id: + build_technique_page( + url_prefix=url_prefix, + parent_dir=external_dir, + attack_version=attack_version, + attack_domain=attack_domain, + technique=technique, + breadcrumbs=breadcrumbs, + ) for technique in all_techniques: external_dir = ( diff --git a/src/mappings_explorer/templates/macros.html.j2 b/src/mappings_explorer/templates/macros.html.j2 index 100ecf90..f34a0df6 100644 --- a/src/mappings_explorer/templates/macros.html.j2 +++ b/src/mappings_explorer/templates/macros.html.j2 @@ -5,7 +5,7 @@ {% endmacro %} -{% macro table(headers, mappings, url_prefix, table_max_count, full_link, full_size) %} +{% macro table(headers, mappings, url_prefix, table_max_count, full_link, full_size, attack_version, attack_domain, previous_link) %}
{% if mappings | length > table_max_count %}

@@ -29,6 +29,7 @@ + {% if mappings | length > 0 %} {%- for mapping in mappings[:table_max_count] %} {% for header in headers -%} @@ -44,6 +45,14 @@ {% endfor -%} {% endfor -%} + {% else %} + + + No mappings found for this technique in ATT&CK {{attack_domain}} version {{attack_version}}. Change versions + of ATT&CK or check out a different technique with Matrix View. + + + {% endif%}