mirror of
https://github.com/DISARMFoundation/DISARMframeworks.git
synced 2025-08-13 00:35:37 -04:00
add subtechniques to stix2 generator
This commit is contained in:
parent
0549123900
commit
8937d50328
5 changed files with 85 additions and 24 deletions
|
@ -19,3 +19,27 @@ def make_disarm_subtechnique_relationship(source, target):
|
|||
)
|
||||
|
||||
return relationship
|
||||
|
||||
|
||||
def make_disarm_subtechnique_relationships(techniques, subtechniques):
|
||||
"""Creates a map of technique and sub-technique.
|
||||
|
||||
Args:
|
||||
techniques (list): List of STIX2 technique objects.
|
||||
subtechniques (list): List of STIX2 subtechnique objects.
|
||||
|
||||
Returns:
|
||||
A Relationship object.
|
||||
|
||||
"""
|
||||
technique_ids = {}
|
||||
for technique in techniques:
|
||||
technique_ids[technique["external_references"][0]["external_id"]] = technique["id"]
|
||||
|
||||
relationships = []
|
||||
for subtechnique in subtechniques:
|
||||
technique_id = technique_ids[subtechnique["external_references"][0]["external_id"].split(".")[0]]
|
||||
relationship = make_disarm_subtechnique_relationship(subtechnique["id"], technique_id)
|
||||
relationships.append(relationship)
|
||||
|
||||
return relationships
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue