INNER CODE UNIT · Python
getSectionList
mitre-attack/attack-scripts · scripts/diff_stix.py:361
def getSectionList(items, obj_type, section):
"""
parse a list of items in a section and return a string for the items
"""
# get parents which have children
childless = list(filter(lambda item: not self.has_subtechniques(item, True) and not ("x_mitre_is_subtechnique" in item and item["x_mitre_is_subtechnique"]), items))
parents = list(filter(lambda item: self.has_subtechniques(item, True) and not ("x_mitre_is_subtechnique" in item and item["x_mitre_is_subtechnique"]), items))
children = { item["id"]: item for item in filter(lambda item: "x_mitre_is_subtechnique" in item and item["x_mitre_is_subtechnique"], items) }
subtechnique_of_rels = self.new_subtechnique_of_rels if section != "deletions" else self.old_subtechnique_of_rels
id_to_technique = self.new_id_to_technique if section != "deletions" else self.old_id_to_technique
parentToChildren = {} # stixID => [ children ]
for relationship in subtechnique_of_rels:
if relationship["target_ref"] in parentToChildren:
if relationship["source_ref"] in children:
parentToChildren[relationship["target_ref"]].append(children[relationship["source_ref"]])