INNER CODE UNIT · Python
placard
mitre-attack/attack-scripts · scripts/diff_stix.py:405
def placard(item):
"""get a section list item for the given SDO according to section type"""
if section == "revocations":
revoker = item['revoked_by']
if "x_mitre_is_subtechnique" in revoker and revoker["x_mitre_is_subtechnique"]:
# get revoking technique's parent for display
parentID = list(filter(lambda rel: rel["source_ref"] == revoker["id"], subtechnique_of_rels))[0]["target_ref"]
parentName = id_to_technique[parentID]["name"] if parentID in id_to_technique else "ERROR NO PARENT"
return f"{item['name']} (revoked by { parentName}: [{revoker['name']}]({self.site_prefix}/{self.getUrlFromStix(revoker, True)}))"
else:
return f"{item['name']} (revoked by [{revoker['name']}]({self.site_prefix}/{self.getUrlFromStix(revoker)}))"
if section == "deletions":
return f"{item['name']}"
else:
is_subtechnique = item["type"] == "attack-pattern" and "x_mitre_is_subtechnique" in item and item["x_mitre_is_subtechnique"]
return f"[{item['name']}]({self.site_prefix}/{self.getUrlFromStix(item, is_subtechnique)})"