Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added include_pre_attack parameter to attack_client constructor #61

Merged
merged 2 commits into from
Nov 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions attackcti/attack_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class attack_client(object):
TC_ICS_SOURCE = None
COMPOSITE_DS = None

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

self.COMPOSITE_DS = CompositeDataSource()
self.COMPOSITE_DS.add_data_sources([self.TC_ENTERPRISE_SOURCE, self.TC_PRE_SOURCE, self.TC_MOBILE_SOURCE, self.TC_ICS_SOURCE])

self.COMPOSITE_DS.add_data_sources([self.TC_ENTERPRISE_SOURCE, self.TC_MOBILE_SOURCE, self.TC_ICS_SOURCE])

if include_pre_attack:
self.COMPOSITE_DS.add_data_sources([self.TC_PRE_SOURCE])

def translate_stix_objects(self, stix_objects):
technique_stix_mapping = {
"type": "type",
Expand Down Expand Up @@ -543,7 +546,7 @@ def get_pre_techniques(self, skip_revoked_deprecated=True, include_subtechniques
if include_subtechniques:
pre_techniques = self.TC_PRE_SOURCE.query(Filter("type", "=", "attack-pattern"))
else:
pre_techniques = self.TC_ENTERPRISE_SOURCE.query([
pre_techniques = self.TC_PRE_SOURCE.query([
Filter("type", "=", "attack-pattern"),
Filter('x_mitre_is_subtechnique', '=', False)
])
Expand Down