From 602e67a2cc26f77a96721aef1615f61b2b101ec7 Mon Sep 17 00:00:00 2001 From: adpare Date: Mon, 11 Sep 2023 19:49:24 -0400 Subject: [PATCH 01/25] 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 764153ab0452586485460ab6d5a74e4e42083e73 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 13 Sep 2023 09:52:49 -0400 Subject: [PATCH 02/25] 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 f61a152df26413fd6f80e8a80618199ce3eabd96 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 00:18:04 -0400 Subject: [PATCH 03/25] 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 04/25] 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 05/25] 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 dae4c9c63c38e35e08965f924a488d70a1608316 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 15 Sep 2023 12:36:27 -0400 Subject: [PATCH 06/25] 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 07/25] 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 08/25] 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 09/25] 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 10/25] 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 11/25] 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 12/25] 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 13/25] 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 9d1d3a250c8c3df12dad8938f12705a26a39e21d Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 10:47:49 -0400 Subject: [PATCH 14/25] 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 15/25] 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 16/25] 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 952442569df3da52a962445c6bb566025ef7f9ad Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 20 Sep 2023 15:40:58 -0400 Subject: [PATCH 17/25] 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 c595399d319eeac88dbcd235657d1d06ccc92014 Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 10:12:11 -0400 Subject: [PATCH 18/25] 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 4833c5a4ec501d278b875e177db290631b96efee Mon Sep 17 00:00:00 2001 From: adpare Date: Wed, 27 Sep 2023 16:08:14 -0400 Subject: [PATCH 19/25] 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) %} +
@@ -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 20/25] 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 82ae1a9ca25711eff5d717743c72921ecaf1617a Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 29 Sep 2023 10:37:13 -0400 Subject: [PATCH 21/25] remove sidebar from unlinked pages list --- modules/tests/linkchecker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/tests/linkchecker.py b/modules/tests/linkchecker.py index d385a2a0d1c..f676abfa544 100644 --- a/modules/tests/linkchecker.py +++ b/modules/tests/linkchecker.py @@ -433,7 +433,8 @@ def check_links(external_links=False): if unlinked_pages: f.write("Pages listed were not linked from another page\n\n") for page in unlinked_pages: - f.write(page + "\n") + if 'sidebar' not in page: #remove the sidebar html pages from unlinked pages + f.write(page + "\n") else: f.write("No unlinked pages found\n") From 937fa9dd9c65d1d13139dec673a5cdb7def2f0b8 Mon Sep 17 00:00:00 2001 From: adpare Date: Fri, 29 Sep 2023 16:10:10 -0400 Subject: [PATCH 22/25] versions module loaded link checker --- modules/tests/linkchecker.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/tests/linkchecker.py b/modules/tests/linkchecker.py index f676abfa544..ad847506b8f 100644 --- a/modules/tests/linkchecker.py +++ b/modules/tests/linkchecker.py @@ -6,7 +6,7 @@ from loguru import logger from modules import site_config - +import modules from . import tests_config # STATIC PROPERTIES @@ -442,12 +442,21 @@ def check_links(external_links=False): broken_count = 0 with open(os.path.join(site_config.test_report_directory, tests_config.links_report_filename), "w") as f: f.write("Broken links report:\n\n") + build_versions_module = False + for module_info in modules.run_ptr: + if module_info["module_name"] == "versions": + build_versions_module = True if broken_pages: for page in broken_pages: f.write(page["path"] + "\n") for problem in page["problems"]: - f.write("\t- " + problem + "\n") - broken_count += 1 + if "versions" in problem: + if build_versions_module: + f.write("\t- " + problem + "\n") + broken_count += 1 + else: + f.write("\t- " + problem + "\n") + broken_count += 1 else: f.write("No broken links found\n") From a1f0e5451ec0bbcac31bf88a2e50ad628325ba1c Mon Sep 17 00:00:00 2001 From: adpare Date: Mon, 2 Oct 2023 13:58:23 -0400 Subject: [PATCH 23/25] code cleanup --- .gitignore | 1 + .../templates/general/sidebar-technique.html | 21 --- modules/resources/templates/attackcon.html | 135 ------------------ modules/website_build/templates/faq.html | 52 ------- 4 files changed, 1 insertion(+), 208 deletions(-) delete mode 100644 attack-theme/templates/general/sidebar-technique.html delete mode 100644 modules/resources/templates/attackcon.html delete mode 100644 modules/website_build/templates/faq.html diff --git a/.gitignore b/.gitignore index a57b1721080..e91dd82628a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ attack-theme/templates/techniques attack-theme/templates/website_build attack-theme/templates/versions attack-theme/static/scripts/settings.js +attack-theme/templates/general/sidebar-resources.html content/ data/pelican_settings.json diff --git a/attack-theme/templates/general/sidebar-technique.html b/attack-theme/templates/general/sidebar-technique.html deleted file mode 100644 index f6dc5d3346b..00000000000 --- a/attack-theme/templates/general/sidebar-technique.html +++ /dev/null @@ -1,21 +0,0 @@ -{% 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/modules/resources/templates/attackcon.html b/modules/resources/templates/attackcon.html deleted file mode 100644 index adddec40bdd..00000000000 --- a/modules/resources/templates/attackcon.html +++ /dev/null @@ -1,135 +0,0 @@ -{% extends "general/two-column.html" %} -{% set active_page = "attackcon" -%} -{% set title = "MITRE ATT&CKcon | MITRE ATT&CK®" -%} -{% set conventions = page.data | from_json %} -{% import 'macros/navigation.html' as navigation %} - -{% block innerleft %} - -{% endblock %} - -{% block innerright %} - -
- -
- -
- -
- {% for con in conventions %} - {% set conID = "-".join(con.date.split(' ')) %} - {% set active = conID == 'March-2022' %} -
- - {% if "banner_img" in con %} -

- -

- {% endif %} - - {% if "description" in con %} -

{{con.description}}

- {% endif %} - {% if "blogpost" in con %} -

Click here to read our blog post about {{con.title}}! External site

- {% endif %} - -
-

Presentations

- {% for presentation in con.presentations %} - {% set isPanel = "moderator" in presentation %} -
- -
-
- {% if not isPanel %} -

{{presentation.description}}

- {% else %} -

Panelists:

-
    - {% for panelist in presentation.panelists %} -
  • - {{panelist}} -
  • - {% endfor %} -
-

{{presentation.moderator.name}} moderates a panel that discusses:

-
    - {% for topic in presentation.topics %} -
  • - {{topic}} -
  • - {% endfor %} -
- {% endif %} - - {% if "video" in presentation %} - video External site - {% else %} - (no video) - {% endif %} - - {% if "slides" in presentation %} - slides External site - {% else %} - (no slides) - {% endif %} -
-
-
- - {% endfor %} -
- {% if "sponsors_img" in con %} -
-

Sponsors

- -
- {% elif "sponsors_img_list" in con %} -
-

Sponsors

-
- {% for sponsor_img in con.sponsors_img_list %} -
- -
- {% endfor %} -
-
- {% endif %} -
- {% endfor %} -
-
- -{% endblock %} - - -{% block scripts %} -{{ super() }} - - -{% endblock %} \ No newline at end of file diff --git a/modules/website_build/templates/faq.html b/modules/website_build/templates/faq.html deleted file mode 100644 index b6baf2c7bb5..00000000000 --- a/modules/website_build/templates/faq.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends "general/two-column.html" %} -{% set active_page = "resources" -%} -{% set title = "FAQ | MITRE ATT&CK®" -%} -{% set parsed = page.data | from_json %} -{% import 'macros/navigation.html' as navigation %} - -{% block innerleft %} -
- {{navigation.sidenav(RESOURCE_NAV, output_file)}} -
-{% endblock %} - -{% block innerright %} - -
- -
-
-

Frequently Asked Questions

-
- {% for section in parsed.sections %} -
-

{{section.name}}

-
- {% for qa in section.questions %} -
- -
-
- {{qa.answer}} -
-
-
- {% endfor %} -
-
- {% endfor %} -
-
-{% endblock %} - -{% block scripts %} -{{ super() }} - - -{% endblock %} \ No newline at end of file From 4b2b26160365a34f7ca9e0f879ac12f5303216ba Mon Sep 17 00:00:00 2001 From: adpare Date: Mon, 2 Oct 2023 17:10:58 -0400 Subject: [PATCH 24/25] fix contribute page on mobile view --- attack-theme/static/scripts/navigation.js | 1 - modules/resources/templates/contribute.html | 24 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/attack-theme/static/scripts/navigation.js b/attack-theme/static/scripts/navigation.js index b19ac4db22e..ef3d7f937d7 100644 --- a/attack-theme/static/scripts/navigation.js +++ b/attack-theme/static/scripts/navigation.js @@ -71,7 +71,6 @@ $(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/modules/resources/templates/contribute.html b/modules/resources/templates/contribute.html index a269f4dbedc..56dc49bb4f4 100644 --- a/modules/resources/templates/contribute.html +++ b/modules/resources/templates/contribute.html @@ -100,18 +100,18 @@

Contribution Examples

New Technique Example
-
-
(Sub-)Technique Name:
-

COM, ROM, & BE GONE

-
Tactic:
-

Persistence

-
-
-
Platform:
-

Windows

-
Required Permissions:
-

User

-
+

+ (Sub-)Technique Name: COM, ROM, & BE GONE +

+

+ Tactic: Persistence +

+

+ Platform: Windows +

+

+ Required Permissions: User +

Sub-techniques: This is a sub-technique of T1XXX, or this would have T1XXX as a sub-technique

From 5551c69c008d0a36ac9a3d691c568169a61768e2 Mon Sep 17 00:00:00 2001 From: adpare Date: Tue, 3 Oct 2023 00:08:20 -0400 Subject: [PATCH 25/25] code smells --- attack-theme/static/scripts/mobileview-datasources.js | 2 +- attack-theme/static/scripts/sidebar-load-all.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/attack-theme/static/scripts/mobileview-datasources.js b/attack-theme/static/scripts/mobileview-datasources.js index 3896a292eb5..10020cae820 100644 --- a/attack-theme/static/scripts/mobileview-datasources.js +++ b/attack-theme/static/scripts/mobileview-datasources.js @@ -1,5 +1,5 @@ // This code is for creating a collapsable sidebar for the mobile view -var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') +let mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { if (e.matches) { diff --git a/attack-theme/static/scripts/sidebar-load-all.js b/attack-theme/static/scripts/sidebar-load-all.js index d2ce1700f13..0b274726817 100644 --- a/attack-theme/static/scripts/sidebar-load-all.js +++ b/attack-theme/static/scripts/sidebar-load-all.js @@ -4,8 +4,8 @@ if (mod_name.includes('contact')){ mod_entry = "/" + "resources/sidebar-resources" } $("#sidebars").load(mod_entry, function() { - var navElements = document.querySelectorAll('.sidenav-head > a'); - var winlocation; + let navElements = document.querySelectorAll('.sidenav-head > a'); + let winlocation; navElements.forEach(function(element){ if(!window.location.href.endsWith("/")){ winlocation = window.location.href + "/"; @@ -21,7 +21,7 @@ $("#sidebars").load(mod_entry, function() { }}); //This code is for creating a collapsable sidebar for the mobile view - var mediaQuery = window.matchMedia('(max-width: 47.9875rem)') + let mediaQuery = window.matchMedia('(max-width: 47.9875rem)') function mobileSidenav(e) { if (e.matches) { $('#sidebar-collapse').collapse('hide') @@ -32,8 +32,11 @@ $("#sidebars").load(mod_entry, 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' }) + if (sidenav_active_elements.length > 0) setTimeout(() => { //setTimeout gives bootstrap time to execute first + sidenav[0].scrollTop = sidenav_active_elements[0].offsetTop - 60; + }); }); mediaQuery.addEventListener('change', mobileSidenav)