Skip to content

Commit f0a0633

Browse files
authored
Merge pull request #30 from OTRF/hotfix/improve-multiple-filters
added better support to handle stix filter results
2 parents 69226ea + 5503035 commit f0a0633

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

attackcti/attack_api.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def handle_list(list_object, object_type):
234234
elif obj['type'] == "marking-definition":
235235
stix_mapping = marking_stix_mapping
236236
else:
237-
exit
237+
return stix_objects_list
238238

239239
if key in stix_mapping.keys():
240240
if key == "external_references" or key == "kill_chain_phases":
@@ -1215,6 +1215,8 @@ def get_software_used_by_group(self, stix_object, stix_format=True):
12151215
for relation in relationships:
12161216
if get_type_from_id(relation.target_ref) in ['malware', 'tool']:
12171217
software_relationships.append(relation)
1218+
if len(software_relationships) == 0:
1219+
return software_relationships
12181220
filter_objects = [
12191221
Filter('type', 'in', ['malware', 'tool']),
12201222
Filter('id', '=', [r.target_ref for r in software_relationships])
@@ -1256,6 +1258,8 @@ def get_techniques_used_by_software(self, stix_object, stix_format=True):
12561258
for relation in relationships:
12571259
if get_type_from_id(relation.source_ref) in ['malware', 'tool']:
12581260
software_relationships.append(relation)
1261+
if len(software_relationships) == 0:
1262+
return software_relationships
12591263
filter_objects = [
12601264
Filter('type', '=', 'attack-pattern'),
12611265
Filter('id', '=', [r.target_ref for r in software_relationships])
@@ -1299,6 +1303,8 @@ def get_techniques_used_by_group_software(self, stix_object, stix_format=True):
12991303
for relation in relationships:
13001304
if get_type_from_id(relation.target_ref) in ['malware', 'tool']:
13011305
software_relationships.append(relation)
1306+
if len(software_relationships) == 0:
1307+
return software_relationships
13021308
# Get all used by the software that is used by group
13031309
filter_objects = [
13041310
Filter('type', '=', 'relationship'),
@@ -1364,6 +1370,8 @@ def get_techniques_mitigated_by_mitigation(self, stix_object, stix_format=True):
13641370
for relation in relationships:
13651371
if get_type_from_id(relation.source_ref) == 'course-of-action':
13661372
mitigation_relationships.append(relation)
1373+
if len(mitigation_relationships) == 0:
1374+
return mitigation_relationships
13671375
filter_objects = [
13681376
Filter('type', '=', 'attack-pattern'),
13691377
Filter('id', '=', [r.target_ref for r in mitigation_relationships])
@@ -1406,6 +1414,8 @@ def get_techniques_mitigated_by_all_mitigations(self, stix_format=True):
14061414
for relation in relationships:
14071415
if get_type_from_id(relation.source_ref) in ['course-of-action']:
14081416
mitigation_relationships.append(relation)
1417+
if len(mitigation_relationships) == 0:
1418+
return mitigation_relationships
14091419
# Get all techniques
14101420
techniques = self.get_techniques()
14111421
all_techniques_list = list()

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setuptools.setup(
1515
name="attackcti",
16-
version="0.3.4.3",
16+
version="0.3.4.4",
1717
author="Roberto Rodriguez",
1818
description="ATTACK CTI Libary",
1919
long_description=long_description,

0 commit comments

Comments
 (0)