Skip to content

Commit

Permalink
Add non mapped technique pages to fix any 404 link errors
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonrobbins committed Jul 5, 2024
1 parent 61b0412 commit ce9b64c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
18 changes: 18 additions & 0 deletions src/mappings_explorer/site_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +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 = (
PUBLIC_DIR
Expand Down
41 changes: 25 additions & 16 deletions src/mappings_explorer/templates/macros.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</a>
{% 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) %}
<div class="table-responsive table-outer">
{% if mappings | length > table_max_count %}
<p class="notice">
Expand All @@ -29,21 +29,30 @@
</tr>
</thead>
<tbody>
{%- for mapping in mappings[:table_max_count] %}
<tr>
{% for header in headers -%}
{%- if header[2] and header[3] -%}
<td><a href="{{header[3]}}{{mapping[header[2]] | replace(' ', '_') }}/">{{mapping[header[0]]}}</a></td>
{% endif -%}
{%- if header[2] and not header[3] -%}
<td><a href="{{mapping | build_capability_url(url_prefix, mapping[header[2]])}}">{{mapping[header[0]]}}</a></td>
{% endif -%}
{%- if not header[2] -%}
<td>{{mapping[header[0]]}}</td>
{% endif -%}
{% endfor -%}
</tr>
{% endfor -%}
{% if mappings | length > 0 %}
{%- for mapping in mappings[:table_max_count] %}
<tr>
{% for header in headers -%}
{%- if header[2] and header[3] -%}
<td><a href="{{header[3]}}{{mapping[header[2]] | replace(' ', '_') }}/">{{mapping[header[0]]}}</a></td>
{% endif -%}
{%- if header[2] and not header[3] -%}
<td><a href="{{mapping | build_capability_url(url_prefix, mapping[header[2]])}}">{{mapping[header[0]]}}</a></td>
{% endif -%}
{%- if not header[2] -%}
<td>{{mapping[header[0]]}}</td>
{% endif -%}
{% endfor -%}
</tr>
{% endfor -%}
{% else %}
<tr>
<td class="text-center" colspan="{{headers | length}}">
No mappings found for this technique in ATT&CK {{attack_domain}} version {{attack_version}}. <a href={{previous_link}}>Change versions
of ATT&CK</a> or check out a different technique with <a href="{{url_prefix}}attack/matrix/">Matrix View</a>.
</td>
</tr>
{% endif%}
</tbody>
</table>
<script>
Expand Down
2 changes: 1 addition & 1 deletion src/mappings_explorer/templates/technique.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</div>
</div>
<div class="col-12">
{{ macros.table(headers, mappings, url_prefix, table_max_count, full_link, full_size) }}
{{ macros.table(headers, mappings, url_prefix, table_max_count, full_link, full_size, attack_version, attack_domain, previous_link) }}
</div>
</div>
</div>
Expand Down

0 comments on commit ce9b64c

Please sign in to comment.