Skip to content

Commit

Permalink
fix for 'get_objects_by_content()', it broke due to 'self.src' not be…
Browse files Browse the repository at this point in the history
…ing an iterable (it was a 'stix2.MemoryStore') (#164)
  • Loading branch information
M0rpheus-0 authored Feb 20, 2024
1 parent 251f78a commit 6be4d41
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mitreattack/stix20/MitreAttackData.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,16 @@ def get_objects_by_content(self, content: str, object_type: str = None, remove_r
# filter for objects of given type
objects = self.src.query([Filter("type", "=", object_type)])

objects = list(filter(lambda t: content.lower() in t.description.lower(), objects))
# replaced: 'filter(lambda t: content.lower() in t.description.lower(), objects)'
# it broke because 'objects' is not an iterable.
matched_objects = []
for obj in self.src.sink._data.values():
if (
hasattr(obj, 'all_versions') and
content.lower() in tuple(obj.all_versions.values())[0].get('description', '').lower()
):
matched_objects.append(obj)

if remove_revoked_deprecated:
objects = self.remove_revoked_deprecated(objects)
return objects
Expand Down

0 comments on commit 6be4d41

Please sign in to comment.