From 919240b24361944ab47059c31dc2c3990c59e44f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:47:36 +0000 Subject: [PATCH 01/51] Bump gitpython from 3.1.32 to 3.1.34 Bumps [gitpython](https://github.com/gitpython-developers/GitPython) from 3.1.32 to 3.1.34. - [Release notes](https://github.com/gitpython-developers/GitPython/releases) - [Changelog](https://github.com/gitpython-developers/GitPython/blob/main/CHANGES) - [Commits](https://github.com/gitpython-developers/GitPython/compare/3.1.32...3.1.34) --- updated-dependencies: - dependency-name: gitpython dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 065c5a9d9b6..4ce3fec7847 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -GitPython==3.1.32 +GitPython==3.1.34 Markdown==3.4.3 bleach==6.0.0 colorama==0.4.6 From 602e67a2cc26f77a96721aef1615f61b2b101ec7 Mon Sep 17 00:00:00 2001 From: adpare Date: Mon, 11 Sep 2023 19:49:24 -0400 Subject: [PATCH 02/51] first attempt at loading sidebar --- attack-theme/static/scripts/navigation.js | 1 + attack-theme/static/scripts/sidebar-load.js | 69 ++++ .../templates/general/attackcon-overview.html | 4 +- .../templates/general/intro-overview.html | 2 +- modules/resources/docs/sidebar.html | 353 ++++++++++++++++++ modules/resources/templates/attackcon.html | 4 +- modules/resources/templates/brand.html | 4 +- .../resources/templates/getting-started.html | 4 +- .../resources/templates/related-projects.html | 4 +- modules/resources/templates/resources.html | 4 +- modules/resources/templates/training-cti.html | 4 +- modules/resources/templates/training.html | 4 +- modules/resources/templates/update-post.html | 4 +- .../resources/templates/updates-index.html | 4 +- .../templates/working-with-attack.html | 4 +- .../website_build/templates/changelog.html | 2 +- modules/website_build/templates/faq.html | 4 +- 17 files changed, 449 insertions(+), 26 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load.js create mode 100644 modules/resources/docs/sidebar.html diff --git a/attack-theme/static/scripts/navigation.js b/attack-theme/static/scripts/navigation.js index ef3d7f937d7..b19ac4db22e 100644 --- a/attack-theme/static/scripts/navigation.js +++ b/attack-theme/static/scripts/navigation.js @@ -71,6 +71,7 @@ $(document).ready(function () { $(".sidenav-head").click(function () { localStorage.setItem("need_update", true); localStorage.setItem("new_active_id", $(this).attr('id')); + $(this).addClass("active"); }); // If this method is called, then the user has clicked on a link in the subtechniques dropdown table. diff --git a/attack-theme/static/scripts/sidebar-load.js b/attack-theme/static/scripts/sidebar-load.js new file mode 100644 index 00000000000..141b63c0039 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load.js @@ -0,0 +1,69 @@ +$(document).ready(function () { +console.log("by"); +}); + + console.log("hi"); + $("#sidebars").load("/docs/sidebar.html", function() { + // put the code here that you want to run when the .load() + // has completed and the content is available + // Or, you can call a function from here + let active_id = "" + + // Check if referrer was from the same domain + // If not, set update to false + // This will remove unwanted behavior that appears when + // jumping from one domain to another. E.g. techniques to matrices + $(".sidenav-head").each(function () { + let check = localStorage.getItem("need_update"); + if($(this)[0].id == localStorage.getItem("new_active_id") && check === true){ + $(this).addClass("active"); + } + }); + + var sidebar = document.querySelector(".sidebar"); + var sidebarSize = localStorage.getItem('sidebarWidth'); + sidebar.style.width = sidebarSize; + + let current_modules = window.location.pathname.split("/"); + + if (document.referrer) { + // Loop through the modules in case page is hosted from different + // directory + + let is_found = false; + for (let i = 0; i < current_modules.length; i++) { + if ((document.referrer.includes(current_modules[i]))) { + is_found = true; + } + if (!is_found) { + localStorage.setItem("need_update", false); + } + } + } + else { + localStorage.setItem("need_update", false); + } + + // Update panes + if (localStorage.getItem("need_update") === "true") { + // Get active id from storage and remove update + active_id = localStorage.getItem("new_active_id").split("-") + localStorage.setItem("need_update", false); + $(this).addClass("active"); + } + else { + // Set active id to first element that is active + // This will open the first one in the case that there are multiple + $(".sidenav-head.active:first").each(function () { + active_id = $(this).attr('id').split("-"); + $(this).addClass("active"); + }); + } + + // If this method is called then the user is clicking on the sidenav + // Set update to true and set the new id to one that was clicked + $(".sidenav-head").click(function () { + localStorage.setItem("need_update", true); + localStorage.setItem("new_active_id", $(this).attr('id')); + }); +}); \ No newline at end of file diff --git a/attack-theme/templates/general/attackcon-overview.html b/attack-theme/templates/general/attackcon-overview.html index b33437e1cac..03fbf6592d9 100644 --- a/attack-theme/templates/general/attackcon-overview.html +++ b/attack-theme/templates/general/attackcon-overview.html @@ -6,7 +6,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -117,5 +117,5 @@

Sponsors

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index 29e410b8abc..20730db83d5 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -25,5 +25,5 @@

{{ page.title }}

{% block scripts %} {{ super () }} - + {% endblock %} diff --git a/modules/resources/docs/sidebar.html b/modules/resources/docs/sidebar.html new file mode 100644 index 00000000000..29bf998ebb9 --- /dev/null +++ b/modules/resources/docs/sidebar.html @@ -0,0 +1,353 @@ + + +
+
RESOURCES + + +
+ +
+ \ No newline at end of file diff --git a/modules/resources/templates/attackcon.html b/modules/resources/templates/attackcon.html index cd7c8741522..65077751a2b 100644 --- a/modules/resources/templates/attackcon.html +++ b/modules/resources/templates/attackcon.html @@ -6,7 +6,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -133,5 +133,5 @@

Sponsors

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/brand.html b/modules/resources/templates/brand.html index 4d6b68a78c0..1dca4d9ed14 100644 --- a/modules/resources/templates/brand.html +++ b/modules/resources/templates/brand.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -78,5 +78,5 @@

Brand Guide

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/getting-started.html b/modules/resources/templates/getting-started.html index 846d46cb261..b09af711a2b 100644 --- a/modules/resources/templates/getting-started.html +++ b/modules/resources/templates/getting-started.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -263,5 +263,5 @@

Community

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/related-projects.html b/modules/resources/templates/related-projects.html index 8d8c4547e92..8e3e4bc9216 100644 --- a/modules/resources/templates/related-projects.html +++ b/modules/resources/templates/related-projects.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -116,5 +116,5 @@
- + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/resources.html b/modules/resources/templates/resources.html index bab4d488e9b..87fc196bf2e 100644 --- a/modules/resources/templates/resources.html +++ b/modules/resources/templates/resources.html @@ -6,7 +6,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -157,5 +157,5 @@

Other Resources

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training-cti.html b/modules/resources/templates/training-cti.html index a4678ca8422..2753b5f28c1 100644 --- a/modules/resources/templates/training-cti.html +++ b/modules/resources/templates/training-cti.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -284,5 +284,5 @@

Exercise 5: Making defensive recommendations {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training.html b/modules/resources/templates/training.html index aa624821f44..ff2708b5f64 100644 --- a/modules/resources/templates/training.html +++ b/modules/resources/templates/training.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -49,5 +49,5 @@

ATT&CK Training

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/update-post.html b/modules/resources/templates/update-post.html index d860bc2ed33..a9d765c770f 100644 --- a/modules/resources/templates/update-post.html +++ b/modules/resources/templates/update-post.html @@ -5,7 +5,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -24,5 +24,5 @@

{{ article.title }}

{% endblock %} {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/updates-index.html b/modules/resources/templates/updates-index.html index 108694145f1..cde0067be0a 100644 --- a/modules/resources/templates/updates-index.html +++ b/modules/resources/templates/updates-index.html @@ -6,7 +6,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} {% block innerright %} @@ -26,5 +26,5 @@

{{ (articles|selectattr('template', 'equalto', {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/working-with-attack.html b/modules/resources/templates/working-with-attack.html index b8973088de3..b552c6872d8 100644 --- a/modules/resources/templates/working-with-attack.html +++ b/modules/resources/templates/working-with-attack.html @@ -7,7 +7,7 @@ {% block innerleft %}
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% endblock %} @@ -194,5 +194,5 @@

Explore our standa {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/website_build/templates/changelog.html b/modules/website_build/templates/changelog.html index c06d974bf2b..ad102713775 100644 --- a/modules/website_build/templates/changelog.html +++ b/modules/website_build/templates/changelog.html @@ -35,5 +35,5 @@

Changelog

{% endblock %} {% block scripts %} {{ super () }} - + {% endblock %} diff --git a/modules/website_build/templates/faq.html b/modules/website_build/templates/faq.html index 76f1799579f..182b096ed7d 100644 --- a/modules/website_build/templates/faq.html +++ b/modules/website_build/templates/faq.html @@ -48,5 +48,5 @@
{{qa.question}}
{% block scripts %} {{ super() }} - -{% endblock %} \ No newline at end of file + +{% endblock %} \ No newline at end of file From a1fc5443e8f01be0f826e16a5f89ba4be7d5c60e Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:51:12 -0400 Subject: [PATCH 03/51] init assets --- .gitignore | 1 + modules/assets/__init__.py | 21 ++ modules/assets/assets.py | 232 +++++++++++++++++++++ modules/assets/assets_config.py | 22 ++ modules/assets/assets_redirections.json | 7 + modules/assets/templates/asset.html | 148 +++++++++++++ modules/assets/templates/assets-index.html | 80 +++++++ modules/util/relationshipgetters.py | 31 +++ modules/util/relationshiphelpers.py | 15 ++ modules/util/stixhelpers.py | 5 + modules/website_build/website_build.py | 1 + update-attack.py | 1 + 12 files changed, 564 insertions(+) create mode 100644 modules/assets/__init__.py create mode 100644 modules/assets/assets.py create mode 100644 modules/assets/assets_config.py create mode 100644 modules/assets/assets_redirections.json create mode 100644 modules/assets/templates/asset.html create mode 100644 modules/assets/templates/assets-index.html diff --git a/.gitignore b/.gitignore index a57b1721080..59588f224dc 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ attack-theme/templates/contribute attack-theme/templates/datasources attack-theme/templates/groups attack-theme/templates/campaigns +attack-theme/templates/assets attack-theme/templates/matrices attack-theme/templates/mitigations attack-theme/templates/resources diff --git a/modules/assets/__init__.py b/modules/assets/__init__.py new file mode 100644 index 00000000000..454a48536c3 --- /dev/null +++ b/modules/assets/__init__.py @@ -0,0 +1,21 @@ +from . import assets +from . import assets_config + + +def get_priority(): + return assets_config.priority + + +def get_menu(): + return { + "display_name": assets_config.module_name, + "module_name": assets_config.module_name, + "url": "/assets", + "external_link": False, + "priority": assets_config.priority, + "children": [], + } + + +def run_module(): + return (assets.generate_assets(), assets_config.module_name) diff --git a/modules/assets/assets.py b/modules/assets/assets.py new file mode 100644 index 00000000000..3fcf38830bb --- /dev/null +++ b/modules/assets/assets.py @@ -0,0 +1,232 @@ +import collections +import json +import os + +from loguru import logger + +from modules import util + +from . import assets_config +from .. import site_config + + +def generate_assets(): + """ + Responsible for verifying asset directory and starting off asset markdown generation. + """ + # Create content pages directory if does not already exist + util.buildhelpers.create_content_pages_dir() + + # Move templates to templates directory + util.buildhelpers.move_templates(assets_config.module_name, assets_config.assets_templates_path) + + # Verify if directory exists + if not os.path.isdir(assets_config.asset_markdown_path): + os.mkdir(assets_config.asset_markdown_path) + + # TODO resolve infinite redirect loop when run locally. Needs further testing before code removal. + # Generate redirections + util.buildhelpers.generate_redirections( + redirections_filename=assets_config.assets_redirection_location, redirect_md=site_config.redirect_md + ) + + # Generates the markdown files to be used for page generation + assets_generated = generate_markdown_files() + + if not assets_generated: + util.buildhelpers.remove_module_from_menu(assets_config.module_name) + + +def generate_markdown_files(): + """ + Responsible for generating asset index page and getting shared data for all assets. + """ + has_asset = False + + asset_list = util.relationshipgetters.get_asset_list() + + asset_list_no_deprecated_revoked = util.buildhelpers.filter_deprecated_revoked(asset_list) + + if asset_list_no_deprecated_revoked: + has_asset = True + + if has_asset: + data = {} + + notes = util.relationshipgetters.get_objects_using_notes() + side_menu_data = util.buildhelpers.get_side_menu_data( + "Assets", "/assets/", asset_list_no_deprecated_revoked + ) + data["side_menu_data"] = side_menu_data + data["assets_table"] = get_assets_table_data(asset_list_no_deprecated_revoked) + data["assets_list_len"] = str(len(asset_list_no_deprecated_revoked)) + + subs = assets_config.asset_index_md + json.dumps(data) + + with open( + os.path.join(assets_config.asset_markdown_path, "overview.md"), "w", encoding="utf8" + ) as md_file: + md_file.write(subs) + + # Create the markdown for assets + for asset in asset_list: + generate_asset_md(asset, side_menu_data, notes) + + return has_asset + + +def generate_asset_md(asset, side_menu_data, notes): + """Responsible for generating markdown of all assets.""" + + attack_id = util.buildhelpers.get_attack_id(asset) + + if not attack_id: return + + data = {} + data["attack_id"] = attack_id + data["side_menu_data"] = side_menu_data + data["notes"] = notes.get(asset["id"]) + + dates = util.buildhelpers.get_created_and_modified_dates(asset) + if dates.get("created"): + data["created"] = dates["created"] + if dates.get("modified"): + data["modified"] = dates["modified"] + if asset.get("name"): + data["name"] = asset["name"] + if asset.get("x_mitre_version"): + data["version"] = asset["x_mitre_version"] + + if isinstance(asset.get("x_mitre_contributors"), collections.abc.Iterable): + data["contributors_list"] = asset["x_mitre_contributors"] + + # if asset.get("x_mitre_platforms"): + # asset["x_mitre_platforms"].sort() + # data["platforms"] = ", ".join(asset["x_mitre_platforms"]) + + # if asset.get("x_mitre_sectors"): + # asset["x_mitre_sectors"].sort() + # data["sectors"] = ", ".join(asset["x_mitre_sectors"]) + + # Get initial reference list + reference_list = {"current_number": 0} + + # Get initial reference list from asset object + reference_list = util.buildhelpers.update_reference_list(reference_list, asset) + + if asset.get("description"): + data["descr"] = asset["description"] + if asset.get("x_mitre_deprecated"): + data["deprecated"] = True + + # Get technique data for technique table + data["technique_table_data"] = get_techniques_targeted_by_asset_data(asset, reference_list) + + # Get navigator layers for this asset + layers = util.buildhelpers.get_navigator_layers( + data["name"], + data["attack_id"], + "asset", + data["version"] if "version" in data else None, + data["technique_table_data"], + ) + + data["layers"] = [] + for layer in layers: + with open( + os.path.join( + assets_config.asset_markdown_path, + "-".join([data["attack_id"], "techniques", layer["domain"]]) + ".md", + ), + "w", + encoding="utf8", + ) as layer_json: + subs = site_config.layer_md.substitute( + { + "attack_id": data["attack_id"], + "path": "assets/" + data["attack_id"], + "domain": layer["domain"], + } + ) + subs = subs + layer["layer"] + layer_json.write(subs) + data["layers"].append( + { + "domain": layer["domain"], + "name": layer["name"], + "filename": layer["filename"], + "navigator_link": site_config.navigator_link, + } + ) + + # TODO: related assets + + data["citations"] = reference_list + data["versioning_feature"] = site_config.check_versions_module() + + subs = assets_config.asset_md.substitute(data) + subs = subs + json.dumps(data) + + # Write out the markdown file + with open( + os.path.join(assets_config.asset_markdown_path, data["attack_id"] + ".md"), "w", encoding="utf8" + ) as md_file: + md_file.write(subs) + + +def get_assets_table_data(asset_list): + """Responsible for generating asset table data for the asset index page""" + assets_table_data = [] + for asset in asset_list: + attack_id = util.buildhelpers.get_attack_id(asset) + if not attack_id: continue + + domain_list = util.buildhelpers.get_domain_name(asset) + row = { + "id": attack_id, + "name": asset["name"] if asset.get("name") else attack_id, + } + + for domain_idx in range(len(domain_list)): + domain_list[domain_idx] = domain_list[domain_idx].replace('-attack','') + if domain_list[domain_idx] == "ics": + domain_list[domain_idx] = domain_list[domain_idx].upper() + else: + domain_list[domain_idx] = domain_list[domain_idx].capitalize() + row["domains"] = domain_list + + if asset.get("description"): + row["descr"] = asset["description"] + + if asset.get("x_mitre_deprecated"): + row["deprecated"] = True + + assets_table_data.append(row) + + return assets_table_data + + +def get_techniques_targeted_by_asset_data(asset, reference_list): + """Given an asset and its reference list, get the techniques targeted by the asset. + Check the reference list for citations, if not found in list, add it. + """ + technique_list = {} + techniques_targeted_by_assets = util.relationshipgetters.get_techniques_targeted_by_assets() + + if techniques_targeted_by_assets.get(asset.get("id")): + for technique in techniques_targeted_by_assets[asset["id"]]: + # Do not add if technique is deprecated + if not technique["object"].get("x_mitre_deprecated"): + technique_list = util.buildhelpers.technique_used_helper(technique_list, technique, reference_list) + + technique_data = [] + for item in technique_list: + technique_data.append(technique_list[item]) + # Sort by technique name + technique_data = sorted(technique_data, key=lambda k: k["name"].lower()) + + # Sort by domain name + technique_data = sorted( + technique_data, key=lambda k: [site_config.custom_alphabet.index(c) for c in k["domain"].lower()] + ) + return technique_data diff --git a/modules/assets/assets_config.py b/modules/assets/assets_config.py new file mode 100644 index 00000000000..4781adff9e1 --- /dev/null +++ b/modules/assets/assets_config.py @@ -0,0 +1,22 @@ +from string import Template + +module_name = "Assets" +priority = 7.2 + +# Markdown path for assets +asset_markdown_path = "content/pages/assets/" + +# String template for asset index page +asset_index_md = ( + "Title: Asset overview\n" "Template: assets/assets-index\n" "save_as: assets/index.html\n" "data: " +) + +# String template for asset page +asset_md = Template( + "Title: ${name}\n" "Template: assets/asset\n" "save_as: assets/${attack_id}/index.html\n" "data: " +) + +# Path for templates +assets_templates_path = "modules/assets/templates/" + +assets_redirection_location = "modules/assets/assets_redirections.json" diff --git a/modules/assets/assets_redirections.json b/modules/assets/assets_redirections.json new file mode 100644 index 00000000000..16b713b22f4 --- /dev/null +++ b/modules/assets/assets_redirections.json @@ -0,0 +1,7 @@ +[ + { + "title": "assets-redirect", + "from": "assets.html", + "to": "/assets/" + } +] diff --git a/modules/assets/templates/asset.html b/modules/assets/templates/asset.html new file mode 100644 index 00000000000..07799183f26 --- /dev/null +++ b/modules/assets/templates/asset.html @@ -0,0 +1,148 @@ +{% extends "general/two-column.html" %} +{% set parsed = page.data | from_json %} +{% set title = parsed.name + ", Asset " + parsed.attack_id + " | MITRE ATT&CK®" -%} +{% set active_page = "assets" -%} + +{% import 'macros/deprecated.html' as deprecated %} +{% import 'macros/navigator.html' as navigator %} +{% import 'macros/references.html' as references %} +{% import 'macros/navigation.html' as navigation %} +{% import 'macros/techniques_used.html' as techniques_used %} +{% import 'macros/versioning.html' as versioning %} +{% import 'macros/clean_output.html' as clean_output %} +{% import 'macros/citations.html' as citations %} +{% import 'macros/notes.html' as notes %} + +{% block head %} + {{ super () }} + {% if parsed.deprecated %} + + {% endif %} +{% endblock %} + +{% block innerleft %} + +
+ {{ navigation.sidenav(parsed.side_menu_data, output_file) }} +
+ +{% endblock %} + +{% block innerright %} +{{ super () }} + +
+
+
+
+
+
+

{{ parsed.name }}

+ + {% if parsed.deprecated %} + {% if parsed.descr %} + {{ deprecated.deprecated(clean_output.stixToHTML(parsed.descr, firstParagraphOnly=True)) }} + {% else %} + {{ deprecated.deprecated("This asset has been deprecated.") }} + {% endif %} + {% else %} +
+
+ {% if parsed.descr %} +
+ {{ clean_output.stixToHTML(parsed.descr, parsed.citations) }} +
+ {% endif %} + {% if parsed.notes %} + {{ notes.notes_section(parsed.notes) }} + {% endif %} +
+
+
+
+ {% if parsed.attack_id %} +
+
+ ID: {{ parsed.attack_id }} +
+
+ {% endif %} + {% if parsed.platforms %} +
+
+ +
+
+ {{ "Platform" if parsed.platforms | length < 2 else "Platforms" }}: {{parsed.platforms}} +
+
+ {% endif %} + {% if parsed.sectors %} +
+
+ {{ "Sector" if parse.sectors | length < 2 else "Sectors" }}: {{ parsed.sectors }} +
+
+ {% endif %} + {% if parsed.contributors_list %} +
+
+ Contributors: {{ parsed.contributors_list|join("; ") }} +
+
+ {% endif %} + {% if parsed.version %} +
+
+ Version: {{ parsed.version }} +
+
+ {% endif %} + {% if parsed.created %} +
+
+ Created: {{ parsed.created }} +
+
+ {% endif %} + {% if parsed.modified %} +
+
+ Last Modified: {{ parsed.modified }} +
+
+ {% endif %} +
+
+ {% if parsed.versioning_feature %} + {{ versioning.permalink_button(output_file, parsed.attack_id)}} + {% endif %} +
+
+ + {% if parsed.technique_table_data %} + {{ navigator.layer_links(parsed.attack_id, "assets", parsed.layers) }} + {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques Targeted", true, "Targets", parsed.citations) }} + {% endif %} + + {{ citations.reference_section(parsed.citations) }} + {% endif %} +
+
+
+
+ +{% endblock %} + +{% block scripts %} + {{ super() }} + + + + + +{% endblock %} diff --git a/modules/assets/templates/assets-index.html b/modules/assets/templates/assets-index.html new file mode 100644 index 00000000000..3b28b7b5e16 --- /dev/null +++ b/modules/assets/templates/assets-index.html @@ -0,0 +1,80 @@ +{% extends "general/two-column.html" %} +{% set title = "Assets | MITRE ATT&CK®" %} +{% set parsed = page.data | from_json %} +{% set active_page = "assets" -%} +{% import 'macros/navigation.html' as navigation %} +{% import 'macros/clean_output.html' as clean_output %} + +{% block innerleft %} + +
+ {{ navigation.sidenav(parsed.side_menu_data, output_file) }} +
+ +{% endblock %} + +{% block innerright %} + {{ super () }} + +
+
+
+
+
+
+

Assets

+

+ <PLACEHOLDER DESCRIPTION> +

+ +
Assets: {{ parsed.assets_list_len }}
+ + + + + + + + + + + {% for row in parsed.assets_table %} + + + + + + + {% endfor %} + +
IDNameDomainDescription
+ {{ row.id | upper }} + + {{ row.name }} + + {% for dom in row.domains %} + {{dom}} +
+ {% endfor %} +
+ {% if row.deprecated %} + ****Deprecation Warning**** + {% endif %} + {{ clean_output.stixToHTML(row.descr) }} +
+
+
+
+
+
+ +{% endblock %} + +{% block scripts %} + {{ super() }} + + +{% endblock %} \ No newline at end of file diff --git a/modules/util/relationshipgetters.py b/modules/util/relationshipgetters.py index 8cd981f9a56..05a0ff94dc7 100644 --- a/modules/util/relationshipgetters.py +++ b/modules/util/relationshipgetters.py @@ -11,6 +11,7 @@ techniques_used_by_tools = {} techniques_used_by_groups = {} techniques_used_by_campaigns = {} +techniques_targeted_by_assets = {} techniques_detected_by_datacomponent = {} groups_using_tool = {} groups_using_malware = {} @@ -20,6 +21,7 @@ tools_using_technique = {} malware_using_technique = {} groups_using_technique = {} +assets_targeting_techniques = {} campaigns_using_technique = {} campaigns_using_tool = {} campaigns_using_malware = {} @@ -44,6 +46,7 @@ datacomponent_list = [] mitigation_list = [] campaign_list = [] +asset_list = [] technique_to_domain = {} @@ -130,6 +133,25 @@ def get_techniques_used_by_campaigns(): return techniques_used_by_campaigns +def get_techniques_targeted_by_assets(): + """techniques targeted by assets getter""" + global techniques_targeted_by_assets + + if not techniques_targeted_by_assets: + techniques_targeted_by_assets = rsh.techniques_targeted_by_assets(get_srcs()) + + return techniques_targeted_by_assets + + +def get_assets_targeting_techniques(): + """assets targeting techniques getter""" + global assets_targeting_techniques + + if not assets_targeting_techniques: + assets_targeting_techniques = rsh.assets_targeting_techniques(get_srcs()) + + return assets_targeting_techniques + def get_techniques_detected_by_datacomponent(): global techniques_detected_by_datacomponent @@ -431,6 +453,15 @@ def get_campaign_list(): return campaign_list +def get_asset_list(): + """asset list getter""" + global asset_list + + if not asset_list: + asset_list = get_resources()["assets"] + + return asset_list + def get_technique_to_domain(): """technique to domain getter""" diff --git a/modules/util/relationshiphelpers.py b/modules/util/relationshiphelpers.py index 13f6ab734e1..9e9b54caf54 100644 --- a/modules/util/relationshiphelpers.py +++ b/modules/util/relationshiphelpers.py @@ -247,6 +247,21 @@ def campaigns_attributed_to_group(srcs): return get_related(srcs, "campaign", "attributed-to", "intrusion-set", reverse=True) +# technique:asset +def techniques_targeted_by_assets(srcs): + """Return asset_id => {technique, relationship} for each technique targeted by the asset. + + srcs should be an array of memorystores for enterprise, mobile, and pre + """ + return get_related(srcs, "attack-pattern", "targets", "x-mitre-asset", reverse=True) + +def assets_targeting_techniques(srcs): + """Return technique_id => {asset, relationship} for each asset targeting the technique. + + srcs should be an array of memorystores for enterprise, mobile, and pre + """ + return get_related(srcs, "attack-pattern", "targets", "x-mitre-asset") + # technique:malware def techniques_used_by_malware(srcs): """Return malware => {technique, relationship} for each technique used by the malware. diff --git a/modules/util/stixhelpers.py b/modules/util/stixhelpers.py index 3925b04fdfa..165b4ac6388 100644 --- a/modules/util/stixhelpers.py +++ b/modules/util/stixhelpers.py @@ -359,6 +359,9 @@ def get_domain_resources(types): # Generates list of campaigns campaign_list = get_domain_resources(["campaign"]) + # Generates list of assets + asset_list = get_domain_resources(["x-mitre-asset"]) + # Generates list of relationships rel_list = [] for domain in site_config.domains: @@ -377,6 +380,7 @@ def get_domain_resources(types): "techniques": tech_list, "mitigations": coa_list, "campaigns": campaign_list, + "assets": asset_list } return resources @@ -430,6 +434,7 @@ def get_contributors(ms): "x-mitre-data-component", "x-mitre-data-source", "x-mitre-tactic", + "x-mitre-asset", ] src = ms[domain["name"]] obj_list = [] diff --git a/modules/website_build/website_build.py b/modules/website_build/website_build.py index 1270d672d3c..a4ef579bfe4 100644 --- a/modules/website_build/website_build.py +++ b/modules/website_build/website_build.py @@ -168,6 +168,7 @@ def generate_index_page(): "groups": "Group", "software": "Software", "campaigns": "Campaign", + "assets": "Asset", } routes = {} diff --git a/update-attack.py b/update-attack.py index 602fd29cc56..d657835c607 100644 --- a/update-attack.py +++ b/update-attack.py @@ -22,6 +22,7 @@ "tactics", "techniques", "campaigns", + "assets", "tour", "website_build", "random_page", From abe5af746bc403efa9f49ac2e4a0af9de12f1762 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:51:30 -0400 Subject: [PATCH 04/51] add asset to random page generator --- modules/random_page/random_page.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/random_page/random_page.py b/modules/random_page/random_page.py index 11236283fc0..604e7e65e17 100644 --- a/modules/random_page/random_page.py +++ b/modules/random_page/random_page.py @@ -16,6 +16,7 @@ def generate_json(): "groups": "Group", "software": "Software", "campaigns": "Campaign", + "assets": "Asset" } routes = {} @@ -57,6 +58,8 @@ def generate_json(): add_to_json = True elif route == "campaigns" and re.search(r"C[0-9]{4}", thepath): add_to_json = True + elif route == "assets" and re.search(r"A[0-9]{4}", thepath): + add_to_json = True if add_to_json: json_data[value].append(thepath[6:]) From 666516741d05c5103a0cc6a95e82ce720997c434 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 11:52:10 -0400 Subject: [PATCH 05/51] update working with attack --- modules/resources/resources.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/resources/resources.py b/modules/resources/resources.py index 3b84026e294..4f821cb2232 100644 --- a/modules/resources/resources.py +++ b/modules/resources/resources.py @@ -308,6 +308,7 @@ def generate_working_with_attack(): "techniques", "datasources", "campaigns", + "assets" ] # Verify if directories exists From 0f76a61392276857466d4b46921bffdb93c8eec6 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:12:33 -0400 Subject: [PATCH 06/51] sonarlint --- modules/assets/assets.py | 10 ++++------ modules/assets/assets_config.py | 4 ++-- modules/assets/templates/assets-index.html | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index 3fcf38830bb..46cb794c050 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -100,13 +100,11 @@ def generate_asset_md(asset, side_menu_data, notes): if isinstance(asset.get("x_mitre_contributors"), collections.abc.Iterable): data["contributors_list"] = asset["x_mitre_contributors"] - # if asset.get("x_mitre_platforms"): - # asset["x_mitre_platforms"].sort() - # data["platforms"] = ", ".join(asset["x_mitre_platforms"]) + if asset.get("x_mitre_platforms"): + asset["x_mitre_platforms"].sort() + data["platforms"] = ", ".join(asset["x_mitre_platforms"]) - # if asset.get("x_mitre_sectors"): - # asset["x_mitre_sectors"].sort() - # data["sectors"] = ", ".join(asset["x_mitre_sectors"]) + # TODO: x_mitre_sectors # Get initial reference list reference_list = {"current_number": 0} diff --git a/modules/assets/assets_config.py b/modules/assets/assets_config.py index 4781adff9e1..deafdb527d0 100644 --- a/modules/assets/assets_config.py +++ b/modules/assets/assets_config.py @@ -8,12 +8,12 @@ # String template for asset index page asset_index_md = ( - "Title: Asset overview\n" "Template: assets/assets-index\n" "save_as: assets/index.html\n" "data: " + "Title: Asset overview\nTemplate: assets/assets-index\nsave_as: assets/index.html\ndata: " ) # String template for asset page asset_md = Template( - "Title: ${name}\n" "Template: assets/asset\n" "save_as: assets/${attack_id}/index.html\n" "data: " + "Title: ${name}\nTemplate: assets/asset\nsave_as: assets/${attack_id}/index.html\ndata: " ) # Path for templates diff --git a/modules/assets/templates/assets-index.html b/modules/assets/templates/assets-index.html index 3b28b7b5e16..7c3d9f910d3 100644 --- a/modules/assets/templates/assets-index.html +++ b/modules/assets/templates/assets-index.html @@ -31,7 +31,7 @@

Assets

Assets: {{ parsed.assets_list_len }}
- +
@@ -57,7 +57,7 @@
Assets: {{ parsed.assets_list_len }}
From b1b6d2abb2f99c92a58d8a8b84393ebca3b112ca Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:22:19 -0400 Subject: [PATCH 07/51] add sectors to asset info card --- modules/assets/assets.py | 4 +++- modules/assets/templates/asset.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index 46cb794c050..eb9980add53 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -104,7 +104,9 @@ def generate_asset_md(asset, side_menu_data, notes): asset["x_mitre_platforms"].sort() data["platforms"] = ", ".join(asset["x_mitre_platforms"]) - # TODO: x_mitre_sectors + if asset.get("x_mitre_sectors"): + asset["x_mitre_sectors"].sort() + data["sectors"] = ", ".join(asset["x_mitre_sectors"]) # Get initial reference list reference_list = {"current_number": 0} diff --git a/modules/assets/templates/asset.html b/modules/assets/templates/asset.html index 07799183f26..2a6571d7948 100644 --- a/modules/assets/templates/asset.html +++ b/modules/assets/templates/asset.html @@ -84,7 +84,7 @@

{{ parsed.name }}

{% if parsed.sectors %}
- {{ "Sector" if parse.sectors | length < 2 else "Sectors" }}: {{ parsed.sectors }} + {{ "Sector" if parsed.sectors | length < 2 else "Sectors" }}: {{parsed.sectors}}
{% endif %} @@ -126,7 +126,7 @@

{{ parsed.name }}

{% if parsed.technique_table_data %} {{ navigator.layer_links(parsed.attack_id, "assets", parsed.layers) }} - {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques Targeted", true, "Targets", parsed.citations) }} + {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques", true, "Targets", parsed.citations) }} {% endif %} {{ citations.reference_section(parsed.citations) }} From d7ba1984731e7cebbed0074072060aca74d7f8c9 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 12:35:51 -0400 Subject: [PATCH 08/51] add asset table to technique pages --- modules/techniques/techniques.py | 117 +++++++++++++------- modules/techniques/templates/technique.html | 29 +++++ 2 files changed, 105 insertions(+), 41 deletions(-) diff --git a/modules/techniques/techniques.py b/modules/techniques/techniques.py index e5ab5e051c0..590b66800dc 100644 --- a/modules/techniques/techniques.py +++ b/modules/techniques/techniques.py @@ -55,9 +55,8 @@ def generate_techniques(): check_if_generated = generate_domain_markdown( domain["name"], techniques_no_sub, tactics, side_nav_data, notes, deprecated ) - if not technique_generated: - if check_if_generated: - technique_generated = True + if not technique_generated and check_if_generated: + technique_generated = True if not technique_generated: util.buildhelpers.remove_module_from_menu(techniques_config.module_name) @@ -220,6 +219,9 @@ def generate_data_for_md(technique_dict, technique, tactic_list, is_sub_techniqu # Get examples technique_dict["examples_table"] = get_examples_table_data(technique, reference_list) + # Get asset table + technique_dict["assets_table"] = get_assets_table_data(technique, reference_list) + # Get technique version if technique.get("x_mitre_version"): technique_dict["version"] = technique["x_mitre_version"] @@ -357,26 +359,60 @@ def get_mitigations_table_data(technique, reference_list): # Do not add deprecated mitigation to table if not mitigation["object"].get("x_mitre_deprecated"): attack_id = util.buildhelpers.get_attack_id(mitigation["object"]) - # Only add if mitigation attack id is found - if attack_id: - row = {} - row["mid"] = attack_id - row["name"] = mitigation["object"]["name"] - if mitigation["relationship"].get("description"): - # Get filtered description - reference_list = util.buildhelpers.update_reference_list( - reference_list, mitigation["relationship"] - ) - row["descr"] = mitigation["relationship"]["description"] + if not attack_id: continue + row = {} + row["mid"] = attack_id + row["name"] = mitigation["object"]["name"] + if mitigation["relationship"].get("description"): + # Get filtered description + reference_list = util.buildhelpers.update_reference_list( + reference_list, mitigation["relationship"] + ) + row["descr"] = mitigation["relationship"]["description"] - mitigation_data.append(row) + mitigation_data.append(row) if mitigation_data: mitigation_data = sorted(mitigation_data, key=lambda k: k["name"].lower()) return mitigation_data +def get_assets_table_data(technique, reference_list): + """Given a technique a reference list, find assets that target the + technique and return list with asset data. Also modifies the + reference list if it finds a reference that is not on the list + """ + asset_data = [] + + # Check if technique has assets + assets_targeting_techniques = util.relationshipgetters.get_assets_targeting_techniques().get(technique["id"]) + if assets_targeting_techniques: + # Iterate through technique assets + for asset in assets_targeting_techniques: + # Do not add deprecated assets to table + if not asset["object"].get("x_mitre_deprecated"): + attack_id = util.buildhelpers.get_attack_id(asset["object"]) + + # Only add if attack id is found + if not attack_id: continue + row = {} + row["id"] = attack_id + row["name"] = asset["object"]["name"] + if asset["relationship"].get("description"): + # Get filtered description + reference_list = util.buildhelpers.update_reference_list( + reference_list, asset["relationship"] + ) + row["descr"] = asset["relationship"]["description"] + + asset_data.append(row) + + if asset_data: + asset_data = sorted(asset_data, key=lambda k: k["name"].lower()) + return asset_data + + def get_examples_table_data(technique, reference_list): """Given a technique object, find examples in malware using technique, tools using technique and groups using technique. Return list with @@ -399,23 +435,23 @@ def get_examples_table_data(technique, reference_list): attack_id = util.buildhelpers.get_attack_id(example["object"]) # Only add example data if the attack id is found - if attack_id: - row = {} + if not attack_id: continue + row = {} - row["id"] = attack_id + row["id"] = attack_id - row["path"] = get_path_from_type(example["object"]) + row["path"] = get_path_from_type(example["object"]) - row["name"] = example["object"]["name"] + row["name"] = example["object"]["name"] - if example["relationship"].get("description"): - # Get filtered description - reference_list = util.buildhelpers.update_reference_list( - reference_list, example["relationship"] - ) - row["descr"] = example["relationship"]["description"] + if example["relationship"].get("description"): + # Get filtered description + reference_list = util.buildhelpers.update_reference_list( + reference_list, example["relationship"] + ) + row["descr"] = example["relationship"]["description"] - example_data.append(row) + example_data.append(row) if example_data: example_data = sorted(example_data, key=lambda k: k["name"].lower()) @@ -507,20 +543,21 @@ def get_techniques_list(techniques): if not technique.get("revoked") and not technique.get("x_mitre_deprecated"): attack_id = util.buildhelpers.get_attack_id(technique) - if attack_id: - technique_dict = {} - technique_dict["id"] = attack_id - technique_dict["stix_id"] = technique["id"] - technique_dict["name"] = technique["name"] - technique_dict["description"] = technique["description"] + if not attack_id: continue - if technique.get("kill_chain_phases"): - for elem in technique["kill_chain_phases"]: - # Fill dict - if elem["phase_name"] not in technique_list: - technique_list[elem["phase_name"]] = [] + technique_dict = {} + technique_dict["id"] = attack_id + technique_dict["stix_id"] = technique["id"] + technique_dict["name"] = technique["name"] + technique_dict["description"] = technique["description"] - technique_list[elem["phase_name"]].append(technique_dict) + if technique.get("kill_chain_phases"): + for elem in technique["kill_chain_phases"]: + # Fill dict + if elem["phase_name"] not in technique_list: + technique_list[elem["phase_name"]] = [] + + technique_list[elem["phase_name"]].append(technique_dict) for key, __ in technique_list.items(): technique_list[key] = sorted(technique_list[key], key=lambda k: k["name"].lower()) @@ -531,8 +568,6 @@ def get_techniques_list(techniques): def get_subtechniques(technique): """Given a technique, return the ID and name of the subtechnique.""" subtechs = [] - attack_id = util.buildhelpers.get_attack_id(technique) - subtechniques_of = util.relationshipgetters.get_subtechniques_of() if technique["id"] in subtechniques_of: diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 12faafebbbf..988270c6820 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -369,6 +369,35 @@

Procedure Examples

ID {% if row.deprecated %} - ****Deprecation Warning**** + ****Deprecation Warning**** {% endif %} {{ clean_output.stixToHTML(row.descr) }}
{% endif %} + {% if parsed.assets_table %} +

Assets

+ + + + + + + + + + {% for asset in parsed.assets_table %} + + + + + + {% endfor %} + +
IDAssetDescription
+ {{asset.id}} + + {{asset.name}} + + {% if asset.descr %} + {{clean_output.stixToHTML(asset.descr, parsed.citations)}} + {% endif %} +
+ {% endif %} {% if parsed.domain != 'pre' %}

Mitigations

{% if parsed.mitigation_table %} From 99fa3d1de8b8f2fa9282ae03d733ad516b9edf1c Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:20:22 -0400 Subject: [PATCH 09/51] related assets table --- modules/assets/assets.py | 18 +++++++++++++++++- modules/assets/templates/asset.html | 24 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index eb9980add53..dca33b5e394 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -159,7 +159,8 @@ def generate_asset_md(asset, side_menu_data, notes): } ) - # TODO: related assets + if asset.get("x_mitre_related_assets"): + data["related_assets_table"] = get_related_asset_data(asset["x_mitre_related_assets"]) data["citations"] = reference_list data["versioning_feature"] = site_config.check_versions_module() @@ -206,6 +207,21 @@ def get_assets_table_data(asset_list): return assets_table_data +def get_related_asset_data(related_assets): + if not related_assets: return [] + + related_asset_data = [] + for related_asset in related_assets: + row = { + "name": related_asset["name"], # required + "sector": related_asset["related_asset_sector"], # required + } + if related_asset.get("description"): + row["descr"] = related_asset["description"] + related_asset_data.append(row) + return related_asset_data + + def get_techniques_targeted_by_asset_data(asset, reference_list): """Given an asset and its reference list, get the techniques targeted by the asset. Check the reference list for citations, if not found in list, add it. diff --git a/modules/assets/templates/asset.html b/modules/assets/templates/asset.html index 2a6571d7948..641b67a3d3c 100644 --- a/modules/assets/templates/asset.html +++ b/modules/assets/templates/asset.html @@ -124,6 +124,30 @@

{{ parsed.name }}

+ {% if parsed.related_assets_table %} +

Related Assets

+ + + + + + + + + + {% for related_asset in parsed.related_assets_table %} + + + + + + {% endfor %} + +
NameSectorDescription
{{ related_asset.name }}{{ related_asset.sector }} + {{ clean_output.stixToHTML(related_asset.descr, parsed.citations) }} +
+ {% endif %} + {% if parsed.technique_table_data %} {{ navigator.layer_links(parsed.attack_id, "assets", parsed.layers) }} {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques", true, "Targets", parsed.citations) }} From 67de6a76d689ff6af1d7a9e800282c4abd52169e Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:34:09 -0400 Subject: [PATCH 10/51] navlayer verbage --- modules/assets/assets.py | 1 + modules/campaigns/campaigns.py | 1 + modules/groups/groups.py | 1 + modules/mitigations/mitigations.py | 1 + modules/software/software.py | 1 + modules/util/buildhelpers.py | 18 +++++++++--------- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index dca33b5e394..bff21055651 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -127,6 +127,7 @@ def generate_asset_md(asset, side_menu_data, notes): data["name"], data["attack_id"], "asset", + "targeted by", data["version"] if "version" in data else None, data["technique_table_data"], ) diff --git a/modules/campaigns/campaigns.py b/modules/campaigns/campaigns.py index 0a4eba57575..4ebfa2aa80e 100644 --- a/modules/campaigns/campaigns.py +++ b/modules/campaigns/campaigns.py @@ -141,6 +141,7 @@ def generate_campaign_md(campaign, side_menu_data, notes): data["name"], data["attack_id"], "campaign", + "used by", data["version"] if "version" in data else None, data["technique_table_data"], ) diff --git a/modules/groups/groups.py b/modules/groups/groups.py index 5b2c888bd6c..28310a4e083 100644 --- a/modules/groups/groups.py +++ b/modules/groups/groups.py @@ -132,6 +132,7 @@ def generate_group_md(group, side_menu_data, notes): data["name"], data["attack_id"], "group", + "used by", data["version"] if "version" in data else None, data["technique_table_data"], inheritance, # extend legend to include color coding for inherited techniques, if applicable diff --git a/modules/mitigations/mitigations.py b/modules/mitigations/mitigations.py index e6e6eb64e3c..bb8ad266725 100644 --- a/modules/mitigations/mitigations.py +++ b/modules/mitigations/mitigations.py @@ -137,6 +137,7 @@ def generate_mitigation_md(mitigation, domain, side_menu_data, notes): data["name"], data["attack_id"], "mitigation", + "mitigated by", data["version"] if "version" in data else None, data["techniques_addressed_data"], ) diff --git a/modules/software/software.py b/modules/software/software.py index b93a6faee0b..eb4d623b794 100644 --- a/modules/software/software.py +++ b/modules/software/software.py @@ -129,6 +129,7 @@ def generate_software_md(software, side_menu_data, notes): data["name"], data["attack_id"], "software", + "used by", data["version"] if "version" in data else None, data["technique_table_data"], ) diff --git a/modules/util/buildhelpers.py b/modules/util/buildhelpers.py index ea0c6eb92ab..20b82e56d26 100644 --- a/modules/util/buildhelpers.py +++ b/modules/util/buildhelpers.py @@ -507,17 +507,17 @@ def replace_html_chars(to_be_replaced): } -def get_navigator_layers(name, attack_id, obj_type, version, techniques_used, inheritance=False): +def get_navigator_layers(name, attack_id, obj_type, rel_type, version, techniques_used, inheritance=False): """Generate the Enterprise, Mobile, and ICS Navigator JSON layers for the given object.""" # Generate Enterprise base layer - enterprise_layer = build_base_layer("enterprise-attack", name, obj_type, attack_id, version, inheritance) + enterprise_layer = build_base_layer("enterprise-attack", name, obj_type, rel_type, attack_id, version, inheritance) # Generate Mobile base layer - mobile_layer = build_base_layer("mobile-attack", name, obj_type, attack_id, version, inheritance) + mobile_layer = build_base_layer("mobile-attack", name, obj_type, rel_type, attack_id, version, inheritance) # Generate ICS base layer - ics_layer = build_base_layer("ics-attack", name, obj_type, attack_id, version, inheritance) + ics_layer = build_base_layer("ics-attack", name, obj_type, rel_type, attack_id, version, inheritance) # Add technique data to layer for technique in techniques_used: @@ -584,12 +584,12 @@ def get_navigator_layers(name, attack_id, obj_type, version, techniques_used, in return layers -def build_base_layer(domain, object_name, object_type, attack_id, version, inheritance=False): +def build_base_layer(domain, object_name, object_type, rel_type, attack_id, version, inheritance=False): """Build the base Navigator layer for the given object.""" layer = {} # Layer description - layer["description"] = f"{domain_name_map[domain]} techniques used by {object_name}, ATT&CK {object_type} {attack_id}" + layer["description"] = f"{domain_name_map[domain]} techniques {rel_type} {object_name}, ATT&CK {object_type} {attack_id}" if version: # Add object version number if it exists layer["description"] += f" (v{version})" @@ -616,14 +616,14 @@ def build_base_layer(domain, object_name, object_type, attack_id, version, inher # Layer legend layer["legendItems"] = [ - {"label": f"used by {object_name}", "color": colorMap[1]} + {"label": f"{rel_type} {object_name}", "color": colorMap[1]} ] # Add campaign inheritance to legend, if applicable if inheritance: layer["legendItems"].extend([ - {"label": f"used by a campaign attributed to {object_name}", "color": colorMap[2]}, - {"label": f"used by {object_name} and used by a campaign attributed to {object_name}", "color": colorMap[3]} + {"label": f"{rel_type} a campaign attributed to {object_name}", "color": colorMap[2]}, + {"label": f"{rel_type} {object_name} and {rel_type} a campaign attributed to {object_name}", "color": colorMap[3]} ]) return layer From 86899f2c53e32276d88dbb56d8f8ed529630f8c0 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Tue, 12 Sep 2023 14:26:48 -0400 Subject: [PATCH 11/51] update search file paths --- attack-search/src/settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/attack-search/src/settings.js b/attack-search/src/settings.js index db171b6711a..a01ad11ff3e 100644 --- a/attack-search/src/settings.js +++ b/attack-search/src/settings.js @@ -2,6 +2,7 @@ const baseURL = ''; // TODO migrate from base_url (generated via Pelican) const searchFilePaths = [ "campaigns.json", + "assets.json", "datasources.json", "groups.json", "matrices.json", From 764153ab0452586485460ab6d5a74e4e42083e73 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 13 Sep 2023 09:52:49 -0400 Subject: [PATCH 12/51] techniques sidebar done --- attack-theme/static/scripts/resizer.js | 2 +- attack-theme/static/scripts/sidebar-load.js | 70 +------------------ .../templates/general/attackcon-overview.html | 2 - .../templates/general/sidebar-technique.html | 21 ++++++ .../templates/general/sidebar-test.html | 24 +++++++ modules/resources/resources.py | 12 ++++ modules/resources/resources_config.py | 6 ++ modules/resources/templates/attackcon.html | 2 - modules/resources/templates/brand.html | 4 +- .../resources/templates/getting-started.html | 2 - .../resources/templates/related-projects.html | 2 - modules/resources/templates/resources.html | 2 - modules/resources/templates/training-cti.html | 2 - modules/resources/templates/training.html | 2 - modules/resources/templates/update-post.html | 2 - .../resources/templates/updates-index.html | 2 - .../templates/working-with-attack.html | 2 - modules/techniques/techniques.py | 15 +++- modules/techniques/techniques_config.py | 7 ++ modules/techniques/templates/technique.html | 8 ++- .../templates/techniques-domain-index.html | 7 +- modules/website_build/website_build.py | 20 ++++++ modules/website_build/website_build_config.py | 4 ++ 23 files changed, 120 insertions(+), 100 deletions(-) create mode 100644 attack-theme/templates/general/sidebar-technique.html create mode 100644 attack-theme/templates/general/sidebar-test.html diff --git a/attack-theme/static/scripts/resizer.js b/attack-theme/static/scripts/resizer.js index eb6b3972bf1..d14d334b337 100644 --- a/attack-theme/static/scripts/resizer.js +++ b/attack-theme/static/scripts/resizer.js @@ -34,7 +34,7 @@ resizer.addEventListener("mousedown", resizeSidebar_mousedownHandler); } //This code is for creating a collapsable sidebar for the mobile view -const mediaQuery = window.matchMedia('(max-width: 47.9875rem)') +var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { if (e.matches) { diff --git a/attack-theme/static/scripts/sidebar-load.js b/attack-theme/static/scripts/sidebar-load.js index 141b63c0039..3a9b81c1794 100644 --- a/attack-theme/static/scripts/sidebar-load.js +++ b/attack-theme/static/scripts/sidebar-load.js @@ -1,69 +1 @@ -$(document).ready(function () { -console.log("by"); -}); - - console.log("hi"); - $("#sidebars").load("/docs/sidebar.html", function() { - // put the code here that you want to run when the .load() - // has completed and the content is available - // Or, you can call a function from here - let active_id = "" - - // Check if referrer was from the same domain - // If not, set update to false - // This will remove unwanted behavior that appears when - // jumping from one domain to another. E.g. techniques to matrices - $(".sidenav-head").each(function () { - let check = localStorage.getItem("need_update"); - if($(this)[0].id == localStorage.getItem("new_active_id") && check === true){ - $(this).addClass("active"); - } - }); - - var sidebar = document.querySelector(".sidebar"); - var sidebarSize = localStorage.getItem('sidebarWidth'); - sidebar.style.width = sidebarSize; - - let current_modules = window.location.pathname.split("/"); - - if (document.referrer) { - // Loop through the modules in case page is hosted from different - // directory - - let is_found = false; - for (let i = 0; i < current_modules.length; i++) { - if ((document.referrer.includes(current_modules[i]))) { - is_found = true; - } - if (!is_found) { - localStorage.setItem("need_update", false); - } - } - } - else { - localStorage.setItem("need_update", false); - } - - // Update panes - if (localStorage.getItem("need_update") === "true") { - // Get active id from storage and remove update - active_id = localStorage.getItem("new_active_id").split("-") - localStorage.setItem("need_update", false); - $(this).addClass("active"); - } - else { - // Set active id to first element that is active - // This will open the first one in the case that there are multiple - $(".sidenav-head.active:first").each(function () { - active_id = $(this).attr('id').split("-"); - $(this).addClass("active"); - }); - } - - // If this method is called then the user is clicking on the sidenav - // Set update to true and set the new id to one that was clicked - $(".sidenav-head").click(function () { - localStorage.setItem("need_update", true); - localStorage.setItem("new_active_id", $(this).attr('id')); - }); -}); \ No newline at end of file +$("#sidebars").load("/resources/sidebar-check"); \ No newline at end of file diff --git a/attack-theme/templates/general/attackcon-overview.html b/attack-theme/templates/general/attackcon-overview.html index 03fbf6592d9..3e8f2c20f1f 100644 --- a/attack-theme/templates/general/attackcon-overview.html +++ b/attack-theme/templates/general/attackcon-overview.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/attack-theme/templates/general/sidebar-technique.html b/attack-theme/templates/general/sidebar-technique.html new file mode 100644 index 00000000000..f6dc5d3346b --- /dev/null +++ b/attack-theme/templates/general/sidebar-technique.html @@ -0,0 +1,21 @@ +{% import 'macros/navigation.html' as navigation %} +{% set parsed = page.data | from_json %} + + +
+ {{ navigation.sidenav(parsed.menu, output_file) }} +
+ + +{% block scripts %} + + + + + + + + + + +{% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/sidebar-test.html b/attack-theme/templates/general/sidebar-test.html new file mode 100644 index 00000000000..8e948613be7 --- /dev/null +++ b/attack-theme/templates/general/sidebar-test.html @@ -0,0 +1,24 @@ +{% set RESOURCE_NAV = ${RESOURCE_NAV} -%} +{% import 'macros/navigation.html' as navigation %} + + +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
+ + +{% block scripts %} + + + + + + + + + + +{% endblock %} + + + diff --git a/modules/resources/resources.py b/modules/resources/resources.py index 3b84026e294..c672d967f39 100644 --- a/modules/resources/resources.py +++ b/modules/resources/resources.py @@ -47,6 +47,7 @@ def generate_resources(): generate_attackcon_page() generate_faq_page() generate_static_pages() + generate_sidebar_check() def copy_docs(module_docs_path): @@ -355,3 +356,14 @@ def generate_working_with_attack(): os.path.join(site_config.resources_markdown_path, "working_with_attack.md"), "w", encoding="utf8" ) as md_file: md_file.write(working_with_attack_content) + +def generate_sidebar_check(): + """Responsible for generating the markdown pages of the training pages.""" + logger.info("Generating sidebar") + + # Training Overview + sidebar_check_md = resources_config.sidebar_check_md + + # write markdown to file + with open(os.path.join(site_config.resources_markdown_path, "sidebar_check.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_check_md) diff --git a/modules/resources/resources_config.py b/modules/resources/resources_config.py index 5c438a74dad..63717f041da 100644 --- a/modules/resources/resources_config.py +++ b/modules/resources/resources_config.py @@ -45,3 +45,9 @@ "save_as: resources/working-with-attack/index.html\n" "data: " ) + +sidebar_check_md = ( + "Title: Resources Sidebar\n" + "Template: general/sidebar-work \n" + "save_as: resources/sidebar-check/index.html\n" +) diff --git a/modules/resources/templates/attackcon.html b/modules/resources/templates/attackcon.html index 65077751a2b..bb96d57af8a 100644 --- a/modules/resources/templates/attackcon.html +++ b/modules/resources/templates/attackcon.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/brand.html b/modules/resources/templates/brand.html index 1dca4d9ed14..68588fa3374 100644 --- a/modules/resources/templates/brand.html +++ b/modules/resources/templates/brand.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
- -
+ {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/getting-started.html b/modules/resources/templates/getting-started.html index b09af711a2b..df17c4f3d42 100644 --- a/modules/resources/templates/getting-started.html +++ b/modules/resources/templates/getting-started.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/related-projects.html b/modules/resources/templates/related-projects.html index 8e3e4bc9216..dec2f71ca23 100644 --- a/modules/resources/templates/related-projects.html +++ b/modules/resources/templates/related-projects.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/resources.html b/modules/resources/templates/resources.html index 87fc196bf2e..a5d46ca41a5 100644 --- a/modules/resources/templates/resources.html +++ b/modules/resources/templates/resources.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/training-cti.html b/modules/resources/templates/training-cti.html index 2753b5f28c1..18707180aa4 100644 --- a/modules/resources/templates/training-cti.html +++ b/modules/resources/templates/training-cti.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/training.html b/modules/resources/templates/training.html index ff2708b5f64..25cc79e39bd 100644 --- a/modules/resources/templates/training.html +++ b/modules/resources/templates/training.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/update-post.html b/modules/resources/templates/update-post.html index a9d765c770f..630c594ecd0 100644 --- a/modules/resources/templates/update-post.html +++ b/modules/resources/templates/update-post.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/resources/templates/updates-index.html b/modules/resources/templates/updates-index.html index cde0067be0a..8092782093c 100644 --- a/modules/resources/templates/updates-index.html +++ b/modules/resources/templates/updates-index.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} {{ super () }} diff --git a/modules/resources/templates/working-with-attack.html b/modules/resources/templates/working-with-attack.html index b552c6872d8..706acdcdc89 100644 --- a/modules/resources/templates/working-with-attack.html +++ b/modules/resources/templates/working-with-attack.html @@ -6,9 +6,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
-
{% endblock %} {% block innerright %} diff --git a/modules/techniques/techniques.py b/modules/techniques/techniques.py index e5ab5e051c0..d7e1756bd61 100644 --- a/modules/techniques/techniques.py +++ b/modules/techniques/techniques.py @@ -58,7 +58,7 @@ def generate_techniques(): if not technique_generated: if check_if_generated: technique_generated = True - + generate_sidebar_technique(side_nav_data) if not technique_generated: util.buildhelpers.remove_module_from_menu(techniques_config.module_name) @@ -612,3 +612,16 @@ def get_datasources_and_components_of_technique(technique, reference_list): datasource_and_components = sorted(datasource_and_components, key=lambda k: k["name"].lower()) return datasource_and_components, show_descriptions + +def generate_sidebar_technique(side_nav_data): + """Responsible for generating the markdown pages of the training pages.""" + logger.info("Generating technique sidebar") + data = {} + data["menu"] = side_nav_data + + # Training Overview + sidebar_check_md = techniques_config.sidebar_technique_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(techniques_config.techniques_markdown_path, "sidebar_check.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_check_md) diff --git a/modules/techniques/techniques_config.py b/modules/techniques/techniques_config.py index d3947171d3a..bdccf92e4a1 100644 --- a/modules/techniques/techniques_config.py +++ b/modules/techniques/techniques_config.py @@ -42,3 +42,10 @@ "save_as: techniques/${parent_id}/${sub_number}/index.html\n" "data: " ) + +sidebar_technique_md = ( + "Title: Techniques Sidebar\n" + "Template: general/sidebar-technique-work \n" + "save_as: techniques/sidebar-check/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 12faafebbbf..2bcc3375635 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -37,9 +37,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.menu, output_file) }} -
+ {% endblock %} @@ -456,4 +454,8 @@

Difficulty for the Adversary

{% else %} {% endif %} + + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index 0f4d018a689..161a55dc780 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -23,9 +23,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.menu, output_file) }} -
+ {% endblock %} @@ -87,4 +85,7 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{{ super() }} + {% endblock %} \ No newline at end of file diff --git a/modules/website_build/website_build.py b/modules/website_build/website_build.py index 1270d672d3c..dd0e506d308 100644 --- a/modules/website_build/website_build.py +++ b/modules/website_build/website_build.py @@ -142,6 +142,26 @@ def generate_base_html(): with open(os.path.join(website_build_config.template_dir, "base.html"), "w", encoding="utf8") as base_template_f: base_template_f.write(subs) + + with open( + os.path.join(website_build_config.template_dir, "sidebar-test.html"), "r", encoding="utf8" + ) as sidebar_template_f: + sidebar_template = sidebar_template_f.read() + sidebar_template = Template(sidebar_template) + subs = sidebar_template.substitute(website_build_config.sidebar_page_data) + + with open(os.path.join(website_build_config.template_dir, "sidebar-work.html"), "w", encoding="utf8") as sidebar_template_f: + sidebar_template_f.write(subs) + + with open( + os.path.join(website_build_config.template_dir, "sidebar-technique.html"), "r", encoding="utf8" + ) as sidebar_template_f: + sidebar_template = sidebar_template_f.read() + sidebar_template = Template(sidebar_template) + subs = sidebar_template.substitute(website_build_config.base_page_data) + + with open(os.path.join(website_build_config.template_dir, "sidebar-technique-work.html"), "w", encoding="utf8") as sidebar_template_f: + sidebar_template_f.write(subs) def generate_index_page(): diff --git a/modules/website_build/website_build_config.py b/modules/website_build/website_build_config.py index 2220f1f8c27..86512e1b851 100644 --- a/modules/website_build/website_build_config.py +++ b/modules/website_build/website_build_config.py @@ -32,6 +32,10 @@ "RESOURCE_NAV": site_config.resource_nav, } +sidebar_page_data = { + "RESOURCE_NAV": site_config.resource_nav, +} + # config for the matrix shown on the index page index_matrix = { "name": "ATT&CK Matrix for Enterprise", From cb6db1445196390253d6438121276302b3992952 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Thu, 14 Sep 2023 09:55:59 -0400 Subject: [PATCH 13/51] fn renaming --- modules/assets/assets.py | 12 ++++----- modules/techniques/techniques.py | 8 +++--- modules/techniques/templates/technique.html | 2 +- modules/util/relationshipgetters.py | 28 ++++++++++----------- modules/util/relationshiphelpers.py | 8 +++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index bff21055651..3cc2083b471 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -120,7 +120,7 @@ def generate_asset_md(asset, side_menu_data, notes): data["deprecated"] = True # Get technique data for technique table - data["technique_table_data"] = get_techniques_targeted_by_asset_data(asset, reference_list) + data["technique_table_data"] = get_techniques_targeting_asset_data(asset, reference_list) # Get navigator layers for this asset layers = util.buildhelpers.get_navigator_layers( @@ -223,15 +223,15 @@ def get_related_asset_data(related_assets): return related_asset_data -def get_techniques_targeted_by_asset_data(asset, reference_list): - """Given an asset and its reference list, get the techniques targeted by the asset. +def get_techniques_targeting_asset_data(asset, reference_list): + """Given an asset and its reference list, get the techniques targeting the asset. Check the reference list for citations, if not found in list, add it. """ technique_list = {} - techniques_targeted_by_assets = util.relationshipgetters.get_techniques_targeted_by_assets() + techniques_targeting_assets = util.relationshipgetters.get_techniques_targeting_assets() - if techniques_targeted_by_assets.get(asset.get("id")): - for technique in techniques_targeted_by_assets[asset["id"]]: + if techniques_targeting_assets.get(asset.get("id")): + for technique in techniques_targeting_assets[asset["id"]]: # Do not add if technique is deprecated if not technique["object"].get("x_mitre_deprecated"): technique_list = util.buildhelpers.technique_used_helper(technique_list, technique, reference_list) diff --git a/modules/techniques/techniques.py b/modules/techniques/techniques.py index 590b66800dc..1c5980aaab8 100644 --- a/modules/techniques/techniques.py +++ b/modules/techniques/techniques.py @@ -379,17 +379,17 @@ def get_mitigations_table_data(technique, reference_list): def get_assets_table_data(technique, reference_list): - """Given a technique a reference list, find assets that target the + """Given a technique a reference list, find assets that are targeted by the technique and return list with asset data. Also modifies the reference list if it finds a reference that is not on the list """ asset_data = [] # Check if technique has assets - assets_targeting_techniques = util.relationshipgetters.get_assets_targeting_techniques().get(technique["id"]) - if assets_targeting_techniques: + assets_targeted_by_techniques = util.relationshipgetters.get_assets_targeted_by_techniques().get(technique["id"]) + if assets_targeted_by_techniques: # Iterate through technique assets - for asset in assets_targeting_techniques: + for asset in assets_targeted_by_techniques: # Do not add deprecated assets to table if not asset["object"].get("x_mitre_deprecated"): attack_id = util.buildhelpers.get_attack_id(asset["object"]) diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 988270c6820..d48ca8ff05d 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -370,7 +370,7 @@

Procedure Examples

{% endif %} {% if parsed.assets_table %} -

Assets

+

Targeted Assets

diff --git a/modules/util/relationshipgetters.py b/modules/util/relationshipgetters.py index 05a0ff94dc7..ff92451a1a0 100644 --- a/modules/util/relationshipgetters.py +++ b/modules/util/relationshipgetters.py @@ -11,7 +11,7 @@ techniques_used_by_tools = {} techniques_used_by_groups = {} techniques_used_by_campaigns = {} -techniques_targeted_by_assets = {} +techniques_targeting_assets = {} techniques_detected_by_datacomponent = {} groups_using_tool = {} groups_using_malware = {} @@ -21,7 +21,7 @@ tools_using_technique = {} malware_using_technique = {} groups_using_technique = {} -assets_targeting_techniques = {} +assets_targeted_by_techniques = {} campaigns_using_technique = {} campaigns_using_tool = {} campaigns_using_malware = {} @@ -133,24 +133,24 @@ def get_techniques_used_by_campaigns(): return techniques_used_by_campaigns -def get_techniques_targeted_by_assets(): - """techniques targeted by assets getter""" - global techniques_targeted_by_assets +def get_techniques_targeting_assets(): + """techniques targeting assets getter""" + global techniques_targeting_assets - if not techniques_targeted_by_assets: - techniques_targeted_by_assets = rsh.techniques_targeted_by_assets(get_srcs()) + if not techniques_targeting_assets: + techniques_targeting_assets = rsh.techniques_targeting_assets(get_srcs()) - return techniques_targeted_by_assets + return techniques_targeting_assets -def get_assets_targeting_techniques(): - """assets targeting techniques getter""" - global assets_targeting_techniques +def get_assets_targeted_by_techniques(): + """assets targeted by techniques getter""" + global assets_targeted_by_techniques - if not assets_targeting_techniques: - assets_targeting_techniques = rsh.assets_targeting_techniques(get_srcs()) + if not assets_targeted_by_techniques: + assets_targeted_by_techniques = rsh.assets_targeted_by_techniques(get_srcs()) - return assets_targeting_techniques + return assets_targeted_by_techniques def get_techniques_detected_by_datacomponent(): global techniques_detected_by_datacomponent diff --git a/modules/util/relationshiphelpers.py b/modules/util/relationshiphelpers.py index 9e9b54caf54..3a8d42db620 100644 --- a/modules/util/relationshiphelpers.py +++ b/modules/util/relationshiphelpers.py @@ -248,15 +248,15 @@ def campaigns_attributed_to_group(srcs): # technique:asset -def techniques_targeted_by_assets(srcs): - """Return asset_id => {technique, relationship} for each technique targeted by the asset. +def techniques_targeting_assets(srcs): + """Return asset_id => {technique, relationship} for each technique targeting the asset. srcs should be an array of memorystores for enterprise, mobile, and pre """ return get_related(srcs, "attack-pattern", "targets", "x-mitre-asset", reverse=True) -def assets_targeting_techniques(srcs): - """Return technique_id => {asset, relationship} for each asset targeting the technique. +def assets_targeted_by_techniques(srcs): + """Return technique_id => {asset, relationship} for each asset targeted by the technique. srcs should be an array of memorystores for enterprise, mobile, and pre """ From f61a152df26413fd6f80e8a80618199ce3eabd96 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 00:18:04 -0400 Subject: [PATCH 14/51] progress on active class --- attack-theme/static/scripts/sidebar-load.js | 17 ++++++++++++++++- modules/techniques/templates/technique.html | 10 +++++++++- .../templates/techniques-domain-index.html | 10 +++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/attack-theme/static/scripts/sidebar-load.js b/attack-theme/static/scripts/sidebar-load.js index 3a9b81c1794..80c9c35ed9f 100644 --- a/attack-theme/static/scripts/sidebar-load.js +++ b/attack-theme/static/scripts/sidebar-load.js @@ -1 +1,16 @@ -$("#sidebars").load("/resources/sidebar-check"); \ No newline at end of file +$("#sidebars").load("/resources/sidebar-check", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + console.log(element) + console.log(element.parentNode) + $(element.parentNode).addClass("active") + }}); +}); \ No newline at end of file diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 2bcc3375635..b5419b245e2 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -455,7 +455,15 @@

Difficulty for the Adversary

{% endif %} {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index 161a55dc780..5fc6e01872e 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -86,6 +86,14 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{% endblock %} \ No newline at end of file From 4017dbaa9a07c945fa8af8632f358817a21c2114 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 11:48:33 -0400 Subject: [PATCH 15/51] code cleanup --- ...ebar-load.js => sidebar-load-resources.js} | 4 +--- .../static/scripts/sidebar-load-techniques.js | 14 +++++++++++ .../templates/general/attackcon-overview.html | 2 +- .../templates/general/intro-overview.html | 2 +- .../general/sidebar-resources-template.html | 13 ++++++++++ .../general/sidebar-techniques-template.html | 13 ++++++++++ .../templates/general/sidebar-test.html | 24 ------------------- modules/resources/resources.py | 12 +++++----- modules/resources/resources_config.py | 6 ++--- modules/resources/templates/attackcon.html | 2 +- modules/resources/templates/brand.html | 2 +- .../resources/templates/getting-started.html | 2 +- .../resources/templates/related-projects.html | 2 +- modules/resources/templates/resources.html | 2 +- modules/resources/templates/training-cti.html | 2 +- modules/resources/templates/training.html | 2 +- modules/resources/templates/update-post.html | 2 +- .../resources/templates/updates-index.html | 2 +- .../templates/working-with-attack.html | 2 +- modules/techniques/techniques.py | 10 ++++---- modules/techniques/techniques_config.py | 6 ++--- modules/techniques/templates/technique.html | 15 ++---------- .../templates/techniques-domain-index.html | 15 ++---------- .../website_build/templates/changelog.html | 2 +- modules/website_build/templates/faq.html | 2 +- modules/website_build/website_build.py | 8 +++---- 26 files changed, 80 insertions(+), 88 deletions(-) rename attack-theme/static/scripts/{sidebar-load.js => sidebar-load-resources.js} (75%) create mode 100644 attack-theme/static/scripts/sidebar-load-techniques.js create mode 100644 attack-theme/templates/general/sidebar-resources-template.html create mode 100644 attack-theme/templates/general/sidebar-techniques-template.html delete mode 100644 attack-theme/templates/general/sidebar-test.html diff --git a/attack-theme/static/scripts/sidebar-load.js b/attack-theme/static/scripts/sidebar-load-resources.js similarity index 75% rename from attack-theme/static/scripts/sidebar-load.js rename to attack-theme/static/scripts/sidebar-load-resources.js index 80c9c35ed9f..eac62745a51 100644 --- a/attack-theme/static/scripts/sidebar-load.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -1,4 +1,4 @@ -$("#sidebars").load("/resources/sidebar-check", function() { +$("#sidebars").load("/resources/sidebar-resources", function() { var navElements = document.querySelectorAll('.sidenav-head > a'); var winlocation; navElements.forEach(function(element){ @@ -9,8 +9,6 @@ $("#sidebars").load("/resources/sidebar-check", function() { winlocation = window.location.href } if(element.href == winlocation){ - console.log(element) - console.log(element.parentNode) $(element.parentNode).addClass("active") }}); }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-techniques.js b/attack-theme/static/scripts/sidebar-load-techniques.js new file mode 100644 index 00000000000..6627c114203 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-techniques.js @@ -0,0 +1,14 @@ +$("#sidebars").load("/techniques/sidebar-techniques", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + }); \ No newline at end of file diff --git a/attack-theme/templates/general/attackcon-overview.html b/attack-theme/templates/general/attackcon-overview.html index 3e8f2c20f1f..caa2d847b31 100644 --- a/attack-theme/templates/general/attackcon-overview.html +++ b/attack-theme/templates/general/attackcon-overview.html @@ -115,5 +115,5 @@

Sponsors

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index 20730db83d5..a2d6de9e413 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -25,5 +25,5 @@

{{ page.title }}

{% block scripts %} {{ super () }} - + {% endblock %} diff --git a/attack-theme/templates/general/sidebar-resources-template.html b/attack-theme/templates/general/sidebar-resources-template.html new file mode 100644 index 00000000000..faf0d7f70fd --- /dev/null +++ b/attack-theme/templates/general/sidebar-resources-template.html @@ -0,0 +1,13 @@ +{% set RESOURCE_NAV = ${RESOURCE_NAV} -%} +{% import 'macros/navigation.html' as navigation %} + + +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
+ + +{% block scripts %} + + +{% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/sidebar-techniques-template.html b/attack-theme/templates/general/sidebar-techniques-template.html new file mode 100644 index 00000000000..b88b6ad2181 --- /dev/null +++ b/attack-theme/templates/general/sidebar-techniques-template.html @@ -0,0 +1,13 @@ +{% import 'macros/navigation.html' as navigation %} +{% set parsed = page.data | from_json %} + + +
+ {{ navigation.sidenav(parsed.menu, output_file) }} +
+ + +{% block scripts %} + + +{% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/sidebar-test.html b/attack-theme/templates/general/sidebar-test.html deleted file mode 100644 index 8e948613be7..00000000000 --- a/attack-theme/templates/general/sidebar-test.html +++ /dev/null @@ -1,24 +0,0 @@ -{% set RESOURCE_NAV = ${RESOURCE_NAV} -%} -{% import 'macros/navigation.html' as navigation %} - - -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
- - -{% block scripts %} - - - - - - - - - - -{% endblock %} - - - diff --git a/modules/resources/resources.py b/modules/resources/resources.py index c672d967f39..daa3d612260 100644 --- a/modules/resources/resources.py +++ b/modules/resources/resources.py @@ -47,7 +47,7 @@ def generate_resources(): generate_attackcon_page() generate_faq_page() generate_static_pages() - generate_sidebar_check() + generate_sidebar_resources() def copy_docs(module_docs_path): @@ -357,13 +357,13 @@ def generate_working_with_attack(): ) as md_file: md_file.write(working_with_attack_content) -def generate_sidebar_check(): - """Responsible for generating the markdown pages of the training pages.""" +def generate_sidebar_resources(): + """Responsible for generating the markdown pages of the resources sidebar.""" logger.info("Generating sidebar") # Training Overview - sidebar_check_md = resources_config.sidebar_check_md + sidebar_resources_md = resources_config.sidebar_resources_md # write markdown to file - with open(os.path.join(site_config.resources_markdown_path, "sidebar_check.md"), "w", encoding="utf8") as md_file: - md_file.write(sidebar_check_md) + with open(os.path.join(site_config.resources_markdown_path, "sidebar_resources.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_resources_md) diff --git a/modules/resources/resources_config.py b/modules/resources/resources_config.py index 63717f041da..4d9bfc8a73f 100644 --- a/modules/resources/resources_config.py +++ b/modules/resources/resources_config.py @@ -46,8 +46,8 @@ "data: " ) -sidebar_check_md = ( +sidebar_resources_md = ( "Title: Resources Sidebar\n" - "Template: general/sidebar-work \n" - "save_as: resources/sidebar-check/index.html\n" + "Template: general/sidebar-resources \n" + "save_as: resources/sidebar-resources/index.html\n" ) diff --git a/modules/resources/templates/attackcon.html b/modules/resources/templates/attackcon.html index bb96d57af8a..adddec40bdd 100644 --- a/modules/resources/templates/attackcon.html +++ b/modules/resources/templates/attackcon.html @@ -131,5 +131,5 @@

Sponsors

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/brand.html b/modules/resources/templates/brand.html index 68588fa3374..3a937ee69da 100644 --- a/modules/resources/templates/brand.html +++ b/modules/resources/templates/brand.html @@ -76,5 +76,5 @@

Brand Guide

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/getting-started.html b/modules/resources/templates/getting-started.html index df17c4f3d42..714612e9e57 100644 --- a/modules/resources/templates/getting-started.html +++ b/modules/resources/templates/getting-started.html @@ -261,5 +261,5 @@

Community

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/related-projects.html b/modules/resources/templates/related-projects.html index dec2f71ca23..7b811b180bd 100644 --- a/modules/resources/templates/related-projects.html +++ b/modules/resources/templates/related-projects.html @@ -114,5 +114,5 @@
- + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/resources.html b/modules/resources/templates/resources.html index a5d46ca41a5..53d033922f9 100644 --- a/modules/resources/templates/resources.html +++ b/modules/resources/templates/resources.html @@ -155,5 +155,5 @@

Other Resources

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training-cti.html b/modules/resources/templates/training-cti.html index 18707180aa4..cc4659e6cf6 100644 --- a/modules/resources/templates/training-cti.html +++ b/modules/resources/templates/training-cti.html @@ -282,5 +282,5 @@

Exercise 5: Making defensive recommendations {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training.html b/modules/resources/templates/training.html index 25cc79e39bd..ec069448c1f 100644 --- a/modules/resources/templates/training.html +++ b/modules/resources/templates/training.html @@ -47,5 +47,5 @@

ATT&CK Training

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/update-post.html b/modules/resources/templates/update-post.html index 630c594ecd0..5a02cbf8ecd 100644 --- a/modules/resources/templates/update-post.html +++ b/modules/resources/templates/update-post.html @@ -22,5 +22,5 @@

{{ article.title }}

{% endblock %} {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/updates-index.html b/modules/resources/templates/updates-index.html index 8092782093c..5a072b27f38 100644 --- a/modules/resources/templates/updates-index.html +++ b/modules/resources/templates/updates-index.html @@ -24,5 +24,5 @@

{{ (articles|selectattr('template', 'equalto', {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/working-with-attack.html b/modules/resources/templates/working-with-attack.html index 706acdcdc89..c3bce071c51 100644 --- a/modules/resources/templates/working-with-attack.html +++ b/modules/resources/templates/working-with-attack.html @@ -192,5 +192,5 @@

Explore our standa {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/techniques.py b/modules/techniques/techniques.py index d7e1756bd61..4187080233a 100644 --- a/modules/techniques/techniques.py +++ b/modules/techniques/techniques.py @@ -58,7 +58,7 @@ def generate_techniques(): if not technique_generated: if check_if_generated: technique_generated = True - generate_sidebar_technique(side_nav_data) + generate_sidebar_techniques(side_nav_data) if not technique_generated: util.buildhelpers.remove_module_from_menu(techniques_config.module_name) @@ -613,15 +613,15 @@ def get_datasources_and_components_of_technique(technique, reference_list): return datasource_and_components, show_descriptions -def generate_sidebar_technique(side_nav_data): +def generate_sidebar_techniques(side_nav_data): """Responsible for generating the markdown pages of the training pages.""" logger.info("Generating technique sidebar") data = {} data["menu"] = side_nav_data # Training Overview - sidebar_check_md = techniques_config.sidebar_technique_md + json.dumps(data) + sidebar_techniques_md = techniques_config.sidebar_techniques_md + json.dumps(data) # write markdown to file - with open(os.path.join(techniques_config.techniques_markdown_path, "sidebar_check.md"), "w", encoding="utf8") as md_file: - md_file.write(sidebar_check_md) + with open(os.path.join(techniques_config.techniques_markdown_path, "sidebar_techniques.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_techniques_md) diff --git a/modules/techniques/techniques_config.py b/modules/techniques/techniques_config.py index bdccf92e4a1..32fb984782f 100644 --- a/modules/techniques/techniques_config.py +++ b/modules/techniques/techniques_config.py @@ -43,9 +43,9 @@ "data: " ) -sidebar_technique_md = ( +sidebar_techniques_md = ( "Title: Techniques Sidebar\n" - "Template: general/sidebar-technique-work \n" - "save_as: techniques/sidebar-check/index.html\n" + "Template: general/sidebar-techniques \n" + "save_as: techniques/sidebar-techniques/index.html\n" "data: " ) \ No newline at end of file diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index b5419b245e2..1d23f7cab9a 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -37,7 +37,7 @@ {% block innerleft %} - + {% endblock %} @@ -446,7 +446,6 @@

Difficulty for the Adversary

{% block scripts %} {{ super() }} - {% if parsed.is_subtechnique %} @@ -454,16 +453,6 @@

Difficulty for the Adversary

{% else %} {% endif %} - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index 5fc6e01872e..8b5869e8635 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -23,7 +23,7 @@ {% block innerleft %} - + {% endblock %} @@ -84,16 +84,5 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{% block scripts %} {{ super() }} - - + {% endblock %} \ No newline at end of file diff --git a/modules/website_build/templates/changelog.html b/modules/website_build/templates/changelog.html index ad102713775..70bae85cb24 100644 --- a/modules/website_build/templates/changelog.html +++ b/modules/website_build/templates/changelog.html @@ -35,5 +35,5 @@

Changelog

{% endblock %} {% block scripts %} {{ super () }} - + {% endblock %} diff --git a/modules/website_build/templates/faq.html b/modules/website_build/templates/faq.html index 182b096ed7d..b6baf2c7bb5 100644 --- a/modules/website_build/templates/faq.html +++ b/modules/website_build/templates/faq.html @@ -48,5 +48,5 @@
{{qa.question}}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/website_build/website_build.py b/modules/website_build/website_build.py index dd0e506d308..1654c1d1179 100644 --- a/modules/website_build/website_build.py +++ b/modules/website_build/website_build.py @@ -144,23 +144,23 @@ def generate_base_html(): base_template_f.write(subs) with open( - os.path.join(website_build_config.template_dir, "sidebar-test.html"), "r", encoding="utf8" + os.path.join(website_build_config.template_dir, "sidebar-resources-template.html"), "r", encoding="utf8" ) as sidebar_template_f: sidebar_template = sidebar_template_f.read() sidebar_template = Template(sidebar_template) subs = sidebar_template.substitute(website_build_config.sidebar_page_data) - with open(os.path.join(website_build_config.template_dir, "sidebar-work.html"), "w", encoding="utf8") as sidebar_template_f: + with open(os.path.join(website_build_config.template_dir, "sidebar-resources.html"), "w", encoding="utf8") as sidebar_template_f: sidebar_template_f.write(subs) with open( - os.path.join(website_build_config.template_dir, "sidebar-technique.html"), "r", encoding="utf8" + os.path.join(website_build_config.template_dir, "sidebar-techniques-template.html"), "r", encoding="utf8" ) as sidebar_template_f: sidebar_template = sidebar_template_f.read() sidebar_template = Template(sidebar_template) subs = sidebar_template.substitute(website_build_config.base_page_data) - with open(os.path.join(website_build_config.template_dir, "sidebar-technique-work.html"), "w", encoding="utf8") as sidebar_template_f: + with open(os.path.join(website_build_config.template_dir, "sidebar-techniques.html"), "w", encoding="utf8") as sidebar_template_f: sidebar_template_f.write(subs) From 5564a8c40755c52fb7d2c957fcc75f860045615d Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 12:11:43 -0400 Subject: [PATCH 16/51] code cleanup part two --- modules/website_build/website_build.py | 41 +++++++++++++++----------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/modules/website_build/website_build.py b/modules/website_build/website_build.py index 1654c1d1179..fe790e725fa 100644 --- a/modules/website_build/website_build.py +++ b/modules/website_build/website_build.py @@ -31,6 +31,7 @@ def generate_website(): ) generate_javascript_settings() generate_base_html() + generate_sidebar_html() generate_index_page() generate_static_pages() generate_changelog_page() @@ -142,26 +143,30 @@ def generate_base_html(): with open(os.path.join(website_build_config.template_dir, "base.html"), "w", encoding="utf8") as base_template_f: base_template_f.write(subs) - - with open( - os.path.join(website_build_config.template_dir, "sidebar-resources-template.html"), "r", encoding="utf8" - ) as sidebar_template_f: - sidebar_template = sidebar_template_f.read() - sidebar_template = Template(sidebar_template) - subs = sidebar_template.substitute(website_build_config.sidebar_page_data) - - with open(os.path.join(website_build_config.template_dir, "sidebar-resources.html"), "w", encoding="utf8") as sidebar_template_f: - sidebar_template_f.write(subs) - with open( - os.path.join(website_build_config.template_dir, "sidebar-techniques-template.html"), "r", encoding="utf8" - ) as sidebar_template_f: - sidebar_template = sidebar_template_f.read() - sidebar_template = Template(sidebar_template) - subs = sidebar_template.substitute(website_build_config.base_page_data) +def generate_sidebar_html(): + with open( + os.path.join(website_build_config.template_dir, "sidebar-resources-template.html"), "r", encoding="utf8" + ) as sidebar_template_f: + sidebar_template = sidebar_template_f.read() + sidebar_template = Template(sidebar_template) + subs = sidebar_template.substitute(website_build_config.sidebar_page_data) + + with open(os.path.join(website_build_config.template_dir, "sidebar-resources.html"), "w", encoding="utf8") as sidebar_template_f: + sidebar_template_f.write(subs) + + with open( + os.path.join(website_build_config.template_dir, "sidebar-techniques-template.html"), "r", encoding="utf8" + ) as sidebar_template_f: + sidebar_template = sidebar_template_f.read() + sidebar_template = Template(sidebar_template) + print(sidebar_template) + subs = sidebar_template.substitute(website_build_config.base_page_data) + print("boo") + print(subs) - with open(os.path.join(website_build_config.template_dir, "sidebar-techniques.html"), "w", encoding="utf8") as sidebar_template_f: - sidebar_template_f.write(subs) + with open(os.path.join(website_build_config.template_dir, "sidebar-techniques.html"), "w", encoding="utf8") as sidebar_template_f: + sidebar_template_f.write(subs) def generate_index_page(): From ee4b1d1f9d60aae1ff62638e915a525b3858d9f4 Mon Sep 17 00:00:00 2001 From: Jared Ondricek <90368810+jondricek@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:18:54 -0500 Subject: [PATCH 17/51] Update assets.py --- modules/assets/assets.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index 3cc2083b471..98cceaaacd0 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -11,9 +11,7 @@ def generate_assets(): - """ - Responsible for verifying asset directory and starting off asset markdown generation. - """ + """Responsible for verifying asset directory and starting off asset markdown generation.""" # Create content pages directory if does not already exist util.buildhelpers.create_content_pages_dir() From dae4c9c63c38e35e08965f924a488d70a1608316 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 12:36:27 -0400 Subject: [PATCH 18/51] resources page complete --- attack-theme/templates/general/faq-overview.html | 6 ++---- attack-theme/templates/general/intro-overview.html | 4 +--- modules/website_build/templates/changelog.html | 4 +--- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/attack-theme/templates/general/faq-overview.html b/attack-theme/templates/general/faq-overview.html index b1b039b1d1d..75bb278d889 100644 --- a/attack-theme/templates/general/faq-overview.html +++ b/attack-theme/templates/general/faq-overview.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
+ {% endblock %} {% block innerright %} @@ -64,5 +62,5 @@
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index a2d6de9e413..c3d00c73852 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
+ {% endblock %} {% block innerright %} diff --git a/modules/website_build/templates/changelog.html b/modules/website_build/templates/changelog.html index 70bae85cb24..8b395642d85 100644 --- a/modules/website_build/templates/changelog.html +++ b/modules/website_build/templates/changelog.html @@ -4,9 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
+ {% endblock %} {% block innerright %} From 4ce3fd0557301e24564a8e1e88c07ce96ae13b6f Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 15:25:16 -0400 Subject: [PATCH 19/51] software side bar done --- .../static/scripts/sidebar-load-software.js | 14 ++++++++++++++ ...niques-template.html => sidebar-template.html} | 0 modules/resources/resources.py | 6 +++--- modules/software/software.py | 15 ++++++++++++++- modules/software/software_config.py | 9 ++++++++- modules/software/templates/software-index.html | 6 ++---- modules/software/templates/software.html | 6 ++---- modules/techniques/techniques.py | 4 ++-- modules/techniques/techniques_config.py | 2 +- modules/website_build/website_build.py | 13 ------------- 10 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load-software.js rename attack-theme/templates/general/{sidebar-techniques-template.html => sidebar-template.html} (100%) diff --git a/attack-theme/static/scripts/sidebar-load-software.js b/attack-theme/static/scripts/sidebar-load-software.js new file mode 100644 index 00000000000..78af4ff4541 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-software.js @@ -0,0 +1,14 @@ +$("#sidebars").load("/software/sidebar-software", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + }); \ No newline at end of file diff --git a/attack-theme/templates/general/sidebar-techniques-template.html b/attack-theme/templates/general/sidebar-template.html similarity index 100% rename from attack-theme/templates/general/sidebar-techniques-template.html rename to attack-theme/templates/general/sidebar-template.html diff --git a/modules/resources/resources.py b/modules/resources/resources.py index daa3d612260..e29db36ee7b 100644 --- a/modules/resources/resources.py +++ b/modules/resources/resources.py @@ -358,10 +358,10 @@ def generate_working_with_attack(): md_file.write(working_with_attack_content) def generate_sidebar_resources(): - """Responsible for generating the markdown pages of the resources sidebar.""" - logger.info("Generating sidebar") + """Responsible for generating the sidebar for the resource pages.""" + logger.info("Generating resource sidebar") - # Training Overview + # Sidebar Overview sidebar_resources_md = resources_config.sidebar_resources_md # write markdown to file diff --git a/modules/software/software.py b/modules/software/software.py index b93a6faee0b..5a69a4a041b 100644 --- a/modules/software/software.py +++ b/modules/software/software.py @@ -30,7 +30,6 @@ def generate_software(): # Generates the markdown files to be used for page generation and verifies if a software was generated software_generated = generate_markdown_files() - if not software_generated: util.buildhelpers.remove_module_from_menu(software_config.module_name) @@ -55,6 +54,7 @@ def generate_markdown_files(): side_menu_data = util.buildhelpers.get_side_menu_data( "software", "/software/", software_list_no_deprecated_revoked ) + generate_sidebar_software(side_menu_data) data["side_menu_data"] = side_menu_data data["software_table"] = get_software_table_data(software_list_no_deprecated_revoked) @@ -350,3 +350,16 @@ def get_campaign_table_data(software, reference_list): campaign_data = [campaign_list[item] for item in campaign_list] campaign_data = sorted(campaign_data, key=lambda k: k["name"].lower()) return campaign_data + +def generate_sidebar_software(side_menu_data): + """Responsible for generating the sidebar for the software pages.""" + logger.info("Generating software sidebar") + data = {} + data["menu"] = side_menu_data + + # Sidebar Overview + sidebar_software_md = software_config.sidebar_software_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(software_config.software_markdown_path, "sidebar_software.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_software_md) \ No newline at end of file diff --git a/modules/software/software_config.py b/modules/software/software_config.py index 438da972ac9..304e3ca3a6f 100644 --- a/modules/software/software_config.py +++ b/modules/software/software_config.py @@ -21,4 +21,11 @@ "save_as: software/${attack_id}/index.html\n" "data: ") -software_redirection_location = "modules/software/software_redirections.json" \ No newline at end of file +software_redirection_location = "modules/software/software_redirections.json" + +sidebar_software_md = ( + "Title: Software Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: software/sidebar-software/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/software/templates/software-index.html b/modules/software/templates/software-index.html index 573481e8c33..51f90dc82e5 100644 --- a/modules/software/templates/software-index.html +++ b/modules/software/templates/software-index.html @@ -7,9 +7,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -87,5 +85,5 @@
Software: {{ parsed.software_list_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/software/templates/software.html b/modules/software/templates/software.html index 0e1275cf6e0..dd8c3d8780b 100644 --- a/modules/software/templates/software.html +++ b/modules/software/templates/software.html @@ -21,9 +21,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -242,7 +240,7 @@

Campaigns

{% block scripts %} {{ super() }} - + diff --git a/modules/techniques/techniques.py b/modules/techniques/techniques.py index 4187080233a..0e353212ea9 100644 --- a/modules/techniques/techniques.py +++ b/modules/techniques/techniques.py @@ -614,12 +614,12 @@ def get_datasources_and_components_of_technique(technique, reference_list): return datasource_and_components, show_descriptions def generate_sidebar_techniques(side_nav_data): - """Responsible for generating the markdown pages of the training pages.""" + """Responsible for generating the sidebar for the technique pages.""" logger.info("Generating technique sidebar") data = {} data["menu"] = side_nav_data - # Training Overview + # Sidebar Overview sidebar_techniques_md = techniques_config.sidebar_techniques_md + json.dumps(data) # write markdown to file diff --git a/modules/techniques/techniques_config.py b/modules/techniques/techniques_config.py index 32fb984782f..1679960fb7d 100644 --- a/modules/techniques/techniques_config.py +++ b/modules/techniques/techniques_config.py @@ -45,7 +45,7 @@ sidebar_techniques_md = ( "Title: Techniques Sidebar\n" - "Template: general/sidebar-techniques \n" + "Template: general/sidebar-template \n" "save_as: techniques/sidebar-techniques/index.html\n" "data: " ) \ No newline at end of file diff --git a/modules/website_build/website_build.py b/modules/website_build/website_build.py index fe790e725fa..dc7158a3f05 100644 --- a/modules/website_build/website_build.py +++ b/modules/website_build/website_build.py @@ -155,19 +155,6 @@ def generate_sidebar_html(): with open(os.path.join(website_build_config.template_dir, "sidebar-resources.html"), "w", encoding="utf8") as sidebar_template_f: sidebar_template_f.write(subs) - with open( - os.path.join(website_build_config.template_dir, "sidebar-techniques-template.html"), "r", encoding="utf8" - ) as sidebar_template_f: - sidebar_template = sidebar_template_f.read() - sidebar_template = Template(sidebar_template) - print(sidebar_template) - subs = sidebar_template.substitute(website_build_config.base_page_data) - print("boo") - print(subs) - - with open(os.path.join(website_build_config.template_dir, "sidebar-techniques.html"), "w", encoding="utf8") as sidebar_template_f: - sidebar_template_f.write(subs) - def generate_index_page(): """Responsible for creating the landing page""" From 4a68f7032297d4ef458f3c404715e7b07681eff4 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 16:08:37 -0400 Subject: [PATCH 20/51] mitigations done plus mobile fix --- .../scripts/sidebar-load-mitigations.js | 29 +++++++++++++++++++ .../static/scripts/sidebar-load-resources.js | 15 ++++++++++ .../static/scripts/sidebar-load-software.js | 15 ++++++++++ .../static/scripts/sidebar-load-techniques.js | 15 ++++++++++ modules/mitigations/mitigations.py | 15 +++++++++- modules/mitigations/mitigations_config.py | 7 +++++ modules/mitigations/templates/mitigation.html | 8 ++--- .../templates/mitigations-domain-index.html | 6 ++-- 8 files changed, 100 insertions(+), 10 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load-mitigations.js diff --git a/attack-theme/static/scripts/sidebar-load-mitigations.js b/attack-theme/static/scripts/sidebar-load-mitigations.js new file mode 100644 index 00000000000..95a4f64bf49 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-mitigations.js @@ -0,0 +1,29 @@ +$("#sidebars").load("/mitigations/sidebar-mitigations", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + }); + + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-resources.js index eac62745a51..d92cdef4e1a 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -11,4 +11,19 @@ $("#sidebars").load("/resources/sidebar-resources", function() { if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + }); + + mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-software.js b/attack-theme/static/scripts/sidebar-load-software.js index 78af4ff4541..f8a3e4a9759 100644 --- a/attack-theme/static/scripts/sidebar-load-software.js +++ b/attack-theme/static/scripts/sidebar-load-software.js @@ -11,4 +11,19 @@ $("#sidebars").load("/software/sidebar-software", function() { if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + }); + + mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-techniques.js b/attack-theme/static/scripts/sidebar-load-techniques.js index 6627c114203..d8f021c47ad 100644 --- a/attack-theme/static/scripts/sidebar-load-techniques.js +++ b/attack-theme/static/scripts/sidebar-load-techniques.js @@ -11,4 +11,19 @@ $("#sidebars").load("/techniques/sidebar-techniques", function() { if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + }); + + mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/modules/mitigations/mitigations.py b/modules/mitigations/mitigations.py index e6e6eb64e3c..98a5c15272c 100644 --- a/modules/mitigations/mitigations.py +++ b/modules/mitigations/mitigations.py @@ -54,7 +54,7 @@ def generate_mitigations(): if not mitigation_generated: if check_if_generated: mitigation_generated = True - + generate_sidebar_mitigations(side_nav_data) if not mitigation_generated: util.buildhelpers.remove_module_from_menu(mitigations_config.module_name) @@ -230,3 +230,16 @@ def get_techniques_addressed_data(mitigation, reference_list): technique_data, key=lambda k: [site_config.custom_alphabet.index(c) for c in k["domain"].lower()] ) return technique_data + +def generate_sidebar_mitigations(side_nav_data): + """Responsible for generating the sidebar for the mitigations pages.""" + logger.info("Generating mitigations sidebar") + data = {} + data["menu"] = side_nav_data + + # Sidebar Overview + sidebar_mitigations_md = mitigations_config.sidebar_mitigations_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(mitigations_config.mitigation_markdown_path, "sidebar_mitigations.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_mitigations_md) diff --git a/modules/mitigations/mitigations_config.py b/modules/mitigations/mitigations_config.py index 54d0d2987a0..f60ea69f4b4 100644 --- a/modules/mitigations/mitigations_config.py +++ b/modules/mitigations/mitigations_config.py @@ -32,3 +32,10 @@ "save_as: mitigations/${attack_id}/index.html\n" "data: " ) + +sidebar_mitigations_md = ( + "Title: Mitigations Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: mitigations/sidebar-mitigations/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/mitigations/templates/mitigation.html b/modules/mitigations/templates/mitigation.html index 95515399a6a..28f3a4eea4e 100644 --- a/modules/mitigations/templates/mitigation.html +++ b/modules/mitigations/templates/mitigation.html @@ -26,9 +26,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -111,5 +109,5 @@

{% block scripts %} {{ super() }} - -{% endblock %} \ No newline at end of file + + {% endblock %} \ No newline at end of file diff --git a/modules/mitigations/templates/mitigations-domain-index.html b/modules/mitigations/templates/mitigations-domain-index.html index 509ead41ec5..b62a5ff5200 100644 --- a/modules/mitigations/templates/mitigations-domain-index.html +++ b/modules/mitigations/templates/mitigations-domain-index.html @@ -14,9 +14,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -93,5 +91,5 @@

Mitigations: {{parsed.mitigation_list_len}}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file From 4baa5afbc141b188a4e7a7402a012034399fc3c8 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 16:43:01 -0400 Subject: [PATCH 21/51] groups done --- .../static/scripts/sidebar-load-groups.js | 29 +++++++++++++++++++ modules/groups/groups.py | 16 ++++++++++ modules/groups/groups_config.py | 7 +++++ modules/groups/templates/group.html | 6 ++-- modules/groups/templates/groups-index.html | 8 ++--- 5 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load-groups.js diff --git a/attack-theme/static/scripts/sidebar-load-groups.js b/attack-theme/static/scripts/sidebar-load-groups.js new file mode 100644 index 00000000000..deef75588c1 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-groups.js @@ -0,0 +1,29 @@ +$("#sidebars").load("/groups/sidebar-groups", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + }); + + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/modules/groups/groups.py b/modules/groups/groups.py index 5b2c888bd6c..9eb15d925fa 100644 --- a/modules/groups/groups.py +++ b/modules/groups/groups.py @@ -4,6 +4,8 @@ from modules import util +from loguru import logger + from . import groups_config from .. import site_config @@ -77,6 +79,7 @@ def generate_markdown_files(): for group in group_list: generate_group_md(group, side_menu_data, notes) + generate_sidebar_groups(side_menu_data) return has_group @@ -435,3 +438,16 @@ def update_software_list(pairings, software_list, reference_list, reference, id) software_list[software_stix_id]["techniques"].append(tech_data) return software_list, reference + +def generate_sidebar_groups(side_menu_data): + """Responsible for generating the sidebar for the groups pages.""" + logger.info("Generating groups sidebar") + data = {} + data["menu"] = side_menu_data + + # Sidebar Overview + sidebar_groups_md = groups_config.sidebar_groups_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(groups_config.group_markdown_path, "sidebar_groups.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_groups_md) diff --git a/modules/groups/groups_config.py b/modules/groups/groups_config.py index 24d8feb5d04..4377f12f423 100644 --- a/modules/groups/groups_config.py +++ b/modules/groups/groups_config.py @@ -16,3 +16,10 @@ groups_templates_path = "modules/groups/templates/" groups_redirection_location = "modules/groups/groups_redirections.json" + +sidebar_groups_md = ( + "Title: Groups Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: groups/sidebar-groups/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/groups/templates/group.html b/modules/groups/templates/group.html index c2247770c39..b6572096909 100644 --- a/modules/groups/templates/group.html +++ b/modules/groups/templates/group.html @@ -27,9 +27,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -266,7 +264,7 @@

Software

{% block scripts %} {{ super() }} - + diff --git a/modules/groups/templates/groups-index.html b/modules/groups/templates/groups-index.html index 382d907dd7a..80d9deb8109 100644 --- a/modules/groups/templates/groups-index.html +++ b/modules/groups/templates/groups-index.html @@ -7,9 +7,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -87,5 +85,5 @@
Groups: {{ parsed.groups_list_len }}
{% block scripts %} {{ super() }} - -{% endblock %} \ No newline at end of file + + {% endblock %} \ No newline at end of file From 0422b9a405fe8f195bccadecec9f95fe753f601c Mon Sep 17 00:00:00 2001 From: adpare Date: Mon, 18 Sep 2023 16:53:49 -0400 Subject: [PATCH 22/51] sidebar update. make calling function easier --- .../static/scripts/sidebar-load-resources.js | 14 +++++++++++--- modules/techniques/templates/technique.html | 2 +- .../templates/techniques-domain-index.html | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-resources.js index d92cdef4e1a..81d8363c81a 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -1,4 +1,6 @@ -$("#sidebars").load("/resources/sidebar-resources", function() { +let mod_name = window.location.pathname.split("/") +let mod_entry = "/" + mod_name[1] + "/sidebar-" + mod_name[1] +$("#sidebars").load(mod_entry, function() { var navElements = document.querySelectorAll('.sidenav-head > a'); var winlocation; navElements.forEach(function(element){ @@ -10,19 +12,25 @@ $("#sidebars").load("/resources/sidebar-resources", function() { } if(element.href == winlocation){ $(element.parentNode).addClass("active") + var parentElement = $(element.parentNode); + var elementID = document.getElementById(parentElement[0].id) + elementID.scrollIntoView({ behavior: "smooth", block: "center" }) }}); var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { if (e.matches) { - $('#sidebar-collapse').collapse('hide') + $('#sidenav-list').collapse('hide') } else{ - $('#sidebar-collapse').collapse('show') + $('#sidenav-list').collapse('show') } } $(document).ready(function() { mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ behavior: "smooth", block: "center" }) }); mediaQuery.addEventListener('change', mobileSidenav) diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 1d23f7cab9a..e8a82df901b 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -453,6 +453,6 @@

Difficulty for the Adversary

{% else %} {% endif %} - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index 8b5869e8635..d6cd0c85c65 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -84,5 +84,5 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file From b0127ad63744da7c186f079a292562a89672e050 Mon Sep 17 00:00:00 2001 From: adpare Date: Tue, 19 Sep 2023 13:56:55 -0400 Subject: [PATCH 23/51] loading content into view --- attack-theme/static/scripts/sidebar-load-groups.js | 3 +++ attack-theme/static/scripts/sidebar-load-mitigations.js | 3 +++ attack-theme/static/scripts/sidebar-load-resources.js | 2 +- attack-theme/static/scripts/sidebar-load-software.js | 3 +++ attack-theme/static/scripts/sidebar-load-techniques.js | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/attack-theme/static/scripts/sidebar-load-groups.js b/attack-theme/static/scripts/sidebar-load-groups.js index deef75588c1..8cce8dd6563 100644 --- a/attack-theme/static/scripts/sidebar-load-groups.js +++ b/attack-theme/static/scripts/sidebar-load-groups.js @@ -23,6 +23,9 @@ $("#sidebars").load("/groups/sidebar-groups", function() { } $(document).ready(function() { mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); mediaQuery.addEventListener('change', mobileSidenav) diff --git a/attack-theme/static/scripts/sidebar-load-mitigations.js b/attack-theme/static/scripts/sidebar-load-mitigations.js index 95a4f64bf49..1935da43b9c 100644 --- a/attack-theme/static/scripts/sidebar-load-mitigations.js +++ b/attack-theme/static/scripts/sidebar-load-mitigations.js @@ -23,6 +23,9 @@ $("#sidebars").load("/mitigations/sidebar-mitigations", function() { } $(document).ready(function() { mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); mediaQuery.addEventListener('change', mobileSidenav) diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-resources.js index 81d8363c81a..4d1c0309a05 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -30,7 +30,7 @@ $("#sidebars").load(mod_entry, function() { mobileSidenav(mediaQuery) let sidenav = $(".sidenav-list"); let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ behavior: "smooth", block: "center" }) + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); mediaQuery.addEventListener('change', mobileSidenav) diff --git a/attack-theme/static/scripts/sidebar-load-software.js b/attack-theme/static/scripts/sidebar-load-software.js index f8a3e4a9759..16d6e655ffe 100644 --- a/attack-theme/static/scripts/sidebar-load-software.js +++ b/attack-theme/static/scripts/sidebar-load-software.js @@ -23,6 +23,9 @@ $("#sidebars").load("/software/sidebar-software", function() { } $(document).ready(function() { mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); mediaQuery.addEventListener('change', mobileSidenav) diff --git a/attack-theme/static/scripts/sidebar-load-techniques.js b/attack-theme/static/scripts/sidebar-load-techniques.js index d8f021c47ad..acaaa70e5a4 100644 --- a/attack-theme/static/scripts/sidebar-load-techniques.js +++ b/attack-theme/static/scripts/sidebar-load-techniques.js @@ -23,6 +23,9 @@ $("#sidebars").load("/techniques/sidebar-techniques", function() { } $(document).ready(function() { mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); mediaQuery.addEventListener('change', mobileSidenav) From 5720a0bf9371dca341b06fdc50e5fab57fd04df0 Mon Sep 17 00:00:00 2001 From: adpare Date: Tue, 19 Sep 2023 14:47:00 -0400 Subject: [PATCH 24/51] matrices sidebar --- .../static/scripts/sidebar-load-matrices.js | 35 +++++++++++++++++++ modules/matrices/matrices.py | 15 +++++++- modules/matrices/matrices_config.py | 7 ++++ modules/matrices/templates/matrix.html | 4 ++- 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load-matrices.js diff --git a/attack-theme/static/scripts/sidebar-load-matrices.js b/attack-theme/static/scripts/sidebar-load-matrices.js new file mode 100644 index 00000000000..18367c59375 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-matrices.js @@ -0,0 +1,35 @@ +$("#sidebars").load("/matrices/sidebar-matrices", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(!element.href.endsWith("/")){ + element.href = element.href + "/"; + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + + mediaQuery.addEventListener('change', mobileSidenav) + }); \ No newline at end of file diff --git a/modules/matrices/matrices.py b/modules/matrices/matrices.py index bfd8a99ac07..22a3ab254bf 100644 --- a/modules/matrices/matrices.py +++ b/modules/matrices/matrices.py @@ -27,7 +27,7 @@ def generate_matrices(): notes = util.relationshipgetters.get_objects_using_notes() side_menu_data = util.buildhelpers.get_side_menu_matrices(matrices_config.matrices) - + generate_sidebar_matrices(side_menu_data) matrix_generated = False for matrix in matrices_config.matrices: @@ -259,3 +259,16 @@ def transform_tactic(tactic_id): ) return data, has_subtechniques, tour_technique + +def generate_sidebar_matrices(side_menu_data): + """Responsible for generating the sidebar for the matrices pages.""" + logger.info("Generating matrices sidebar") + data = {} + data["menu"] = side_menu_data + + # Sidebar Overview + sidebar_matrices_md = matrices_config.sidebar_matrices_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(matrices_config.matrix_markdown_path, "sidebar_matrices.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_matrices_md) diff --git a/modules/matrices/matrices_config.py b/modules/matrices/matrices_config.py index ef8f4d31377..6ecf34d27b8 100644 --- a/modules/matrices/matrices_config.py +++ b/modules/matrices/matrices_config.py @@ -30,6 +30,13 @@ "data: " ) +sidebar_matrices_md = ( + "Title: Matrices Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: matrices/sidebar-matrices/index.html\n" + "data: " +) + # The tree of matricies on /matrices/ matrices = [ { diff --git a/modules/matrices/templates/matrix.html b/modules/matrices/templates/matrix.html index a4c4624a9c5..226d16915d5 100644 --- a/modules/matrices/templates/matrix.html +++ b/modules/matrices/templates/matrix.html @@ -30,7 +30,7 @@ {% block innerleft %} - {{ navigation.sidenav(parsed.menu, output_file) }} + {% endblock %} @@ -124,4 +124,6 @@

{{parsed.name}} {{matrix_plural}}

+ + {% endblock %} From 47f57967b70ae56839c7fc18f359715ac4d314b0 Mon Sep 17 00:00:00 2001 From: adpare Date: Tue, 19 Sep 2023 15:10:19 -0400 Subject: [PATCH 25/51] tactics and campaigns --- .../static/scripts/sidebar-load-campaigns.js | 32 +++++++++++++++++++ .../static/scripts/sidebar-load-tactics.js | 32 +++++++++++++++++++ modules/campaigns/campaigns.py | 15 ++++++++- modules/campaigns/campaigns_config.py | 7 ++++ modules/campaigns/templates/campaign.html | 5 ++- .../campaigns/templates/campaigns-index.html | 5 ++- modules/tactics/tactics.py | 15 +++++++++ modules/tactics/tactics_config.py | 7 ++++ modules/tactics/templates/tactic.html | 5 ++- .../templates/tactics-domain-index.html | 5 ++- 10 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 attack-theme/static/scripts/sidebar-load-campaigns.js create mode 100644 attack-theme/static/scripts/sidebar-load-tactics.js diff --git a/attack-theme/static/scripts/sidebar-load-campaigns.js b/attack-theme/static/scripts/sidebar-load-campaigns.js new file mode 100644 index 00000000000..282b89f98e2 --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-campaigns.js @@ -0,0 +1,32 @@ +$("#sidebars").load("/campaigns/sidebar-campaigns", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-tactics.js b/attack-theme/static/scripts/sidebar-load-tactics.js new file mode 100644 index 00000000000..957a0a14a7d --- /dev/null +++ b/attack-theme/static/scripts/sidebar-load-tactics.js @@ -0,0 +1,32 @@ +$("#sidebars").load("/tactics/sidebar-tactics", function() { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav = $(".sidenav-list"); + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + + mediaQuery.addEventListener('change', mobileSidenav) + }); \ No newline at end of file diff --git a/modules/campaigns/campaigns.py b/modules/campaigns/campaigns.py index 0a4eba57575..c6e8b23de91 100644 --- a/modules/campaigns/campaigns.py +++ b/modules/campaigns/campaigns.py @@ -67,7 +67,7 @@ def generate_markdown_files(): data["campaigns_list_len"] = str(len(campaign_list_no_deprecated_revoked)) subs = campaigns_config.campaign_index_md + json.dumps(data) - + generate_sidebar_campaigns(side_menu_data) with open( os.path.join(campaigns_config.campaign_markdown_path, "overview.md"), "w", encoding="utf8" ) as md_file: @@ -307,3 +307,16 @@ def get_software_table_data(campaign, reference_list): software_data = [software_list[item] for item in software_list] software_data = sorted(software_data, key=lambda k: k["name"].lower()) return software_data + +def generate_sidebar_campaigns(side_menu_data): + """Responsible for generating the sidebar for the campaigns pages.""" + logger.info("Generating campaigns sidebar") + data = {} + data["menu"] = side_menu_data + + # Sidebar Overview + sidebar_campaigns_md = campaigns_config.sidebar_campaigns_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(campaigns_config.campaign_markdown_path, "sidebar_campaigns.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_campaigns_md) diff --git a/modules/campaigns/campaigns_config.py b/modules/campaigns/campaigns_config.py index 94d0a5de8e5..3eae07cc697 100644 --- a/modules/campaigns/campaigns_config.py +++ b/modules/campaigns/campaigns_config.py @@ -20,3 +20,10 @@ campaigns_templates_path = "modules/campaigns/templates/" campaigns_redirection_location = "modules/campaigns/campaigns_redirections.json" + +sidebar_campaigns_md = ( + "Title: Campaigns Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: campaigns/sidebar-campaigns/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/campaigns/templates/campaign.html b/modules/campaigns/templates/campaign.html index 24ddfbc0fe5..64612e9f780 100644 --- a/modules/campaigns/templates/campaign.html +++ b/modules/campaigns/templates/campaign.html @@ -27,9 +27,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -265,4 +263,5 @@

Software

+ {% endblock %} diff --git a/modules/campaigns/templates/campaigns-index.html b/modules/campaigns/templates/campaigns-index.html index 7787ed35046..9c928461ff4 100644 --- a/modules/campaigns/templates/campaigns-index.html +++ b/modules/campaigns/templates/campaigns-index.html @@ -7,9 +7,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -96,4 +94,5 @@
Campaigns: {{ parsed.campaigns_list_len }}
{{ super() }} + {% endblock %} \ No newline at end of file diff --git a/modules/tactics/tactics.py b/modules/tactics/tactics.py index 740f039fce0..2008ddbd57b 100644 --- a/modules/tactics/tactics.py +++ b/modules/tactics/tactics.py @@ -46,6 +46,7 @@ def generate_tactics(): tactics[domain["name"]] = util.stixhelpers.get_tactic_list(ms[domain["name"]], domain["name"]) side_nav_data = util.buildhelpers.get_side_nav_domains_data("tactics", tactics) + generate_sidebar_tactics(side_nav_data) for domain in site_config.domains: deprecated = True if domain["deprecated"] else False @@ -188,3 +189,17 @@ def get_techniques_of_tactic(tactic, techniques): techniques_list = sorted(techniques_list, key=lambda k: k["name"].lower()) return techniques_list + +def generate_sidebar_tactics(side_nav_data): + """Responsible for generating the sidebar for the tactics pages.""" + logger.info("Generating tactics sidebar") + data = {} + data["menu"] = side_nav_data + + # Sidebar Overview + sidebar_tactics_md = tactics_config.sidebar_tactics_md + json.dumps(data) + + # write markdown to file + with open(os.path.join(tactics_config.tactics_markdown_path, "sidebar_tactics.md"), "w", encoding="utf8") as md_file: + md_file.write(sidebar_tactics_md) + diff --git a/modules/tactics/tactics_config.py b/modules/tactics/tactics_config.py index d645a08bd38..b8dd5e4fa71 100644 --- a/modules/tactics/tactics_config.py +++ b/modules/tactics/tactics_config.py @@ -28,3 +28,10 @@ ) tactics_redirection_location = "modules/tactics/tactics_redirections.json" + +sidebar_tactics_md = ( + "Title: Tactics Sidebar\n" + "Template: general/sidebar-template \n" + "save_as: tactics/sidebar-tactics/index.html\n" + "data: " +) \ No newline at end of file diff --git a/modules/tactics/templates/tactic.html b/modules/tactics/templates/tactic.html index 5ae8e3aa715..1a9c747e49c 100644 --- a/modules/tactics/templates/tactic.html +++ b/modules/tactics/templates/tactic.html @@ -25,9 +25,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -109,4 +107,5 @@

Techniques

{{ super() }} + {% endblock %} \ No newline at end of file diff --git a/modules/tactics/templates/tactics-domain-index.html b/modules/tactics/templates/tactics-domain-index.html index ab231368b91..a322b1677fa 100644 --- a/modules/tactics/templates/tactics-domain-index.html +++ b/modules/tactics/templates/tactics-domain-index.html @@ -23,9 +23,7 @@ {% block innerleft %} -
- {{ navigation.sidenav(parsed.side_menu_data, output_file) }} -
+ {% endblock %} @@ -117,4 +115,5 @@
Tactics: {{ parsed.tactics_list_len }}
{{ super() }} + {% endblock %} \ No newline at end of file From 80c22c70cd25a12937f7313432a5243b1c4ae3dc Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Wed, 20 Sep 2023 10:27:19 -0400 Subject: [PATCH 26/51] update related_asset_sectors --- modules/assets/assets.py | 4 +++- modules/assets/templates/asset.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index 98cceaaacd0..aea00b90a7f 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -213,8 +213,10 @@ def get_related_asset_data(related_assets): for related_asset in related_assets: row = { "name": related_asset["name"], # required - "sector": related_asset["related_asset_sector"], # required } + if related_asset.get("related_asset_sectors"): + related_asset["related_asset_sectors"].sort() + row["sectors"] = ", ".join(related_asset["related_asset_sectors"]) if related_asset.get("description"): row["descr"] = related_asset["description"] related_asset_data.append(row) diff --git a/modules/assets/templates/asset.html b/modules/assets/templates/asset.html index 641b67a3d3c..6caf61e681b 100644 --- a/modules/assets/templates/asset.html +++ b/modules/assets/templates/asset.html @@ -130,7 +130,7 @@

Related Assets

- + @@ -138,7 +138,7 @@

Related Assets

{% for related_asset in parsed.related_assets_table %}
- + From 1709ab5d496d3b2126d42cacf7a4c88886bfe11b Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Wed, 20 Sep 2023 10:35:58 -0400 Subject: [PATCH 27/51] update asset/technique tables --- modules/assets/templates/asset.html | 2 +- modules/techniques/templates/technique.html | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/assets/templates/asset.html b/modules/assets/templates/asset.html index 6caf61e681b..0dfb2452ac9 100644 --- a/modules/assets/templates/asset.html +++ b/modules/assets/templates/asset.html @@ -150,7 +150,7 @@

Related Assets

{% if parsed.technique_table_data %} {{ navigator.layer_links(parsed.attack_id, "assets", parsed.layers) }} - {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques", true, "Targets", parsed.citations) }} + {{ techniques_used.techniques_used(parsed.technique_table_data, "Techniques", true, "", parsed.citations) }} {% endif %} {{ citations.reference_section(parsed.citations) }} diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index d48ca8ff05d..79e8f44ace3 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -376,7 +376,6 @@

Targeted Assets

- @@ -388,11 +387,6 @@

Targeted Assets

- {% endfor %} From 9d1d3a250c8c3df12dad8938f12705a26a39e21d Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 10:47:49 -0400 Subject: [PATCH 28/51] stable working condition --- attack-theme/static/scripts/sidebar-load-resources.js | 8 ++------ attack-theme/templates/general/attackcon-overview.html | 2 +- attack-theme/templates/general/faq-overview.html | 2 +- attack-theme/templates/general/intro-overview.html | 2 +- .../templates/general/sidebar-resources-template.html | 10 +++------- attack-theme/templates/general/sidebar-template.html | 4 ---- attack-theme/templates/general/two-column.html | 2 +- attack-theme/templates/macros/navigation.html | 6 ++---- modules/campaigns/templates/campaign.html | 2 +- modules/campaigns/templates/campaigns-index.html | 2 +- modules/groups/templates/group.html | 2 +- modules/groups/templates/groups-index.html | 2 +- modules/matrices/templates/matrix.html | 2 +- modules/mitigations/templates/mitigation.html | 2 +- .../templates/mitigations-domain-index.html | 2 +- modules/resources/templates/brand.html | 2 +- modules/resources/templates/getting-started.html | 2 +- modules/resources/templates/related-projects.html | 2 +- modules/resources/templates/resources.html | 2 +- modules/resources/templates/training-cti.html | 2 +- modules/resources/templates/training.html | 2 +- modules/resources/templates/update-post.html | 2 +- modules/resources/templates/updates-index.html | 2 +- modules/resources/templates/working-with-attack.html | 2 +- modules/software/templates/software-index.html | 2 +- modules/software/templates/software.html | 2 +- modules/tactics/templates/tactic.html | 2 +- modules/tactics/templates/tactics-domain-index.html | 2 +- modules/techniques/templates/technique.html | 2 +- .../techniques/templates/techniques-domain-index.html | 2 +- modules/versions/templates/versions.html | 4 +--- modules/website_build/templates/changelog.html | 2 +- 32 files changed, 35 insertions(+), 51 deletions(-) diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-resources.js index 4d1c0309a05..dd9f8a846a2 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -12,23 +12,19 @@ $("#sidebars").load(mod_entry, function() { } if(element.href == winlocation){ $(element.parentNode).addClass("active") - var parentElement = $(element.parentNode); - var elementID = document.getElementById(parentElement[0].id) - elementID.scrollIntoView({ behavior: "smooth", block: "center" }) }}); var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { if (e.matches) { - $('#sidenav-list').collapse('hide') + $('#sidebar-collapse').collapse('hide') } else{ - $('#sidenav-list').collapse('show') + $('#sidebar-collapse').collapse('show') } } $(document).ready(function() { mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); let sidenav_active_elements = $(".sidenav .active"); sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); diff --git a/attack-theme/templates/general/attackcon-overview.html b/attack-theme/templates/general/attackcon-overview.html index caa2d847b31..251c95f8ca7 100644 --- a/attack-theme/templates/general/attackcon-overview.html +++ b/attack-theme/templates/general/attackcon-overview.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/attack-theme/templates/general/faq-overview.html b/attack-theme/templates/general/faq-overview.html index 75bb278d889..61ee0ff074a 100644 --- a/attack-theme/templates/general/faq-overview.html +++ b/attack-theme/templates/general/faq-overview.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index c3d00c73852..9a53db9224f 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/attack-theme/templates/general/sidebar-resources-template.html b/attack-theme/templates/general/sidebar-resources-template.html index faf0d7f70fd..e2876bd9d4f 100644 --- a/attack-theme/templates/general/sidebar-resources-template.html +++ b/attack-theme/templates/general/sidebar-resources-template.html @@ -1,12 +1,8 @@ {% set RESOURCE_NAV = ${RESOURCE_NAV} -%} {% import 'macros/navigation.html' as navigation %} - - -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
- - +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
{% block scripts %} diff --git a/attack-theme/templates/general/sidebar-template.html b/attack-theme/templates/general/sidebar-template.html index b88b6ad2181..35887ffb5c8 100644 --- a/attack-theme/templates/general/sidebar-template.html +++ b/attack-theme/templates/general/sidebar-template.html @@ -1,12 +1,8 @@ {% import 'macros/navigation.html' as navigation %} {% set parsed = page.data | from_json %} - -
{{ navigation.sidenav(parsed.menu, output_file) }}
- - {% block scripts %} diff --git a/attack-theme/templates/general/two-column.html b/attack-theme/templates/general/two-column.html index de595fdd145..5d392da8c86 100644 --- a/attack-theme/templates/general/two-column.html +++ b/attack-theme/templates/general/two-column.html @@ -4,7 +4,7 @@ {% block left %} {{ super() }} diff --git a/attack-theme/templates/macros/navigation.html b/attack-theme/templates/macros/navigation.html index 4a385b5f279..41e86328ec5 100644 --- a/attack-theme/templates/macros/navigation.html +++ b/attack-theme/templates/macros/navigation.html @@ -20,7 +20,7 @@ --> {% macro sidenav(root, output_file, filter=False) %}
-
{{root.name | upper}} +
{{root.name | upper}}
@@ -41,8 +41,7 @@
{% endif %}
- {% endmacro %} diff --git a/modules/campaigns/templates/campaign.html b/modules/campaigns/templates/campaign.html index 64612e9f780..ebbe1002aac 100644 --- a/modules/campaigns/templates/campaign.html +++ b/modules/campaigns/templates/campaign.html @@ -27,7 +27,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/campaigns/templates/campaigns-index.html b/modules/campaigns/templates/campaigns-index.html index 9c928461ff4..ef4e5ab2957 100644 --- a/modules/campaigns/templates/campaigns-index.html +++ b/modules/campaigns/templates/campaigns-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/groups/templates/group.html b/modules/groups/templates/group.html index b6572096909..ace6f923b2d 100644 --- a/modules/groups/templates/group.html +++ b/modules/groups/templates/group.html @@ -27,7 +27,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/groups/templates/groups-index.html b/modules/groups/templates/groups-index.html index 80d9deb8109..6009f9a0f56 100644 --- a/modules/groups/templates/groups-index.html +++ b/modules/groups/templates/groups-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/matrices/templates/matrix.html b/modules/matrices/templates/matrix.html index 226d16915d5..026e5d6ed89 100644 --- a/modules/matrices/templates/matrix.html +++ b/modules/matrices/templates/matrix.html @@ -30,7 +30,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/mitigations/templates/mitigation.html b/modules/mitigations/templates/mitigation.html index 28f3a4eea4e..49abfb63dac 100644 --- a/modules/mitigations/templates/mitigation.html +++ b/modules/mitigations/templates/mitigation.html @@ -26,7 +26,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/mitigations/templates/mitigations-domain-index.html b/modules/mitigations/templates/mitigations-domain-index.html index b62a5ff5200..125748a2bdf 100644 --- a/modules/mitigations/templates/mitigations-domain-index.html +++ b/modules/mitigations/templates/mitigations-domain-index.html @@ -14,7 +14,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/resources/templates/brand.html b/modules/resources/templates/brand.html index 3a937ee69da..f78dc0c1671 100644 --- a/modules/resources/templates/brand.html +++ b/modules/resources/templates/brand.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/getting-started.html b/modules/resources/templates/getting-started.html index 714612e9e57..c107edb00bc 100644 --- a/modules/resources/templates/getting-started.html +++ b/modules/resources/templates/getting-started.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/related-projects.html b/modules/resources/templates/related-projects.html index 7b811b180bd..d10f3e97e27 100644 --- a/modules/resources/templates/related-projects.html +++ b/modules/resources/templates/related-projects.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/resources.html b/modules/resources/templates/resources.html index 53d033922f9..1b086537522 100644 --- a/modules/resources/templates/resources.html +++ b/modules/resources/templates/resources.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/training-cti.html b/modules/resources/templates/training-cti.html index cc4659e6cf6..8142f82007f 100644 --- a/modules/resources/templates/training-cti.html +++ b/modules/resources/templates/training-cti.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/training.html b/modules/resources/templates/training.html index ec069448c1f..3a8c55729a1 100644 --- a/modules/resources/templates/training.html +++ b/modules/resources/templates/training.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/update-post.html b/modules/resources/templates/update-post.html index 5a02cbf8ecd..9c2efa99406 100644 --- a/modules/resources/templates/update-post.html +++ b/modules/resources/templates/update-post.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/resources/templates/updates-index.html b/modules/resources/templates/updates-index.html index 5a072b27f38..b1978332d23 100644 --- a/modules/resources/templates/updates-index.html +++ b/modules/resources/templates/updates-index.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} {{ super () }} diff --git a/modules/resources/templates/working-with-attack.html b/modules/resources/templates/working-with-attack.html index c3bce071c51..c113a02082a 100644 --- a/modules/resources/templates/working-with-attack.html +++ b/modules/resources/templates/working-with-attack.html @@ -6,7 +6,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} diff --git a/modules/software/templates/software-index.html b/modules/software/templates/software-index.html index 51f90dc82e5..d03c5748c7c 100644 --- a/modules/software/templates/software-index.html +++ b/modules/software/templates/software-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/software/templates/software.html b/modules/software/templates/software.html index dd8c3d8780b..4b6a4bf8945 100644 --- a/modules/software/templates/software.html +++ b/modules/software/templates/software.html @@ -21,7 +21,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/tactics/templates/tactic.html b/modules/tactics/templates/tactic.html index 1a9c747e49c..2cdc362bf63 100644 --- a/modules/tactics/templates/tactic.html +++ b/modules/tactics/templates/tactic.html @@ -25,7 +25,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/tactics/templates/tactics-domain-index.html b/modules/tactics/templates/tactics-domain-index.html index a322b1677fa..4acd3836909 100644 --- a/modules/tactics/templates/tactics-domain-index.html +++ b/modules/tactics/templates/tactics-domain-index.html @@ -23,7 +23,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index e8a82df901b..23ca31f64b7 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -37,7 +37,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index d6cd0c85c65..f9a770ff76a 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -23,7 +23,7 @@ {% block innerleft %} - + {% endblock %} diff --git a/modules/versions/templates/versions.html b/modules/versions/templates/versions.html index e317438935b..35fcfcb2ead 100644 --- a/modules/versions/templates/versions.html +++ b/modules/versions/templates/versions.html @@ -5,9 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
+ {% endblock %} {% block innerright %} diff --git a/modules/website_build/templates/changelog.html b/modules/website_build/templates/changelog.html index 8b395642d85..3cd1ec4a02e 100644 --- a/modules/website_build/templates/changelog.html +++ b/modules/website_build/templates/changelog.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} From 42240d8236ef1f575cd0fba0f1239ea9cd5c40e3 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 11:11:39 -0400 Subject: [PATCH 29/51] code cleanup 1 --- .../scripts/sidebar-load-mitigations.js | 56 +++++++++---------- modules/campaigns/templates/campaign.html | 1 - .../campaigns/templates/campaigns-index.html | 1 - modules/matrices/templates/matrix.html | 1 - modules/tactics/templates/tactic.html | 1 - .../templates/tactics-domain-index.html | 1 - modules/versions/templates/versions.html | 1 - 7 files changed, 27 insertions(+), 35 deletions(-) diff --git a/attack-theme/static/scripts/sidebar-load-mitigations.js b/attack-theme/static/scripts/sidebar-load-mitigations.js index 1935da43b9c..732539095f4 100644 --- a/attack-theme/static/scripts/sidebar-load-mitigations.js +++ b/attack-theme/static/scripts/sidebar-load-mitigations.js @@ -1,32 +1,30 @@ $("#sidebars").load("/mitigations/sidebar-mitigations", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/modules/campaigns/templates/campaign.html b/modules/campaigns/templates/campaign.html index ebbe1002aac..929cdb3d27d 100644 --- a/modules/campaigns/templates/campaign.html +++ b/modules/campaigns/templates/campaign.html @@ -259,7 +259,6 @@

Software

{% block scripts %} {{ super() }} - diff --git a/modules/campaigns/templates/campaigns-index.html b/modules/campaigns/templates/campaigns-index.html index ef4e5ab2957..f08b1a7dcb2 100644 --- a/modules/campaigns/templates/campaigns-index.html +++ b/modules/campaigns/templates/campaigns-index.html @@ -93,6 +93,5 @@
Campaigns: {{ parsed.campaigns_list_len }}
{% block scripts %} {{ super() }} - {% endblock %} \ No newline at end of file diff --git a/modules/matrices/templates/matrix.html b/modules/matrices/templates/matrix.html index 026e5d6ed89..92c2d1fc06f 100644 --- a/modules/matrices/templates/matrix.html +++ b/modules/matrices/templates/matrix.html @@ -120,7 +120,6 @@

{{parsed.name}} {{matrix_plural}}

{{ super() }} - diff --git a/modules/tactics/templates/tactic.html b/modules/tactics/templates/tactic.html index 2cdc362bf63..f687d3949b0 100644 --- a/modules/tactics/templates/tactic.html +++ b/modules/tactics/templates/tactic.html @@ -106,6 +106,5 @@

Techniques

{% block scripts %} {{ super() }} - {% endblock %} \ No newline at end of file diff --git a/modules/tactics/templates/tactics-domain-index.html b/modules/tactics/templates/tactics-domain-index.html index 4acd3836909..d883d4cc0b8 100644 --- a/modules/tactics/templates/tactics-domain-index.html +++ b/modules/tactics/templates/tactics-domain-index.html @@ -114,6 +114,5 @@
Tactics: {{ parsed.tactics_list_len }}
{% block scripts %} {{ super() }} - {% endblock %} \ No newline at end of file diff --git a/modules/versions/templates/versions.html b/modules/versions/templates/versions.html index 35fcfcb2ead..1b4a1490a2b 100644 --- a/modules/versions/templates/versions.html +++ b/modules/versions/templates/versions.html @@ -88,5 +88,4 @@

Versions of ATT&CK

- {% endblock %} From 04d4923d69a89917daefdc379545b55f384a2136 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 11:25:25 -0400 Subject: [PATCH 30/51] code cleanup 2 --- .../static/scripts/sidebar-load-campaigns.js | 51 ++++++++-------- .../static/scripts/sidebar-load-groups.js | 17 +++--- .../static/scripts/sidebar-load-matrices.js | 57 +++++++++--------- .../scripts/sidebar-load-mitigations.js | 53 +++++++++-------- .../static/scripts/sidebar-load-resources.js | 15 ++--- .../static/scripts/sidebar-load-software.js | 59 +++++++++---------- .../static/scripts/sidebar-load-tactics.js | 51 ++++++++-------- .../static/scripts/sidebar-load-techniques.js | 59 +++++++++---------- 8 files changed, 179 insertions(+), 183 deletions(-) diff --git a/attack-theme/static/scripts/sidebar-load-campaigns.js b/attack-theme/static/scripts/sidebar-load-campaigns.js index 282b89f98e2..28778ecb8e5 100644 --- a/attack-theme/static/scripts/sidebar-load-campaigns.js +++ b/attack-theme/static/scripts/sidebar-load-campaigns.js @@ -1,32 +1,31 @@ $("#sidebars").load("/campaigns/sidebar-campaigns", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - - function mobileSidenav(e) { + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { if (e.matches) { - $('#sidebar-collapse').collapse('hide') + $('#sidebar-collapse').collapse('hide') } else{ - $('#sidebar-collapse').collapse('show') - } + $('#sidebar-collapse').collapse('show') } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-groups.js b/attack-theme/static/scripts/sidebar-load-groups.js index 8cce8dd6563..e02e0cd58c0 100644 --- a/attack-theme/static/scripts/sidebar-load-groups.js +++ b/attack-theme/static/scripts/sidebar-load-groups.js @@ -11,22 +11,21 @@ $("#sidebars").load("/groups/sidebar-groups", function() { if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); + + //This code is for creating a collapsable sidebar for the mobile view var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } } $(document).ready(function() { mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); let sidenav_active_elements = $(".sidenav .active"); sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) }); - mediaQuery.addEventListener('change', mobileSidenav) }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-matrices.js b/attack-theme/static/scripts/sidebar-load-matrices.js index 18367c59375..942af251ed3 100644 --- a/attack-theme/static/scripts/sidebar-load-matrices.js +++ b/attack-theme/static/scripts/sidebar-load-matrices.js @@ -1,35 +1,34 @@ $("#sidebars").load("/matrices/sidebar-matrices", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(!element.href.endsWith("/")){ - element.href = element.href + "/"; - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(!element.href.endsWith("/")){ + element.href = element.href + "/"; + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); - function mobileSidenav(e) { + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { if (e.matches) { - $('#sidebar-collapse').collapse('hide') + $('#sidebar-collapse').collapse('hide') } else{ - $('#sidebar-collapse').collapse('show') - } + $('#sidebar-collapse').collapse('show') } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) - }); \ No newline at end of file + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-mitigations.js b/attack-theme/static/scripts/sidebar-load-mitigations.js index 732539095f4..b6f33cd8fdc 100644 --- a/attack-theme/static/scripts/sidebar-load-mitigations.js +++ b/attack-theme/static/scripts/sidebar-load-mitigations.js @@ -1,30 +1,31 @@ $("#sidebars").load("/mitigations/sidebar-mitigations", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; } else{ - $('#sidebar-collapse').collapse('show') + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); + + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) + }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-resources.js index dd9f8a846a2..8f577e8369a 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-resources.js @@ -13,15 +13,16 @@ $("#sidebars").load(mod_entry, function() { if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } } $(document).ready(function() { mobileSidenav(mediaQuery) diff --git a/attack-theme/static/scripts/sidebar-load-software.js b/attack-theme/static/scripts/sidebar-load-software.js index 16d6e655ffe..b3ddcc1a8c7 100644 --- a/attack-theme/static/scripts/sidebar-load-software.js +++ b/attack-theme/static/scripts/sidebar-load-software.js @@ -1,32 +1,31 @@ $("#sidebars").load("/software/sidebar-software", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) - }); \ No newline at end of file + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-tactics.js b/attack-theme/static/scripts/sidebar-load-tactics.js index 957a0a14a7d..a027727706a 100644 --- a/attack-theme/static/scripts/sidebar-load-tactics.js +++ b/attack-theme/static/scripts/sidebar-load-tactics.js @@ -1,32 +1,31 @@ $("#sidebars").load("/tactics/sidebar-tactics", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); - function mobileSidenav(e) { + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { if (e.matches) { - $('#sidebar-collapse').collapse('hide') + $('#sidebar-collapse').collapse('hide') } else{ - $('#sidebar-collapse').collapse('show') - } + $('#sidebar-collapse').collapse('show') } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) - }); \ No newline at end of file + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-techniques.js b/attack-theme/static/scripts/sidebar-load-techniques.js index acaaa70e5a4..d4ea07d99d5 100644 --- a/attack-theme/static/scripts/sidebar-load-techniques.js +++ b/attack-theme/static/scripts/sidebar-load-techniques.js @@ -1,32 +1,31 @@ $("#sidebars").load("/techniques/sidebar-techniques", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + var navElements = document.querySelectorAll('.sidenav-head > a'); + var winlocation; + navElements.forEach(function(element){ + if(!window.location.href.endsWith("/")){ + winlocation = window.location.href + "/"; + } + else{ + winlocation = window.location.href + } + if(element.href == winlocation){ + $(element.parentNode).addClass("active") + }}); - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav = $(".sidenav-list"); - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - - mediaQuery.addEventListener('change', mobileSidenav) - }); \ No newline at end of file + //This code is for creating a collapsable sidebar for the mobile view + var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } + } + $(document).ready(function() { + mobileSidenav(mediaQuery) + let sidenav_active_elements = $(".sidenav .active"); + sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) + }); + mediaQuery.addEventListener('change', mobileSidenav) +}); \ No newline at end of file From b32bf08f0fe30ff6cce3929fe53104798950a882 Mon Sep 17 00:00:00 2001 From: Jared Ondricek <90368810+jondricek@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:50:33 -0500 Subject: [PATCH 31/51] Update attackcon.json contributor details --- data/attackcon.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/attackcon.json b/data/attackcon.json index da1942107cf..799f6e56af8 100644 --- a/data/attackcon.json +++ b/data/attackcon.json @@ -375,10 +375,10 @@ { "title": "What’s New with ATT&CK for Cloud?", "presenters": [{ - "names": ["Jen Burns"], + "names": ["Jack Burns"], "organization": "MITRE" }], - "description": "Jen Burns is a Lead Cybersecurity Engineer at MITRE and the Lead for MITRE ATT&CK for Cloud. She’s also a red team developer and lead for ATT&CK Evaluations, using her skills in software engineering and adversary emulation. Previously, she was a tech lead at HubSpot on the Infrastructure Security team where she focused on red teaming and building detections in the cloud environment. This presentation is from the MITRE ATT&Ckcon Power Hour session held on October 9, 2020.", + "description": "Jack Burns is a Lead Cybersecurity Engineer at MITRE and the Lead for MITRE ATT&CK for Cloud. He’s also a red team developer and lead for ATT&CK Evaluations, using his skills in software engineering and adversary emulation. Previously, he was a tech lead at HubSpot on the Infrastructure Security team where he focused on red teaming and building detections in the cloud environment. This presentation is from the MITRE ATT&Ckcon Power Hour session held on October 9, 2020.", "video": "https://www.youtube.com/watch?v=a-xs5VqlcKI&list=PLkTApXQou_8KKl3fOIPKD_9pNpmSe1TKu&index=24", "slides": "https://www.slideshare.net/attackcon2018/whats-new-with-attck-for-cloud" }, @@ -1139,4 +1139,4 @@ "slides": "https://www.slideshare.net/attackcon2018/mitre-attckcon-2018-the-use-of-game-theory-with-mitre-attck-matt-summers-and-nick-dunn-ncc-group" } ] -}] \ No newline at end of file +}] From 759123d9abba21535cfc8e91d3b70d2c53006c42 Mon Sep 17 00:00:00 2001 From: Jared Ondricek <90368810+jondricek@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:57:32 -0400 Subject: [PATCH 32/51] Update contributor information --- modules/resources/static_pages/updates-april-2022.md | 2 +- modules/resources/static_pages/updates-october-2021.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/resources/static_pages/updates-april-2022.md b/modules/resources/static_pages/updates-april-2022.md index f0de48f0940..e201f87d147 100644 --- a/modules/resources/static_pages/updates-april-2022.md +++ b/modules/resources/static_pages/updates-april-2022.md @@ -806,10 +806,10 @@ ATT&CK for Mobile does not support data sources * Harshal Tupsamudre, Qualys * Hiroki Nagahama, NEC Corporation * Isif Ibrahima, Mandiant +* Jack Burns, HubSpot * James_inthe_box, Me * Jan Petrov, Citi * Jannie Li, Microsoft Threat Intelligence Center (MSTIC) -* Jen Burns, HubSpot * Jeremy Galloway * Joas Antonio dos Santos, @C0d3Cr4zy, Inmetrics * John Page (aka hyp3rlinx), ApparitionSec diff --git a/modules/resources/static_pages/updates-october-2021.md b/modules/resources/static_pages/updates-october-2021.md index 81a720457ec..68ddeb20052 100644 --- a/modules/resources/static_pages/updates-october-2021.md +++ b/modules/resources/static_pages/updates-october-2021.md @@ -781,10 +781,10 @@ No changes * Isif Ibrahima * Itamar Mizrahi, Cymptom * Ivan Sinyakov +* Jack Burns, HubSpot * Janantha Marasinghe * Jaron Bradley @jbradley89 * Jeff Felling, Red Canary -* Jen Burns, HubSpot * Joas Antonio dos Santos, @C0d3Cr4zy * Johann Rehberger * Jon Sheedy From 952442569df3da52a962445c6bb566025ef7f9ad Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 15:40:58 -0400 Subject: [PATCH 33/51] versions work --- modules/techniques/templates/technique.html | 2 +- modules/techniques/templates/techniques-domain-index.html | 2 +- modules/versions/templates/versions.html | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 23ca31f64b7..2a67f28e5f6 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -453,6 +453,6 @@

Difficulty for the Adversary

{% else %} {% endif %} - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index f9a770ff76a..29f82742e2f 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -84,5 +84,5 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/versions/templates/versions.html b/modules/versions/templates/versions.html index 1b4a1490a2b..a1203592763 100644 --- a/modules/versions/templates/versions.html +++ b/modules/versions/templates/versions.html @@ -88,4 +88,5 @@

Versions of ATT&CK

+ {% endblock %} From 40c920e76da9c9c67aaacbc534f4fa448dd1fe18 Mon Sep 17 00:00:00 2001 From: adpare Date: Thu, 21 Sep 2023 16:23:18 -0400 Subject: [PATCH 34/51] added benefactors page and defenses and cti tab --- attack-theme/static/style/_layouts.scss | 4 ++ .../templates/benefactors/benefactors.html | 34 +++++++++++ .../templates/general/intro-overview.html | 23 ++++--- .../templates/macros/navigation_menu.html | 17 +++++- data/resources_navigation.json | 18 ++++++ modules/benefactors/__init__.py | 21 +++++++ modules/benefactors/benefactors.py | 28 +++++++++ modules/benefactors/benefactors_config.py | 12 ++++ .../benefactors/templates/benefactors.html | 34 +++++++++++ modules/blog/blog_config.py | 2 +- modules/campaigns/__init__.py | 12 ---- modules/contribute/__init__.py | 28 --------- modules/contribute/contribute.py | 61 ------------------- modules/contribute/contribute_config.py | 14 ----- modules/datasources/__init__.py | 14 ++++- modules/datasources/datasources_config.py | 1 + modules/groups/__init__.py | 12 ---- modules/mitigations/__init__.py | 15 ----- modules/resources/__init__.py | 6 ++ .../contribute_redirections.json | 0 modules/resources/resources.py | 51 ++++++++++++++++ modules/resources/resources_config.py | 5 ++ modules/resources/templates/contact.html | 19 +++++- .../templates/contribute.html | 48 +++++++++------ modules/software/__init__.py | 10 --- update-attack.py | 4 +- 26 files changed, 307 insertions(+), 186 deletions(-) create mode 100644 attack-theme/templates/benefactors/benefactors.html create mode 100644 modules/benefactors/__init__.py create mode 100644 modules/benefactors/benefactors.py create mode 100644 modules/benefactors/benefactors_config.py create mode 100644 modules/benefactors/templates/benefactors.html delete mode 100644 modules/contribute/__init__.py delete mode 100644 modules/contribute/contribute.py delete mode 100644 modules/contribute/contribute_config.py rename modules/{contribute => resources}/contribute_redirections.json (100%) rename modules/{contribute => resources}/templates/contribute.html (90%) diff --git a/attack-theme/static/style/_layouts.scss b/attack-theme/static/style/_layouts.scss index aeabc3ea157..a80390c802e 100644 --- a/attack-theme/static/style/_layouts.scss +++ b/attack-theme/static/style/_layouts.scss @@ -1137,6 +1137,10 @@ pre { } } +.contact-center { + margin-block-start: 20vh; +} + /*Card Blocks*/ // container of groups of cards .expand-panel { diff --git a/attack-theme/templates/benefactors/benefactors.html b/attack-theme/templates/benefactors/benefactors.html new file mode 100644 index 00000000000..ab7b3823ae6 --- /dev/null +++ b/attack-theme/templates/benefactors/benefactors.html @@ -0,0 +1,34 @@ +{% extends "general/two-column.html" %} +{% set active_page = "resources" -%} +{% set title = "Benefactors | MITRE ATT&CK®" -%} +{% import 'macros/navigation.html' as navigation %} + +{% block innerleft %} +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
+{% endblock %} + +{% block innerright %} +
+ +
+
+
+
+
+

Benefactors

+
+
+
+
+{% endblock %} +{% block scripts %} +{{ super () }} + + +{% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index 29e410b8abc..aa61c1b2a89 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -10,16 +10,23 @@ {% endblock %} {% block innerright %} -{{ super () }} - -
-

{{ page.title }}

+
+ +
+
+
+
+
+

{{ page.title }}

{{ page.content }}
+
+
+
{% endblock %} {% block scripts %} diff --git a/attack-theme/templates/macros/navigation_menu.html b/attack-theme/templates/macros/navigation_menu.html index 1aa97d850b2..8adb025cb55 100644 --- a/attack-theme/templates/macros/navigation_menu.html +++ b/attack-theme/templates/macros/navigation_menu.html @@ -48,7 +48,7 @@ +{% endmacro %} + +{% macro child_has_child(element) %} + +
+ + +
{% endmacro %} \ No newline at end of file diff --git a/data/resources_navigation.json b/data/resources_navigation.json index d9c71f7884f..08a20f1c4b8 100644 --- a/data/resources_navigation.json +++ b/data/resources_navigation.json @@ -14,6 +14,12 @@ "path": "/resources/getting-started/", "children": [] }, + { + "name": "Contribute", + "id": "contribute", + "path": "/resources/contribute/", + "children": [] + }, { "name": "Training", "id": "training", @@ -69,6 +75,12 @@ "path": "/resources/brand/", "children": [] }, + { + "name": "Benefactors", + "id": "benefactors", + "path": "/resources/benefactors/", + "children": [] + }, { "name": "Privacy Policy", "id": "privacy", @@ -86,6 +98,12 @@ "id": "changelog", "path": "/resources/changelog.html", "children": [] + }, + { + "name": "Contact", + "id": "contact", + "path": "/contact/", + "children": [] } ] } diff --git a/modules/benefactors/__init__.py b/modules/benefactors/__init__.py new file mode 100644 index 00000000000..f21046ea539 --- /dev/null +++ b/modules/benefactors/__init__.py @@ -0,0 +1,21 @@ +from . import benefactors +from . import benefactors_config +import json + + +def get_priority(): + return benefactors_config.priority + + +def get_menu(): + return { + "display_name": "Benefactors", + "module_name": "Benefactors", + "url": "/resources/benefactors/", + "external_link": False, + "priority": benefactors_config.priority, + "children": [], + } + +def run_module(): + return (benefactors.generate_benefactors(), benefactors_config.module_name) diff --git a/modules/benefactors/benefactors.py b/modules/benefactors/benefactors.py new file mode 100644 index 00000000000..4861ab2fdbe --- /dev/null +++ b/modules/benefactors/benefactors.py @@ -0,0 +1,28 @@ +import json +import math +import os + +from modules import util + +from . import benefactors_config +from .. import site_config + + +def generate_benefactors(): + """Generate benefactors page markdown""" + + # Create content pages directory if does not already exist + util.buildhelpers.create_content_pages_dir() + + # Move templates to templates directory + util.buildhelpers.move_templates(benefactors_config.module_name, benefactors_config.benefactors_templates_path) + + # Create directory if it does not exist + if not os.path.isdir(benefactors_config.benefactors_markdown_path): + os.mkdir(benefactors_config.benefactors_markdown_path) + + benefactors_md = benefactors_config.benefactors_md + + # write markdown to file + with open(os.path.join(benefactors_config.benefactors_markdown_path, "benefactors.md"), "w", encoding="utf8") as md_file: + md_file.write(benefactors_md) diff --git a/modules/benefactors/benefactors_config.py b/modules/benefactors/benefactors_config.py new file mode 100644 index 00000000000..ae8ae4db38f --- /dev/null +++ b/modules/benefactors/benefactors_config.py @@ -0,0 +1,12 @@ +module_name = "Benefactors" +priority = 9 + +# Markdown path for benefactors +benefactors_markdown_path = "content/pages/resources" + +# String template for benefactors index page +benefactors_md = ( + "Title: Benefactors\n" "Template: benefactors/benefactors\n" "save_as: resources/benefactors/index.html\n" "data: " +) + +benefactors_templates_path = "modules/benefactors/templates" diff --git a/modules/benefactors/templates/benefactors.html b/modules/benefactors/templates/benefactors.html new file mode 100644 index 00000000000..ab7b3823ae6 --- /dev/null +++ b/modules/benefactors/templates/benefactors.html @@ -0,0 +1,34 @@ +{% extends "general/two-column.html" %} +{% set active_page = "resources" -%} +{% set title = "Benefactors | MITRE ATT&CK®" -%} +{% import 'macros/navigation.html' as navigation %} + +{% block innerleft %} +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
+{% endblock %} + +{% block innerright %} +
+ +
+
+
+
+
+

Benefactors

+
+
+
+
+{% endblock %} +{% block scripts %} +{{ super () }} + + +{% endblock %} \ No newline at end of file diff --git a/modules/blog/blog_config.py b/modules/blog/blog_config.py index cd6759f8ece..b26974ea252 100644 --- a/modules/blog/blog_config.py +++ b/modules/blog/blog_config.py @@ -1,2 +1,2 @@ module_name = "Blog" -priority = 9 +priority = 10 diff --git a/modules/campaigns/__init__.py b/modules/campaigns/__init__.py index 7887aef5dae..99ff4eaa234 100644 --- a/modules/campaigns/__init__.py +++ b/modules/campaigns/__init__.py @@ -5,17 +5,5 @@ def get_priority(): return campaigns_config.priority - -def get_menu(): - return { - "display_name": campaigns_config.module_name, - "module_name": campaigns_config.module_name, - "url": "/campaigns", - "external_link": False, - "priority": campaigns_config.priority, - "children": [], - } - - def run_module(): return (campaigns.generate_campaigns(), campaigns_config.module_name) diff --git a/modules/contribute/__init__.py b/modules/contribute/__init__.py deleted file mode 100644 index b81b657ddb8..00000000000 --- a/modules/contribute/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from . import contribute -from . import contribute_config -import json - - -def get_priority(): - return contribute_config.priority - - -def get_menu(): - return { - "display_name": "Contribute", - "module_name": "Contribute", - "url": "/resources/contribute/", - "external_link": False, - "priority": contribute_config.priority, - "children": [], - } - - -def get_redirections(): - with open(contribute_config.contribute_redirection_location, "r", encoding="utf8") as json_redirections: - return json.load(json_redirections) - return [] - - -def run_module(): - return (contribute.generate_contribute(), contribute_config.module_name) diff --git a/modules/contribute/contribute.py b/modules/contribute/contribute.py deleted file mode 100644 index 6f9e2d52aa0..00000000000 --- a/modules/contribute/contribute.py +++ /dev/null @@ -1,61 +0,0 @@ -import json -import math -import os - -from modules import util - -from . import contribute_config -from .. import site_config - - -def generate_contribute(): - """Generate contribute page markdown""" - - # Create content pages directory if does not already exist - util.buildhelpers.create_content_pages_dir() - - # Move templates to templates directory - util.buildhelpers.move_templates(contribute_config.module_name, contribute_config.contribute_templates_path) - - # Generate redirections - util.buildhelpers.generate_redirections( - redirections_filename=contribute_config.contribute_redirection_location, redirect_md=site_config.redirect_md - ) - - ms = util.relationshipgetters.get_ms() - contributors = util.stixhelpers.get_contributors(ms) - - if not contributors: - util.buildhelpers.remove_module_from_menu(contribute_config.module_name) - return - - data = {} - - data["contributors"] = [] - - contributors_first_col = [] - contributors_second_col = [] - - half = math.ceil((len(contributors)) / 2) - list_size = len(contributors) - - for index in range(0, half): - contributors_first_col.append(contributors[index]) - - for index in range(half, list_size): - contributors_second_col.append(contributors[index]) - - data["contributors"].append(contributors_first_col) - data["contributors"].append(contributors_second_col) - - subs = contribute_config.contribute_index_md + json.dumps(data) - - # Create directory if it does not exist - if not os.path.isdir(contribute_config.contribute_markdown_path): - os.mkdir(contribute_config.contribute_markdown_path) - - # Open markdown file for the contribute page - with open( - os.path.join(contribute_config.contribute_markdown_path, "contribute.md"), "w", encoding="utf8" - ) as md_file: - md_file.write(subs) diff --git a/modules/contribute/contribute_config.py b/modules/contribute/contribute_config.py deleted file mode 100644 index 857319849bd..00000000000 --- a/modules/contribute/contribute_config.py +++ /dev/null @@ -1,14 +0,0 @@ -module_name = "Contribute" -priority = 10 - -# Markdown path for contribute -contribute_markdown_path = "content/pages/resources" - -# String template for contribution index page -contribute_index_md = ( - "Title: Contribute\n" "Template: contribute/contribute\n" "save_as: resources/contribute/index.html\n" "data: " -) - -contribute_templates_path = "modules/contribute/templates" - -contribute_redirection_location = "modules/contribute/contribute_redirections.json" diff --git a/modules/datasources/__init__.py b/modules/datasources/__init__.py index 722076992e1..8790954c0db 100644 --- a/modules/datasources/__init__.py +++ b/modules/datasources/__init__.py @@ -9,12 +9,22 @@ def get_priority(): def get_menu(): return { - "display_name": datasources_config.module_name, + "display_name": datasources_config.module_tab_name, "module_name": datasources_config.module_name_no_spaces, "url": "/datasources", "external_link": False, "priority": datasources_config.priority, - "children": [], + "children": [ + {"display_name": "Data Sources", "url": "/datasources", "external_link": False, "children": []}, + {"display_name": "Mitigations", "url": "/mitigations/", "external_link": False, "children": [ + {"display_name": "Enterprise", "url": "/mitigations/enterprise/", "external_link": False, "children": []}, + {"display_name": "Mobile", "url": "/mitigations/mobile/", "external_link": False, "children": []}, + {"display_name": "ICS", "url": "/mitigations/ics/", "external_link": False, "children": []}, + ]}, + {"display_name": "Groups", "url": "/groups", "external_link": False, "children": []}, + {"display_name": "Software", "url": "/software", "external_link": False, "children": []}, + {"display_name": "Campaigns", "url": "/datasources", "external_link": False, "children": []}, + ], } diff --git a/modules/datasources/datasources_config.py b/modules/datasources/datasources_config.py index 220a45a81d3..df784ac0416 100644 --- a/modules/datasources/datasources_config.py +++ b/modules/datasources/datasources_config.py @@ -2,6 +2,7 @@ module_name = "Data Sources" module_name_no_spaces = "datasources" +module_tab_name = "Defenses and CTI" priority = 4.1 diff --git a/modules/groups/__init__.py b/modules/groups/__init__.py index 96480c1aee3..aa2ad69da15 100644 --- a/modules/groups/__init__.py +++ b/modules/groups/__init__.py @@ -6,17 +6,5 @@ def get_priority(): return groups_config.priority - -def get_menu(): - return { - "display_name": groups_config.module_name, - "module_name": groups_config.module_name, - "url": "/groups", - "external_link": False, - "priority": groups_config.priority, - "children": [], - } - - def run_module(): return (groups.generate_groups(), groups_config.module_name) diff --git a/modules/mitigations/__init__.py b/modules/mitigations/__init__.py index 704fd5eb3e5..40d74cfbd41 100644 --- a/modules/mitigations/__init__.py +++ b/modules/mitigations/__init__.py @@ -6,20 +6,5 @@ def get_priority(): return mitigations_config.priority -def get_menu(): - return { - "display_name": mitigations_config.module_name, - "module_name": mitigations_config.module_name, - "url": "/mitigations/", - "external_link": False, - "priority": mitigations_config.priority, - "children": [ - {"display_name": "Enterprise", "url": "/mitigations/enterprise/", "external_link": False, "children": []}, - {"display_name": "Mobile", "url": "/mitigations/mobile/", "external_link": False, "children": []}, - {"display_name": "ICS", "url": "/mitigations/ics/", "external_link": False, "children": []}, - ], - } - - def run_module(): return (mitigations.generate_mitigations(), mitigations_config.module_name) diff --git a/modules/resources/__init__.py b/modules/resources/__init__.py index 1f4e4eb7d35..fd1805b7fd2 100644 --- a/modules/resources/__init__.py +++ b/modules/resources/__init__.py @@ -22,6 +22,12 @@ def get_menu(): "external_link": False, "children": [], }, + { + "display_name": "Contribute", + "url": "/resources/contribute/", + "external_link": False, + "children": [], + }, {"display_name": "Training", "url": "/resources/training/", "external_link": False, "children": []}, {"display_name": "ATT&CKcon", "url": "/resources/attackcon/", "external_link": False, "children": []}, { diff --git a/modules/contribute/contribute_redirections.json b/modules/resources/contribute_redirections.json similarity index 100% rename from modules/contribute/contribute_redirections.json rename to modules/resources/contribute_redirections.json diff --git a/modules/resources/resources.py b/modules/resources/resources.py index 3b84026e294..4433bde8ddb 100644 --- a/modules/resources/resources.py +++ b/modules/resources/resources.py @@ -3,6 +3,7 @@ import shutil from datetime import datetime from pathlib import Path +import math from loguru import logger from mitreattack.attackToExcel import attackToExcel @@ -37,11 +38,21 @@ def generate_resources(): if site_config.resource_nav["children"][i]["id"] == "versions": del site_config.resource_nav["children"][i] + build_benefactors_module = False + for module_info in modules.run_ptr: + if module_info["module_name"] == "benefactors": + build_benefactors_module = True + if not build_benefactors_module: + for i, child in enumerate(site_config.resource_nav["children"]): + if site_config.resource_nav["children"][i]["id"] == "benefactors": + del site_config.resource_nav["children"][i] + # Move templates to templates directory util.buildhelpers.move_templates(resources_config.module_name, resources_config.resources_templates_path) copy_docs(module_docs_path=resources_config.docs_path) generate_working_with_attack() generate_general_information() + generate_contribute_page() generate_training_pages() generate_brand_page() generate_attackcon_page() @@ -355,3 +366,43 @@ def generate_working_with_attack(): os.path.join(site_config.resources_markdown_path, "working_with_attack.md"), "w", encoding="utf8" ) as md_file: md_file.write(working_with_attack_content) + +def generate_contribute_page(): + """Responsible for generating the markdown pages of the contribute pages.""" + logger.info("Generating contributing page") + + # Generate redirections + util.buildhelpers.generate_redirections( + redirections_filename=resources_config.contribute_redirection_location, redirect_md=site_config.redirect_md + ) + + ms = util.relationshipgetters.get_ms() + contributors = util.stixhelpers.get_contributors(ms) + + data = {} + + data["contributors"] = [] + + contributors_first_col = [] + contributors_second_col = [] + + half = math.ceil((len(contributors)) / 2) + list_size = len(contributors) + + for index in range(0, half): + contributors_first_col.append(contributors[index]) + + for index in range(half, list_size): + contributors_second_col.append(contributors[index]) + + data["contributors"].append(contributors_first_col) + data["contributors"].append(contributors_second_col) + + subs = resources_config.contribute_md + json.dumps(data) + + # Open markdown file for the contribute page + with open( + os.path.join(site_config.resources_markdown_path, "contribute.md"), "w", encoding="utf8" + ) as md_file: + md_file.write(subs) + diff --git a/modules/resources/resources_config.py b/modules/resources/resources_config.py index 5c438a74dad..4ce4a342e1a 100644 --- a/modules/resources/resources_config.py +++ b/modules/resources/resources_config.py @@ -34,6 +34,11 @@ "Template: resources/training-cti\n" "save_as: resources/training/cti/index.html\n" ) +contribute_md = ( + "Title: Contribute\n" "Template: resources/contribute\n" "save_as: resources/contribute/index.html\n" "data: " +) + +contribute_redirection_location = "modules/resources/contribute_redirections.json" # Brand md brand_md = "Title: Brand\n" "Template: resources/brand\n" "save_as: resources/brand/index.html\n" "data: " diff --git a/modules/resources/templates/contact.html b/modules/resources/templates/contact.html index bac0a4d9b8d..8601b12d567 100644 --- a/modules/resources/templates/contact.html +++ b/modules/resources/templates/contact.html @@ -1,10 +1,17 @@ -{% extends "general/base.html" %} +{% extends "general/two-column.html" %} {% set active_page = "contact" -%} {% set title = "Contact | MITRE ATT&CK®" %} +{% import 'macros/navigation.html' as navigation %} -{% block content %} +{% block innerleft %} +
+ {{navigation.sidenav(RESOURCE_NAV, output_file)}} +
+{% endblock %} + +{% block innerright %} {{ super () }} -
+

Contact Us!

@@ -15,4 +22,10 @@

Contact Us!

For learning how to submit contributions to ATT&CK, read our contribute page

+{% endblock %} + +{% block scripts %} +{{ super() }} + + {% endblock %} \ No newline at end of file diff --git a/modules/contribute/templates/contribute.html b/modules/resources/templates/contribute.html similarity index 90% rename from modules/contribute/templates/contribute.html rename to modules/resources/templates/contribute.html index 9e092044aaf..5d1fca332f9 100644 --- a/modules/contribute/templates/contribute.html +++ b/modules/resources/templates/contribute.html @@ -1,19 +1,29 @@ -{% extends "general/base.html" %} +{% extends "general/two-column.html" %} {% set active_page = "resources" -%} {% set title = "Contribute | MITRE ATT&CK®" -%} {% set parsed = page.data | from_json %} +{% import 'macros/navigation.html' as navigation %} -{% block content %} {{ super () }} -
-
- +
-
-

Contribute

+
+
+
+
+

Contribute

You can help contribute to ATT&CK.

@@ -113,7 +123,7 @@
Required Permissions:

Description: Component Object Model (COM) servers - associated with Graphics Interchange Format (JIF) image viewers can be abused to corrupt arbitrary memory banks. Adversaries may leverage this opportunity to modify, mux, and maliciously annoy (MMA) read-only memory (ROM) regularly accessed during normal system operations. + associated with Graphics Interchange Format (JIF) image viewers can be abused to corrupt arbitrary memory banks. Adversaries may leverage this opportunity to modify, mux, and maliciously annoy (MMA) read-only memory (ROM) regularly accessed during normal system operations.

Detection: Monitor the JIF viewers for muxing @@ -121,14 +131,14 @@

Required Permissions:

Mitigation: Configure the Registry key - HKLM\SYSTEM\ControlSet\001\Control\WindowsJIFControl\ to 0 to disable MMA access - if not needed within the environment. + HKLM\SYSTEM\ControlSet\001\Control\WindowsJIFControl\ to 0 to disable MMA access + if not needed within the environment.

Adversary Use: Here is a publicly-available - reference about FUZZYSNUGGLYDUCK using this technique: - (www[.]awesomeThreatReports[.]org/FUZZYSNUGGLYDUCK_NOMS _ON_ROM_VIA_COM). - Additionally, our red team uses this in our operations. + reference about FUZZYSNUGGLYDUCK using this technique: + (www[.]awesomeThreatReports[.]org/FUZZYSNUGGLYDUCK_NOMS _ON_ROM_VIA_COM). + Additionally, our red team uses this in our operations.

Additional References: Here is a reference @@ -252,8 +262,12 @@

Contributors

Thanks to those who have contributed to ATT&CK!

+
-{% endblock %} {% block scripts %} {{ super () }} -{% endblock %} \ No newline at end of file +{% endblock %} +{% block scripts %} {{ super () }} + + +{% endblock %} \ No newline at end of file diff --git a/modules/software/__init__.py b/modules/software/__init__.py index e9d0f6a651b..103553ec56d 100644 --- a/modules/software/__init__.py +++ b/modules/software/__init__.py @@ -5,16 +5,6 @@ def get_priority(): return software_config.priority -def get_menu(): - return { - "display_name": software_config.module_name, - "module_name": software_config.module_name, - "url": "/software/", - "external_link": False, - "priority": software_config.priority, - "children": [] - } - # TODO commented out to resolve infinite redirect loop when run locally. Needs further testing before code removal. # def get_redirections(): # with open(software_config.software_redirection_location , "r", encoding="utf8") as json_redirections: diff --git a/update-attack.py b/update-attack.py index 602fd29cc56..6bf29a89952 100644 --- a/update-attack.py +++ b/update-attack.py @@ -29,7 +29,7 @@ "subdirectory", "tests", ] -extras = ["resources", "versions", "contribute", "blog", "stixtests"] +extras = ["resources", "versions", "blog", "stixtests", "benefactors"] test_choices = ["size", "links", "external_links", "citations"] @@ -229,7 +229,7 @@ def remove_from_menu(): ptr["run_module"]() end_time = time.time() util.buildhelpers.print_end(ptr["module_name"], start_time, end_time) - + # Print end of module update_end = time.time() util.buildhelpers.print_end("TOTAL Update Time", update_start, update_end) From 07dd712e9008a43373dc468ddcf2fef32170bb94 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:53:18 -0400 Subject: [PATCH 35/51] update navbar --- modules/assets/__init__.py | 12 ------------ modules/datasources/__init__.py | 1 + 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/modules/assets/__init__.py b/modules/assets/__init__.py index 454a48536c3..f39002b53e5 100644 --- a/modules/assets/__init__.py +++ b/modules/assets/__init__.py @@ -5,17 +5,5 @@ def get_priority(): return assets_config.priority - -def get_menu(): - return { - "display_name": assets_config.module_name, - "module_name": assets_config.module_name, - "url": "/assets", - "external_link": False, - "priority": assets_config.priority, - "children": [], - } - - def run_module(): return (assets.generate_assets(), assets_config.module_name) diff --git a/modules/datasources/__init__.py b/modules/datasources/__init__.py index 8790954c0db..9d0e95b11c8 100644 --- a/modules/datasources/__init__.py +++ b/modules/datasources/__init__.py @@ -24,6 +24,7 @@ def get_menu(): {"display_name": "Groups", "url": "/groups", "external_link": False, "children": []}, {"display_name": "Software", "url": "/software", "external_link": False, "children": []}, {"display_name": "Campaigns", "url": "/datasources", "external_link": False, "children": []}, + {"display_name": "Assets", "url": "/assets", "external_link": False, "children": [] }, ], } From e471215d22605f38b4de5feccd0e66aaff437bcc Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 22 Sep 2023 12:05:15 -0400 Subject: [PATCH 36/51] campaigns link changed --- modules/datasources/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/datasources/__init__.py b/modules/datasources/__init__.py index 8790954c0db..5c33c5c4402 100644 --- a/modules/datasources/__init__.py +++ b/modules/datasources/__init__.py @@ -23,7 +23,7 @@ def get_menu(): ]}, {"display_name": "Groups", "url": "/groups", "external_link": False, "children": []}, {"display_name": "Software", "url": "/software", "external_link": False, "children": []}, - {"display_name": "Campaigns", "url": "/datasources", "external_link": False, "children": []}, + {"display_name": "Campaigns", "url": "/campaigns", "external_link": False, "children": []}, ], } From c595399d319eeac88dbcd235657d1d06ccc92014 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 10:12:11 -0400 Subject: [PATCH 37/51] code cleanup --- ...-load-resources.js => sidebar-load-all.js} | 3 ++ .../static/scripts/sidebar-load-campaigns.js | 31 ----------------- .../static/scripts/sidebar-load-groups.js | 31 ----------------- .../static/scripts/sidebar-load-matrices.js | 34 ------------------- .../scripts/sidebar-load-mitigations.js | 31 ----------------- .../static/scripts/sidebar-load-software.js | 31 ----------------- .../static/scripts/sidebar-load-tactics.js | 31 ----------------- .../static/scripts/sidebar-load-techniques.js | 31 ----------------- attack-theme/static/style/_layouts.scss | 5 +++ .../templates/general/attackcon-overview.html | 4 +-- .../templates/general/faq-overview.html | 4 +-- .../templates/general/intro-overview.html | 4 +-- modules/campaigns/templates/campaign.html | 4 +-- .../campaigns/templates/campaigns-index.html | 4 +-- modules/groups/templates/group.html | 4 +-- modules/groups/templates/groups-index.html | 6 ++-- modules/matrices/templates/matrix.html | 7 ++-- modules/mitigations/templates/mitigation.html | 6 ++-- .../templates/mitigations-domain-index.html | 6 ++-- modules/resources/templates/brand.html | 4 +-- .../resources/templates/getting-started.html | 4 +-- .../resources/templates/related-projects.html | 4 +-- modules/resources/templates/resources.html | 4 +-- modules/resources/templates/training-cti.html | 4 +-- modules/resources/templates/training.html | 4 +-- modules/resources/templates/update-post.html | 4 +-- .../resources/templates/updates-index.html | 4 +-- .../templates/working-with-attack.html | 4 +-- .../software/templates/software-index.html | 4 +-- modules/software/templates/software.html | 4 +-- modules/tactics/templates/tactic.html | 4 +-- .../templates/tactics-domain-index.html | 4 +-- modules/techniques/templates/technique.html | 5 ++- .../templates/techniques-domain-index.html | 4 +-- modules/versions/templates/versions.html | 4 +-- .../website_build/templates/changelog.html | 4 +-- 36 files changed, 66 insertions(+), 280 deletions(-) rename attack-theme/static/scripts/{sidebar-load-resources.js => sidebar-load-all.js} (93%) delete mode 100644 attack-theme/static/scripts/sidebar-load-campaigns.js delete mode 100644 attack-theme/static/scripts/sidebar-load-groups.js delete mode 100644 attack-theme/static/scripts/sidebar-load-matrices.js delete mode 100644 attack-theme/static/scripts/sidebar-load-mitigations.js delete mode 100644 attack-theme/static/scripts/sidebar-load-software.js delete mode 100644 attack-theme/static/scripts/sidebar-load-tactics.js delete mode 100644 attack-theme/static/scripts/sidebar-load-techniques.js diff --git a/attack-theme/static/scripts/sidebar-load-resources.js b/attack-theme/static/scripts/sidebar-load-all.js similarity index 93% rename from attack-theme/static/scripts/sidebar-load-resources.js rename to attack-theme/static/scripts/sidebar-load-all.js index 8f577e8369a..b628ee6cc1d 100644 --- a/attack-theme/static/scripts/sidebar-load-resources.js +++ b/attack-theme/static/scripts/sidebar-load-all.js @@ -10,6 +10,9 @@ $("#sidebars").load(mod_entry, function() { else{ winlocation = window.location.href } + if(!element.href.endsWith("/")){ + element.href = element.href + "/"; + } if(element.href == winlocation){ $(element.parentNode).addClass("active") }}); diff --git a/attack-theme/static/scripts/sidebar-load-campaigns.js b/attack-theme/static/scripts/sidebar-load-campaigns.js deleted file mode 100644 index 28778ecb8e5..00000000000 --- a/attack-theme/static/scripts/sidebar-load-campaigns.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/campaigns/sidebar-campaigns", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-groups.js b/attack-theme/static/scripts/sidebar-load-groups.js deleted file mode 100644 index e02e0cd58c0..00000000000 --- a/attack-theme/static/scripts/sidebar-load-groups.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/groups/sidebar-groups", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-matrices.js b/attack-theme/static/scripts/sidebar-load-matrices.js deleted file mode 100644 index 942af251ed3..00000000000 --- a/attack-theme/static/scripts/sidebar-load-matrices.js +++ /dev/null @@ -1,34 +0,0 @@ -$("#sidebars").load("/matrices/sidebar-matrices", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(!element.href.endsWith("/")){ - element.href = element.href + "/"; - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-mitigations.js b/attack-theme/static/scripts/sidebar-load-mitigations.js deleted file mode 100644 index b6f33cd8fdc..00000000000 --- a/attack-theme/static/scripts/sidebar-load-mitigations.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/mitigations/sidebar-mitigations", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) - }); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-software.js b/attack-theme/static/scripts/sidebar-load-software.js deleted file mode 100644 index b3ddcc1a8c7..00000000000 --- a/attack-theme/static/scripts/sidebar-load-software.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/software/sidebar-software", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-tactics.js b/attack-theme/static/scripts/sidebar-load-tactics.js deleted file mode 100644 index a027727706a..00000000000 --- a/attack-theme/static/scripts/sidebar-load-tactics.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/tactics/sidebar-tactics", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/scripts/sidebar-load-techniques.js b/attack-theme/static/scripts/sidebar-load-techniques.js deleted file mode 100644 index d4ea07d99d5..00000000000 --- a/attack-theme/static/scripts/sidebar-load-techniques.js +++ /dev/null @@ -1,31 +0,0 @@ -$("#sidebars").load("/techniques/sidebar-techniques", function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; - navElements.forEach(function(element){ - if(!window.location.href.endsWith("/")){ - winlocation = window.location.href + "/"; - } - else{ - winlocation = window.location.href - } - if(element.href == winlocation){ - $(element.parentNode).addClass("active") - }}); - - //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } - } - $(document).ready(function() { - mobileSidenav(mediaQuery) - let sidenav_active_elements = $(".sidenav .active"); - sidenav_active_elements[0].scrollIntoView({ block: 'nearest', inline: 'start' }) - }); - mediaQuery.addEventListener('change', mobileSidenav) -}); \ No newline at end of file diff --git a/attack-theme/static/style/_layouts.scss b/attack-theme/static/style/_layouts.scss index 7a278e0c49b..02a91afe6a6 100644 --- a/attack-theme/static/style/_layouts.scss +++ b/attack-theme/static/style/_layouts.scss @@ -1051,6 +1051,11 @@ pre { /******/ +// how to display the sidebar +div#sidebars { + display: contents +} + /*Plus/Minus expand icons*/ // used in the expandable list items in the side navigation and in the expandable gray blocks in ATT&CKCON .expand-icon { diff --git a/attack-theme/templates/general/attackcon-overview.html b/attack-theme/templates/general/attackcon-overview.html index 251c95f8ca7..380986eee32 100644 --- a/attack-theme/templates/general/attackcon-overview.html +++ b/attack-theme/templates/general/attackcon-overview.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -115,5 +115,5 @@

Sponsors

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/faq-overview.html b/attack-theme/templates/general/faq-overview.html index 61ee0ff074a..0abe4d06579 100644 --- a/attack-theme/templates/general/faq-overview.html +++ b/attack-theme/templates/general/faq-overview.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -62,5 +62,5 @@
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/intro-overview.html b/attack-theme/templates/general/intro-overview.html index 9a53db9224f..76a7e420941 100644 --- a/attack-theme/templates/general/intro-overview.html +++ b/attack-theme/templates/general/intro-overview.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -23,5 +23,5 @@

{{ page.title }}

{% block scripts %} {{ super () }} - + {% endblock %} diff --git a/modules/campaigns/templates/campaign.html b/modules/campaigns/templates/campaign.html index 929cdb3d27d..7f777b1ec46 100644 --- a/modules/campaigns/templates/campaign.html +++ b/modules/campaigns/templates/campaign.html @@ -27,7 +27,7 @@ {% block innerleft %} - + {% endblock %} @@ -262,5 +262,5 @@

Software

- + {% endblock %} diff --git a/modules/campaigns/templates/campaigns-index.html b/modules/campaigns/templates/campaigns-index.html index f08b1a7dcb2..79f8fd1c8f4 100644 --- a/modules/campaigns/templates/campaigns-index.html +++ b/modules/campaigns/templates/campaigns-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} @@ -93,5 +93,5 @@
Campaigns: {{ parsed.campaigns_list_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/groups/templates/group.html b/modules/groups/templates/group.html index ace6f923b2d..fe5809a061f 100644 --- a/modules/groups/templates/group.html +++ b/modules/groups/templates/group.html @@ -27,7 +27,7 @@ {% block innerleft %} - + {% endblock %} @@ -264,7 +264,7 @@

Software

{% block scripts %} {{ super() }} - + diff --git a/modules/groups/templates/groups-index.html b/modules/groups/templates/groups-index.html index 6009f9a0f56..1df205d670c 100644 --- a/modules/groups/templates/groups-index.html +++ b/modules/groups/templates/groups-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} @@ -85,5 +85,5 @@
Groups: {{ parsed.groups_list_len }}
{% block scripts %} {{ super() }} - - {% endblock %} \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/modules/matrices/templates/matrix.html b/modules/matrices/templates/matrix.html index 92c2d1fc06f..fc1177aa7ea 100644 --- a/modules/matrices/templates/matrix.html +++ b/modules/matrices/templates/matrix.html @@ -30,7 +30,7 @@ {% block innerleft %} - + {% endblock %} @@ -123,6 +123,5 @@

{{parsed.name}} {{matrix_plural}}

- - -{% endblock %} + + {% endblock %} diff --git a/modules/mitigations/templates/mitigation.html b/modules/mitigations/templates/mitigation.html index 49abfb63dac..261d8e1518b 100644 --- a/modules/mitigations/templates/mitigation.html +++ b/modules/mitigations/templates/mitigation.html @@ -26,7 +26,7 @@ {% block innerleft %} - + {% endblock %} @@ -109,5 +109,5 @@

{% block scripts %} {{ super() }} - - {% endblock %} \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/modules/mitigations/templates/mitigations-domain-index.html b/modules/mitigations/templates/mitigations-domain-index.html index 125748a2bdf..a387fc452e7 100644 --- a/modules/mitigations/templates/mitigations-domain-index.html +++ b/modules/mitigations/templates/mitigations-domain-index.html @@ -14,7 +14,7 @@ {% block innerleft %} - + {% endblock %} @@ -91,5 +91,5 @@

Mitigations: {{parsed.mitigation_list_len}}
{% block scripts %} {{ super() }} - -{% endblock %} \ No newline at end of file + +{% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/brand.html b/modules/resources/templates/brand.html index f78dc0c1671..24ab7d85e96 100644 --- a/modules/resources/templates/brand.html +++ b/modules/resources/templates/brand.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -76,5 +76,5 @@

Brand Guide

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/getting-started.html b/modules/resources/templates/getting-started.html index c107edb00bc..5f3151705aa 100644 --- a/modules/resources/templates/getting-started.html +++ b/modules/resources/templates/getting-started.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -261,5 +261,5 @@

Community

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/related-projects.html b/modules/resources/templates/related-projects.html index d10f3e97e27..2de4b2615a8 100644 --- a/modules/resources/templates/related-projects.html +++ b/modules/resources/templates/related-projects.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -114,5 +114,5 @@
- + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/resources.html b/modules/resources/templates/resources.html index 1b086537522..b8dce9485e7 100644 --- a/modules/resources/templates/resources.html +++ b/modules/resources/templates/resources.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -155,5 +155,5 @@

Other Resources

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training-cti.html b/modules/resources/templates/training-cti.html index 8142f82007f..17f2720005b 100644 --- a/modules/resources/templates/training-cti.html +++ b/modules/resources/templates/training-cti.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -282,5 +282,5 @@

Exercise 5: Making defensive recommendations {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/training.html b/modules/resources/templates/training.html index 3a8c55729a1..8c8be27956d 100644 --- a/modules/resources/templates/training.html +++ b/modules/resources/templates/training.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -47,5 +47,5 @@

ATT&CK Training

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/update-post.html b/modules/resources/templates/update-post.html index 9c2efa99406..bc48630d877 100644 --- a/modules/resources/templates/update-post.html +++ b/modules/resources/templates/update-post.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -22,5 +22,5 @@

{{ article.title }}

{% endblock %} {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/updates-index.html b/modules/resources/templates/updates-index.html index b1978332d23..5bbcb8ca15c 100644 --- a/modules/resources/templates/updates-index.html +++ b/modules/resources/templates/updates-index.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} {{ super () }} @@ -24,5 +24,5 @@

{{ (articles|selectattr('template', 'equalto', {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/resources/templates/working-with-attack.html b/modules/resources/templates/working-with-attack.html index c113a02082a..731e92094ba 100644 --- a/modules/resources/templates/working-with-attack.html +++ b/modules/resources/templates/working-with-attack.html @@ -6,7 +6,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -192,5 +192,5 @@

Explore our standa {% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/software/templates/software-index.html b/modules/software/templates/software-index.html index d03c5748c7c..c1a43d2e6e5 100644 --- a/modules/software/templates/software-index.html +++ b/modules/software/templates/software-index.html @@ -7,7 +7,7 @@ {% block innerleft %} - + {% endblock %} @@ -85,5 +85,5 @@
Software: {{ parsed.software_list_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/software/templates/software.html b/modules/software/templates/software.html index 4b6a4bf8945..edd180874a7 100644 --- a/modules/software/templates/software.html +++ b/modules/software/templates/software.html @@ -21,7 +21,7 @@ {% block innerleft %} - + {% endblock %} @@ -240,7 +240,7 @@

Campaigns

{% block scripts %} {{ super() }} - + diff --git a/modules/tactics/templates/tactic.html b/modules/tactics/templates/tactic.html index f687d3949b0..fec15eaca49 100644 --- a/modules/tactics/templates/tactic.html +++ b/modules/tactics/templates/tactic.html @@ -25,7 +25,7 @@ {% block innerleft %} - + {% endblock %} @@ -106,5 +106,5 @@

Techniques

{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/tactics/templates/tactics-domain-index.html b/modules/tactics/templates/tactics-domain-index.html index d883d4cc0b8..46694230c05 100644 --- a/modules/tactics/templates/tactics-domain-index.html +++ b/modules/tactics/templates/tactics-domain-index.html @@ -23,7 +23,7 @@ {% block innerleft %} - + {% endblock %} @@ -114,5 +114,5 @@
Tactics: {{ parsed.tactics_list_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index 2a67f28e5f6..e413e42af77 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -37,7 +37,7 @@ {% block innerleft %} - + {% endblock %} @@ -453,6 +453,5 @@

Difficulty for the Adversary

{% else %} {% endif %} - - + {% endblock %} \ No newline at end of file diff --git a/modules/techniques/templates/techniques-domain-index.html b/modules/techniques/templates/techniques-domain-index.html index 29f82742e2f..9cd8308b4ee 100644 --- a/modules/techniques/templates/techniques-domain-index.html +++ b/modules/techniques/templates/techniques-domain-index.html @@ -23,7 +23,7 @@ {% block innerleft %} - + {% endblock %} @@ -84,5 +84,5 @@
Sub-techniques: {{ parsed.subtechniques_len }}
{% block scripts %} {{ super() }} - + {% endblock %} \ No newline at end of file diff --git a/modules/versions/templates/versions.html b/modules/versions/templates/versions.html index a1203592763..808995ef85f 100644 --- a/modules/versions/templates/versions.html +++ b/modules/versions/templates/versions.html @@ -5,7 +5,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -88,5 +88,5 @@

Versions of ATT&CK

- + {% endblock %} diff --git a/modules/website_build/templates/changelog.html b/modules/website_build/templates/changelog.html index 3cd1ec4a02e..6366ad7bc91 100644 --- a/modules/website_build/templates/changelog.html +++ b/modules/website_build/templates/changelog.html @@ -4,7 +4,7 @@ {% import 'macros/navigation.html' as navigation %} {% block innerleft %} - + {% endblock %} {% block innerright %} @@ -33,5 +33,5 @@

Changelog

{% endblock %} {% block scripts %} {{ super () }} - + {% endblock %} From 86bcd4c550c61b7b84ed332320e95cf1727f94f5 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Wed, 27 Sep 2023 11:54:59 -0400 Subject: [PATCH 38/51] code smell --- modules/assets/assets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/assets/assets.py b/modules/assets/assets.py index aea00b90a7f..25c166e201e 100644 --- a/modules/assets/assets.py +++ b/modules/assets/assets.py @@ -22,7 +22,6 @@ def generate_assets(): if not os.path.isdir(assets_config.asset_markdown_path): os.mkdir(assets_config.asset_markdown_path) - # TODO resolve infinite redirect loop when run locally. Needs further testing before code removal. # Generate redirections util.buildhelpers.generate_redirections( redirections_filename=assets_config.assets_redirection_location, redirect_md=site_config.redirect_md From 4833c5a4ec501d278b875e177db290631b96efee Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 16:08:14 -0400 Subject: [PATCH 39/51] fixed error with mobile view --- .../static/scripts/mobileview-datasources.js | 16 ++++++++++++++++ attack-theme/static/scripts/resizer.js | 19 +------------------ attack-theme/static/style/_layouts.scss | 4 ++++ .../templates/general/base-template.html | 1 - .../templates/general/two-column.html | 5 +++++ .../templates/macros/datasource_table.html | 2 ++ .../templates/macros/techniques_used.html | 2 ++ modules/campaigns/templates/campaign.html | 6 ++++++ .../campaigns/templates/campaigns-index.html | 2 ++ modules/datasources/templates/datasource.html | 3 +-- .../templates/datasources-index.html | 1 + modules/groups/templates/group.html | 6 ++++++ modules/groups/templates/groups-index.html | 2 ++ .../templates/mitigations-domain-index.html | 2 ++ .../software/templates/software-index.html | 2 ++ modules/software/templates/software.html | 6 ++++++ .../templates/tactics-domain-index.html | 2 ++ modules/techniques/templates/technique.html | 4 ++++ modules/versions/templates/versions.html | 2 ++ 19 files changed, 66 insertions(+), 21 deletions(-) create mode 100644 attack-theme/static/scripts/mobileview-datasources.js diff --git a/attack-theme/static/scripts/mobileview-datasources.js b/attack-theme/static/scripts/mobileview-datasources.js new file mode 100644 index 00000000000..3896a292eb5 --- /dev/null +++ b/attack-theme/static/scripts/mobileview-datasources.js @@ -0,0 +1,16 @@ +// This code is for creating a collapsable sidebar for the mobile view +var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + +function mobileSidenav(e) { + if (e.matches) { + $('#sidebar-collapse').collapse('hide') + } + else{ + $('#sidebar-collapse').collapse('show') + } +} +$(document).ready(function() { + mobileSidenav(mediaQuery) +}); + +mediaQuery.addEventListener('change', mobileSidenav) \ No newline at end of file diff --git a/attack-theme/static/scripts/resizer.js b/attack-theme/static/scripts/resizer.js index d14d334b337..da812317539 100644 --- a/attack-theme/static/scripts/resizer.js +++ b/attack-theme/static/scripts/resizer.js @@ -31,21 +31,4 @@ function resizeSidebar_mouseupHandler() { } resizer.addEventListener("mousedown", resizeSidebar_mousedownHandler); -} - -//This code is for creating a collapsable sidebar for the mobile view -var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') - -function mobileSidenav(e) { - if (e.matches) { - $('#sidebar-collapse').collapse('hide') - } - else{ - $('#sidebar-collapse').collapse('show') - } -} -$(document).ready(function() { - mobileSidenav(mediaQuery) -}); - -mediaQuery.addEventListener('change', mobileSidenav) \ No newline at end of file +} \ No newline at end of file diff --git a/attack-theme/static/style/_layouts.scss b/attack-theme/static/style/_layouts.scss index 02a91afe6a6..a7663b89f5a 100644 --- a/attack-theme/static/style/_layouts.scss +++ b/attack-theme/static/style/_layouts.scss @@ -388,6 +388,10 @@ a { } } +.tables-mobile { + overflow-y: auto; +} + .table-bordered, .blog-post table, .changelog table { &, & td, & th { border: 1px solid border-color(body); diff --git a/attack-theme/templates/general/base-template.html b/attack-theme/templates/general/base-template.html index 3fad1450130..2d58912ceb4 100644 --- a/attack-theme/templates/general/base-template.html +++ b/attack-theme/templates/general/base-template.html @@ -161,7 +161,6 @@ - {% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/general/two-column.html b/attack-theme/templates/general/two-column.html index 5d392da8c86..74c51701f5d 100644 --- a/attack-theme/templates/general/two-column.html +++ b/attack-theme/templates/general/two-column.html @@ -22,3 +22,8 @@ {% endblock %} {% endblock %} +{% block scripts %} +{{ super() }} + + +{% endblock %} diff --git a/attack-theme/templates/macros/datasource_table.html b/attack-theme/templates/macros/datasource_table.html index 6a18cd05f05..062a57a5e4c 100644 --- a/attack-theme/templates/macros/datasource_table.html +++ b/attack-theme/templates/macros/datasource_table.html @@ -1,6 +1,7 @@ {% import 'macros/clean_output.html' as clean_output %} {% macro datasource_table(datasources, show_descriptions, citations=None) %} +

NameSectorSectors Description
{{ related_asset.name }}{{ related_asset.sector }}{{ related_asset.sectors }} {{ clean_output.stixToHTML(related_asset.descr, parsed.citations) }}
ID AssetDescription
{{asset.name}} - {% if asset.descr %} - {{clean_output.stixToHTML(asset.descr, parsed.citations)}} - {% endif %} -
@@ -50,4 +51,5 @@ {% endfor %}
+ {% endmacro %} \ No newline at end of file diff --git a/attack-theme/templates/macros/techniques_used.html b/attack-theme/templates/macros/techniques_used.html index 21e5d5cf626..e707f7738b7 100644 --- a/attack-theme/templates/macros/techniques_used.html +++ b/attack-theme/templates/macros/techniques_used.html @@ -4,6 +4,7 @@ {% if title %}

{{title}}

{% endif %} +
@@ -133,4 +134,5 @@

{{title}}

{% endfor %}
+
{% endmacro %} \ No newline at end of file diff --git a/modules/campaigns/templates/campaign.html b/modules/campaigns/templates/campaign.html index 7f777b1ec46..874baadaa8f 100644 --- a/modules/campaigns/templates/campaign.html +++ b/modules/campaigns/templates/campaign.html @@ -160,6 +160,7 @@

{{ parsed.name }}

{% if parsed.alias_descriptions %}

Associated Campaign Descriptions

+
@@ -180,10 +181,12 @@

Associated Campaign Descriptions

{% endfor %}
+
{% endif %} {% if parsed.group_data %}

Groups

+
@@ -210,6 +213,7 @@

Groups

{% endfor %}
+
{% endif %} {% if parsed.technique_table_data %} @@ -219,6 +223,7 @@

Groups

{% if parsed.software_data %}

Software

+
@@ -245,6 +250,7 @@

Software

{% endfor %}
+
{% endif %} {{ citations.reference_section(parsed.citations) }} diff --git a/modules/campaigns/templates/campaigns-index.html b/modules/campaigns/templates/campaigns-index.html index 79f8fd1c8f4..9aa0e1c6ce2 100644 --- a/modules/campaigns/templates/campaigns-index.html +++ b/modules/campaigns/templates/campaigns-index.html @@ -49,6 +49,7 @@

Campaigns

Campaigns: {{ parsed.campaigns_list_len }}
+
@@ -82,6 +83,7 @@
Campaigns: {{ parsed.campaigns_list_len }}
{% endfor %}
+
diff --git a/modules/datasources/templates/datasource.html b/modules/datasources/templates/datasource.html index 8e7ce56c470..9ec60ae9daf 100644 --- a/modules/datasources/templates/datasource.html +++ b/modules/datasources/templates/datasource.html @@ -177,7 +177,6 @@

{{parsed.name}}: {{datacomponent.name}}

{% endif %} - {% if datacomponent.techniques %} {% if datacomponent.add_datacomponent_ref %} {{techniques_used.techniques_used(datacomponent.techniques, "", true, "Detects", parsed.citations)}} @@ -185,7 +184,6 @@

{{parsed.name}}: {{datacomponent.name}}

{{techniques_used.techniques_used(datacomponent.techniques, "", true, "")}} {% endif %} {% endif %} - {% endfor %} @@ -205,6 +203,7 @@

{{parsed.name}}: {{datacomponent.name}}

+ diff --git a/modules/datasources/templates/datasources-index.html b/modules/datasources/templates/datasources-index.html index 9a9348972d4..6e1bbb91ec6 100644 --- a/modules/datasources/templates/datasources-index.html +++ b/modules/datasources/templates/datasources-index.html @@ -74,5 +74,6 @@
Data Sources: {{ parsed.datasources_list_len }} + {% endblock %} \ No newline at end of file diff --git a/modules/groups/templates/group.html b/modules/groups/templates/group.html index fe5809a061f..bfab72e72d7 100644 --- a/modules/groups/templates/group.html +++ b/modules/groups/templates/group.html @@ -139,6 +139,7 @@

{% if parsed.alias_descriptions %}

Associated Group Descriptions

+
@@ -159,10 +160,12 @@

Associated Group Descriptions

{% endfor %}
+
{% endif %} {% if parsed.campaign_data %}

Campaigns

+
@@ -203,6 +206,7 @@

Campaigns

{% endfor %}
+
{% endif %} {% if parsed.technique_table_data %} @@ -212,6 +216,7 @@

Campaigns

{% if parsed.software_data %}

Software

+
@@ -250,6 +255,7 @@

Software

{% endfor %}
+
{% endif %} {{ citations.reference_section(parsed.citations) }} diff --git a/modules/groups/templates/groups-index.html b/modules/groups/templates/groups-index.html index 1df205d670c..aa3ea66b7bd 100644 --- a/modules/groups/templates/groups-index.html +++ b/modules/groups/templates/groups-index.html @@ -43,6 +43,7 @@

Groups

Groups: {{ parsed.groups_list_len }}
+
@@ -74,6 +75,7 @@
Groups: {{ parsed.groups_list_len }}
{% endfor %}
+
diff --git a/modules/mitigations/templates/mitigations-domain-index.html b/modules/mitigations/templates/mitigations-domain-index.html index a387fc452e7..9412fb49db5 100644 --- a/modules/mitigations/templates/mitigations-domain-index.html +++ b/modules/mitigations/templates/mitigations-domain-index.html @@ -57,6 +57,7 @@

Mitigations: {{parsed.mitigation_list_len}}
+
@@ -81,6 +82,7 @@
Mitigations: {{parsed.mitigation_list_len}}
{% endfor %}
+
diff --git a/modules/software/templates/software-index.html b/modules/software/templates/software-index.html index c1a43d2e6e5..0c43f5b1055 100644 --- a/modules/software/templates/software-index.html +++ b/modules/software/templates/software-index.html @@ -44,6 +44,7 @@

Software

Software: {{ parsed.software_list_len }}
+
@@ -75,6 +76,7 @@
Software: {{ parsed.software_list_len }}
{% endfor %}
+
diff --git a/modules/software/templates/software.html b/modules/software/templates/software.html index edd180874a7..3d606f47a9f 100644 --- a/modules/software/templates/software.html +++ b/modules/software/templates/software.html @@ -142,6 +142,7 @@

{% if parsed.alias_descriptions %}

Associated Software Descriptions

+
@@ -162,6 +163,7 @@

Associated Software Descriptions

{% endfor %}
+
{% endif %} {% if parsed.technique_table_data %} @@ -171,6 +173,7 @@

Associated Software Descriptions

{% if parsed.groups %}

Groups That Use This Software

+
@@ -195,10 +198,12 @@

Groups That Use This Software

{% endfor %}
+
{% endif %} {% if parsed.campaign_data %}

Campaigns

+
@@ -225,6 +230,7 @@

Campaigns

{% endfor %}
+
{% endif %} {{ citations.reference_section(parsed.citations) }} diff --git a/modules/tactics/templates/tactics-domain-index.html b/modules/tactics/templates/tactics-domain-index.html index 46694230c05..ad0de01a2a4 100644 --- a/modules/tactics/templates/tactics-domain-index.html +++ b/modules/tactics/templates/tactics-domain-index.html @@ -77,6 +77,7 @@
Tactics: {{ parsed.tactics_list_len }}
+
@@ -101,6 +102,7 @@
Tactics: {{ parsed.tactics_list_len }}
{% endfor %}
+
diff --git a/modules/techniques/templates/technique.html b/modules/techniques/templates/technique.html index e413e42af77..6a267b098e5 100644 --- a/modules/techniques/templates/technique.html +++ b/modules/techniques/templates/technique.html @@ -340,6 +340,7 @@
Sub-techniques ({{parsed.subtechniques|len {% if parsed.examples_table %}

Procedure Examples

+
@@ -366,10 +367,12 @@

Procedure Examples

{% endfor %}
+
{% endif %} {% if parsed.domain != 'pre' %}

Mitigations

{% if parsed.mitigation_table %} +
@@ -396,6 +399,7 @@

Mitigations

{% endfor %}
+
{% else %}

This type of attack technique cannot be easily mitigated with preventive controls since diff --git a/modules/versions/templates/versions.html b/modules/versions/templates/versions.html index 808995ef85f..39b8aeff481 100644 --- a/modules/versions/templates/versions.html +++ b/modules/versions/templates/versions.html @@ -30,6 +30,7 @@

Versions of ATT&CK

Below are a list of versions of the ATT&CK website preserved for posterity, including a permalink to the current version of the site:

+
@@ -76,6 +77,7 @@

Versions of ATT&CK

{% endfor %}
+
From fb125a8ad4501ea08789c5486133986b384cbe2d Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 16:09:48 -0400 Subject: [PATCH 40/51] deleted file --- modules/resources/docs/sidebar.html | 353 ---------------------------- 1 file changed, 353 deletions(-) delete mode 100644 modules/resources/docs/sidebar.html diff --git a/modules/resources/docs/sidebar.html b/modules/resources/docs/sidebar.html deleted file mode 100644 index 29bf998ebb9..00000000000 --- a/modules/resources/docs/sidebar.html +++ /dev/null @@ -1,353 +0,0 @@ - - -
- \ No newline at end of file From f6091500f70b1ce000a17e6e185a181c0817fb90 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 16:52:34 -0400 Subject: [PATCH 41/51] updated navbar --- .gitignore | 2 +- .../templates/benefactors/benefactors.html | 34 ------------------- .../templates/macros/navigation_menu.html | 2 +- modules/datasources/__init__.py | 7 ++-- modules/datasources/datasources_config.py | 4 +-- modules/groups/__init__.py | 14 ++++++++ modules/groups/groups_config.py | 1 + 7 files changed, 21 insertions(+), 43 deletions(-) delete mode 100644 attack-theme/templates/benefactors/benefactors.html diff --git a/.gitignore b/.gitignore index 59588f224dc..0747c13ebe4 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ output/ reports/ attack-theme/templates/general/base.html -attack-theme/templates/contribute +attack-theme/templates/benefactors attack-theme/templates/datasources attack-theme/templates/groups attack-theme/templates/campaigns diff --git a/attack-theme/templates/benefactors/benefactors.html b/attack-theme/templates/benefactors/benefactors.html deleted file mode 100644 index ab7b3823ae6..00000000000 --- a/attack-theme/templates/benefactors/benefactors.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "general/two-column.html" %} -{% set active_page = "resources" -%} -{% set title = "Benefactors | MITRE ATT&CK®" -%} -{% import 'macros/navigation.html' as navigation %} - -{% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
-{% endblock %} - -{% block innerright %} -
- -
-
-
-
-
-

Benefactors

-
-
-
-
-{% endblock %} -{% block scripts %} -{{ super () }} - - -{% endblock %} \ No newline at end of file diff --git a/attack-theme/templates/macros/navigation_menu.html b/attack-theme/templates/macros/navigation_menu.html index 8adb025cb55..b77fd46285b 100644 --- a/attack-theme/templates/macros/navigation_menu.html +++ b/attack-theme/templates/macros/navigation_menu.html @@ -61,7 +61,7 @@ {% macro child_has_child(element) %} -
+