Skip to content

Commit c190315

Browse files
authored
Merge pull request #549 from mitre-attack/better-versioning
Better-versioning
2 parents 1cbb1e0 + 24ebf7a commit c190315

File tree

270 files changed

+745
-1002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+745
-1002
lines changed

.env.template

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
ATTACK_VERSION_ARCHIVES="attack-version-archives"
2+
BANNER_ENABLED=True
3+
BANNER_MESSAGE="This is a custom instance of the MITRE ATT&CK Website. The official website can be found at <a href='https://attack.mitre.org'>attack.mitre.org</a>."
14
STIX_LOCATION_ENTERPRISE="https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json"
25
STIX_LOCATION_MOBILE="https://raw.githubusercontent.com/mitre/cti/master/mobile-attack/mobile-attack.json"
36
STIX_LOCATION_ICS="https://raw.githubusercontent.com/mitre/cti/master/ics-attack/ics-attack.json"
47
STIX_LOCATION_PRE="https://raw.githubusercontent.com/mitre/cti/master/pre-attack/pre-attack.json"
5-
BANNER_ENABLED=True
6-
BANNER_MESSAGE="This is a custom instance of the MITRE ATT&CK Website. The official website can be found at <a href='https://attack.mitre.org'>attack.mitre.org</a>."

.github/workflows/static-code-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
1818

1919
- name: SonarCloud Scan
20-
uses: SonarSource/sonarcloud-github-action@master
20+
uses: SonarSource/sonarqube-scan-action@master
2121
env:
2222
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
2323
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,5 @@ node_modules/
3939

4040
attack-style/dist/
4141
attack-style/docs/
42+
attack-version-archives/
43+
tmp/

archive-website.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import argparse
2+
import json
3+
import multiprocessing
4+
import os
5+
6+
from loguru import logger
7+
8+
from modules.versions.versions import create_version_archive
9+
10+
11+
def main():
12+
"""Process previous versions of ATT&CK website."""
13+
parser = argparse.ArgumentParser(
14+
description="Process previous versions of ATT&CK website and create version archives"
15+
)
16+
parser.add_argument(
17+
"--archive-dir",
18+
"-a",
19+
default="attack-version-archives",
20+
help="Directory where version archives will be created (default: attack-version-archives)",
21+
)
22+
23+
args = parser.parse_args()
24+
archive_dir = args.archive_dir
25+
26+
# Create archive directory if it doesn't exist
27+
os.makedirs(archive_dir, exist_ok=True)
28+
29+
with open("data/versions.json", "r") as f:
30+
version_json = json.load(f)
31+
32+
logger.info(f"Processing previous versions of ATT&CK website to {archive_dir}")
33+
34+
processes = []
35+
for version_data in version_json["previous"]:
36+
archive_path = os.path.join(archive_dir, f"website-{version_data['name']}.tar.gz")
37+
if os.path.exists(archive_path):
38+
logger.info(f"Archive already exists for {version_data['name']}: {archive_path} -- skipping.")
39+
continue
40+
41+
p = multiprocessing.Process(
42+
target=create_version_archive,
43+
args=(version_data, archive_dir),
44+
name=f"Process-{version_data['name']}",
45+
)
46+
processes.append(p)
47+
p.start()
48+
logger.info(f"Started process for {version_data['name']} (PID: {p.pid})")
49+
50+
for p in processes:
51+
p.join()
52+
logger.info(f"Process {p.name} for version finished (PID: {p.pid})")
53+
54+
logger.info("All versions processed")
55+
56+
57+
if __name__ == "__main__":
58+
main()

data/versions.json

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"previous": [
99
{
1010
"name": "v16.1",
11-
"aliases": [],
1211
"date_start": "October 31, 2024",
1312
"date_end": "April 21, 2025",
1413
"changelog": "updates-october-2024",
@@ -17,7 +16,6 @@
1716
},
1817
{
1918
"name": "v15.1",
20-
"aliases": [],
2119
"date_start": "April 23, 2024",
2220
"date_end": "October 30, 2024",
2321
"changelog": "updates-april-2024",
@@ -26,7 +24,6 @@
2624
},
2725
{
2826
"name": "v14.1",
29-
"aliases": [],
3027
"date_start": "October 31, 2023",
3128
"date_end": "April 22, 2024",
3229
"changelog": "updates-october-2023",
@@ -35,7 +32,6 @@
3532
},
3633
{
3734
"name": "v13.1",
38-
"aliases": [],
3935
"date_start": "April 25, 2023",
4036
"date_end": "October 30, 2023",
4137
"changelog": "updates-april-2023",
@@ -44,7 +40,6 @@
4440
},
4541
{
4642
"name": "v12.1",
47-
"aliases": [],
4843
"date_start": "October 25, 2022",
4944
"date_end": "April 24, 2023",
5045
"changelog": "updates-october-2022",
@@ -53,7 +48,6 @@
5348
},
5449
{
5550
"name": "v11.3",
56-
"aliases": [],
5751
"date_start": "April 25, 2022",
5852
"date_end": "October 24, 2022",
5953
"changelog": "updates-april-2022",
@@ -62,7 +56,6 @@
6256
},
6357
{
6458
"name": "v10.1",
65-
"aliases": [],
6659
"date_start": "October 21, 2021",
6760
"date_end": "April 24, 2022",
6861
"changelog": "updates-october-2021",
@@ -71,7 +64,6 @@
7164
},
7265
{
7366
"name": "v9.0",
74-
"aliases": [],
7567
"date_start": "April 29, 2021",
7668
"date_end": "October 20, 2021",
7769
"changelog": "updates-april-2021",
@@ -80,36 +72,22 @@
8072
},
8173
{
8274
"name": "v8.2",
83-
"aliases": [],
8475
"date_start": "October 27, 2020",
8576
"date_end": "April 28, 2021",
8677
"changelog": "updates-october-2020",
8778
"cti_url": "https://github.com/mitre/cti/releases/tag/ATT%26CK-v8.2",
8879
"commit": "6073984f48327644bd97256aa62ecf142b690200"
89-
9080
},
9181
{
9282
"name": "v7.2",
93-
"aliases": [],
9483
"date_start": "July 8, 2020",
9584
"date_end": "October 26, 2020",
9685
"changelog": "updates-july-2020",
9786
"cti_url": "https://github.com/mitre/cti/releases/tag/ATT%26CK-v7.2",
9887
"commit": "11a8bce02433810457b90f61e66c5e4a609cbd66"
9988
},
100-
{
101-
"name": "v7.0-beta",
102-
"path": "v7-beta",
103-
"aliases": [],
104-
"date_start": "March 31, 2020",
105-
"date_end": "July 7, 2020",
106-
"changelog": "updates-march-2020",
107-
"cti_url": "https://github.com/mitre/cti/releases/tag/ATT%26CK-v7.0-beta",
108-
"commit": "d086905c3c2242b9f76c893e4ad79ba39ec9ae26"
109-
},
11089
{
11190
"name": "v6.3",
112-
"aliases": [],
11391
"date_start": "October 24, 2019",
11492
"date_end": "March 30, 2020",
11593
"changelog": "updates-october-2019",
@@ -118,7 +96,6 @@
11896
},
11997
{
12098
"name": "v5.2",
121-
"aliases": ["july2019"],
12299
"date_start": "July 31, 2019",
123100
"date_end": "October 23, 2019",
124101
"changelog": "updates-july-2019",
@@ -127,7 +104,6 @@
127104
},
128105
{
129106
"name": "v4.0",
130-
"aliases": ["april2019"],
131107
"date_start": "April 30, 2019",
132108
"date_end": "July 30, 2019",
133109
"changelog": "updates-april-2019",
@@ -136,7 +112,6 @@
136112
},
137113
{
138114
"name": "v3.0",
139-
"aliases": ["october2018"],
140115
"date_start": "October 23, 2018",
141116
"date_end": "April 29, 2019",
142117
"changelog": "updates-october-2018",

modules/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ def sort_menu_by_priority():
1414
def sort_run_ptr_by_priority():
1515
global run_ptr
1616
run_ptr = sorted(run_ptr, key=lambda k: k["priority"])
17-
print(
18-
f"Building website using the following modules in this order: {[pointer_info['module_name'] for pointer_info in run_ptr]}"
19-
)
2017

2118

2219
def check_redirections(redirections_list):

modules/assets/assets.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import json
33
import os
44

5-
from loguru import logger
6-
75
from modules import util
86

9-
from . import assets_config
107
from .. import site_config
8+
from . import assets_config
119

1210

1311
def generate_assets():
@@ -22,11 +20,6 @@ def generate_assets():
2220
if not os.path.isdir(assets_config.asset_markdown_path):
2321
os.mkdir(assets_config.asset_markdown_path)
2422

25-
# Generate redirections
26-
util.buildhelpers.generate_redirections(
27-
redirections_filename=assets_config.assets_redirection_location, redirect_md=site_config.redirect_md
28-
)
29-
3023
# Generates the markdown files to be used for page generation
3124
assets_generated = generate_markdown_files()
3225

@@ -35,9 +28,7 @@ def generate_assets():
3528

3629

3730
def generate_markdown_files():
38-
"""
39-
Responsible for generating asset index page and getting shared data for all assets.
40-
"""
31+
"""Responsible for generating asset index page and getting shared data for all assets."""
4132
has_asset = False
4233

4334
asset_list = util.relationshipgetters.get_asset_list()
@@ -70,7 +61,6 @@ def generate_markdown_files():
7061

7162
def generate_asset_md(asset, side_menu_data, notes):
7263
"""Responsible for generating markdown of all assets."""
73-
7464
attack_id = util.buildhelpers.get_attack_id(asset)
7565

7666
if not attack_id:

modules/assets/assets_redirections.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

modules/blog/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from loguru import logger
2+
13
from . import blog_config
24

35

@@ -14,3 +16,6 @@ def get_menu():
1416
"priority": blog_config.priority,
1517
"children": [],
1618
}
19+
20+
def run_module():
21+
logger.info("Running Blog module...")

modules/campaigns/campaigns.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66

77
from modules import util
88

9-
from . import campaigns_config
109
from .. import site_config
10+
from . import campaigns_config
1111

1212

1313
def generate_campaigns():
14-
"""
15-
Responsible for verifying campaign directory and starting off campaign markdown generation.
16-
"""
17-
14+
"""Responsible for verifying campaign directory and starting off campaign markdown generation."""
1815
# Create content pages directory if does not already exist
1916
util.buildhelpers.create_content_pages_dir()
2017

@@ -25,12 +22,6 @@ def generate_campaigns():
2522
if not os.path.isdir(campaigns_config.campaign_markdown_path):
2623
os.mkdir(campaigns_config.campaign_markdown_path)
2724

28-
# TODO resolve infinite redirect loop when run locally. Needs further testing before code removal.
29-
# Generate redirections
30-
util.buildhelpers.generate_redirections(
31-
redirections_filename=campaigns_config.campaigns_redirection_location, redirect_md=site_config.redirect_md
32-
)
33-
3425
# Generates the markdown files to be used for page generation
3526
campaigns_generated = generate_markdown_files()
3627

@@ -39,10 +30,7 @@ def generate_campaigns():
3930

4031

4132
def generate_markdown_files():
42-
"""
43-
Responsible for generating campaign index page and getting shared data for all campaigns.
44-
"""
45-
33+
"""Responsible for generating campaign index page and getting shared data for all campaigns."""
4634
has_campaign = False
4735

4836
campaign_list = util.relationshipgetters.get_campaign_list()
@@ -79,7 +67,6 @@ def generate_markdown_files():
7967

8068
def generate_campaign_md(campaign, side_menu_data, notes):
8169
"""Responsible for generating markdown of all campaigns."""
82-
8370
attack_id = util.buildhelpers.get_attack_id(campaign)
8471

8572
if attack_id:

0 commit comments

Comments
 (0)