Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 4a108f5

Browse files
committed
Merge branch 'develop' of https://github.com/mitre-attack/attack-scripts into develop
2 parents 00e8fce + d53d80d commit 4a108f5

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ Added scripts used to generate the [sample layers in the ATT&CK Navigator reposi
55
- [bear_APT.py](scripts/layers/samples/bear_APT.py)
66
- [apt3_apt29_software.py](scripts/layers/samples/apt3_apt29_software.py)
77
- [software_execution.py](scripts/layers/samples/software_execution.py)
8+
## Fixes
9+
- Fixed a bug in diff_stix where sub-techniques had the wrong URL in hyperlinks.
810

911
# v1.4.1 - 18 May 2020
12+
13+
# V1.4.1 - 18 May 2020
1014
## New Scripts
1115
- New script [technique_mappings_to_csv.py](technique_mappings_to_csv.py) added to support mapping Techniques with Mitigations, Groups or Software. The output is a CSV file. Added in PR [#23](https://github.com/mitre-attack/attack-scripts/pull/23)
1216
## Improvements

scripts/diff_stix.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,14 @@ def verboseprint(self, *args, **kwargs):
139139
print(*args, **kwargs)
140140

141141

142-
def getUrlFromStix(self, datum):
142+
def getUrlFromStix(self, datum, is_subtechnique=False):
143143
"""
144144
Parse the website url from a stix object.
145145
"""
146146
url = datum['external_references'][0]['url']
147147
split_url = url.split('/')
148-
link = '/'.join(split_url[-2:])
148+
splitfrom = -3 if is_subtechnique else -2
149+
link = '/'.join(split_url[splitfrom:])
149150
return link
150151

151152

@@ -400,13 +401,14 @@ def placard(item):
400401
# get revoking technique's parent for display
401402
parentID = list(filter(lambda rel: rel["source_ref"] == revoker["id"], subtechnique_of_rels))[0]["target_ref"]
402403
parentName = id_to_technique[parentID]["name"] if parentID in id_to_technique else "ERROR NO PARENT"
403-
return f"{item['name']} (revoked by { parentName}: [{revoker['name']}]({self.site_prefix}/{self.getUrlFromStix(revoker)}))"
404+
return f"{item['name']} (revoked by { parentName}: [{revoker['name']}]({self.site_prefix}/{self.getUrlFromStix(revoker, True)}))"
404405
else:
405406
return f"{item['name']} (revoked by [{revoker['name']}]({self.site_prefix}/{self.getUrlFromStix(revoker)}))"
406407
if section == "deletions":
407408
return f"{item['name']}"
408409
else:
409-
return f"[{item['name']}]({self.site_prefix}/{self.getUrlFromStix(item)})"
410+
is_subtechnique = item["type"] == "attack-pattern" and "x_mitre_is_subtechnique" in item and item["x_mitre_is_subtechnique"]
411+
return f"[{item['name']}]({self.site_prefix}/{self.getUrlFromStix(item, is_subtechnique)})"
410412

411413

412414
# build sectionList string
@@ -688,4 +690,4 @@ def verboseprint(*args, **kwargs):
688690
parser.error('-layers requires exactly three files to be specified or none at all')
689691

690692
layers_dict = diffStix.get_layers_dict()
691-
layers_dict_to_files(args.layers, layers_dict)
693+
layers_dict_to_files(args.layers, layers_dict)

0 commit comments

Comments
 (0)