Skip to content

Commit da8c545

Browse files
authored
Merge pull request #61 from rubinatorz/master
added include_pre_attack parameter to attack_client constructor
2 parents f96f9d6 + 45cd339 commit da8c545

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

attackcti/attack_api.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class attack_client(object):
4040
TC_ICS_SOURCE = None
4141
COMPOSITE_DS = None
4242

43-
def __init__(self, local_path=None):
43+
def __init__(self, local_path=None, include_pre_attack=False):
4444
if local_path is not None and os.path.isdir(os.path.join(local_path, ENTERPRISE_ATTACK_LOCAL_DIR)) \
4545
and os.path.isdir(os.path.join(local_path, PRE_ATTACK_LOCAL_DIR)) \
4646
and os.path.isdir(os.path.join(local_path, MOBILE_ATTACK_LOCAL_DIR)) \
@@ -61,8 +61,11 @@ def __init__(self, local_path=None):
6161
self.TC_ICS_SOURCE = TAXIICollectionSource(ICS_COLLECTION)
6262

6363
self.COMPOSITE_DS = CompositeDataSource()
64-
self.COMPOSITE_DS.add_data_sources([self.TC_ENTERPRISE_SOURCE, self.TC_PRE_SOURCE, self.TC_MOBILE_SOURCE, self.TC_ICS_SOURCE])
65-
64+
self.COMPOSITE_DS.add_data_sources([self.TC_ENTERPRISE_SOURCE, self.TC_MOBILE_SOURCE, self.TC_ICS_SOURCE])
65+
66+
if include_pre_attack:
67+
self.COMPOSITE_DS.add_data_sources([self.TC_PRE_SOURCE])
68+
6669
def translate_stix_objects(self, stix_objects):
6770
technique_stix_mapping = {
6871
"type": "type",
@@ -543,7 +546,7 @@ def get_pre_techniques(self, skip_revoked_deprecated=True, include_subtechniques
543546
if include_subtechniques:
544547
pre_techniques = self.TC_PRE_SOURCE.query(Filter("type", "=", "attack-pattern"))
545548
else:
546-
pre_techniques = self.TC_ENTERPRISE_SOURCE.query([
549+
pre_techniques = self.TC_PRE_SOURCE.query([
547550
Filter("type", "=", "attack-pattern"),
548551
Filter('x_mitre_is_subtechnique', '=', False)
549552
])

0 commit comments

Comments
 (0)