Skip to content

Commit 7f0276c

Browse files
authored
Merge pull request #177 from hcristea/master
Fix examples of software_used_by_groups and techniques_using_software: Combine malware with tools instead of overwriting.
2 parents 187ef46 + 6e4e586 commit 7f0276c

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
hashes.json
22
*.pyc
33
.DS_Store
4+
.idea

USAGE.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,13 @@ def get_related(thesrc, src_type, rel_type, target_type, reverse=False):
764764
# software:group
765765
def software_used_by_groups(thesrc):
766766
"""returns group_id => {software, relationship} for each software used by the group."""
767-
x = get_related(thesrc, "intrusion-set", "uses", "tool")
768-
x.update(get_related(thesrc, "intrusion-set", "uses", "malware"))
767+
x = get_related(thesrc, "intrusion-set", "uses", "malware")
768+
x_tool = get_related(thesrc, "intrusion-set", "uses", "tool")
769+
for key in x_tool:
770+
if key in x:
771+
x[key].extend(x_tool[key])
772+
else:
773+
x[key] = x_tool[key]
769774
return x
770775

771776
def groups_using_software(thesrc):
@@ -793,7 +798,12 @@ def techniques_used_by_software(thesrc):
793798
def software_using_technique(thesrc):
794799
"""return technique_id => {software, relationship} for each software using the technique."""
795800
x = get_related(thesrc, "malware", "uses", "attack-pattern", reverse=True)
796-
x.update(get_related(thesrc, "tool", "uses", "attack-pattern", reverse=True))
801+
x_tool = get_related(thesrc, "tool", "uses", "attack-pattern", reverse=True)
802+
for key in x_tool:
803+
if key in x:
804+
x[key].extend(x_tool[key])
805+
else:
806+
x[key] = x_tool[key]
797807
return x
798808

799809
# technique:mitigation

0 commit comments

Comments
 (0)