[BUG] - TypeError raised on technique.tools
BUG:
A TypeError is raised when you iterate over a certain technique's tools: mid: (attack-pattern--45d84c8b-c1e2-474d-a14d-69b5de0a2bc0
)
What happened?
Version 0.1.8
>>> from enterpriseattack import Attack
>>>
>>>
>>>
>>> attack = Attack(
... mitre_version='latest',
... subscriptable=False,
... update=True,
... )
>>>
>>> try:
... for technique in attack.techniques:
... print(technique.tools)
... except TypeError:
... print(technique.mid)
...
... # (the tools are iterated up to a certain point)
attack-pattern--45d84c8b-c1e2-474d-a14d-69b5de0a2bc0
The error:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/opt/homebrew/lib/python3.11/site-packages/enterpriseattack/technique.py", line 247, in tools
for r_ in self.relationships.get(self.mid):
TypeError: 'NoneType' object is not iterable
>>> for technique in attack.techniques:
... if technique.tools:
...
Source points to:
for r_ in self.relationships.get(self.mid):
if self.id_lookup[r_].get('type') == 'tool':
tools_.append(
Software(
self.attack_objects,
self.relationships,
self.id_lookup,
**self.id_lookup[r_]
)
)
return tools_
The solution would be to alter the .get to:
for r_ in self.relationships.get(self.mid, {}):
Version
0.1.8