Skip to content

Commit

Permalink
Merge pull request #95 from swimlane/5_3_0_release
Browse files Browse the repository at this point in the history
5.3.0 Release
  • Loading branch information
MSAdministrator authored Feb 14, 2022
2 parents c00c080 + 406a4ab commit 13e1687
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
7 changes: 4 additions & 3 deletions pyattck/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
import yaml
from requests.api import request
from .utils.exceptions import UknownFileError
from .utils.exceptions import UnknownFileError


class ConfigurationProperties(type):
Expand Down Expand Up @@ -58,7 +58,7 @@ def __write_to_disk(cls, path, data):
elif path.endswith('.yml') or path.endswith('.yaml'):
yaml.dump(data, f)
else:
raise UknownFileError(provided_value=path, known_values=['.json', '.yml', '.yaml'])
raise UnknownFileError(provided_value=path, known_values=['.json', '.yml', '.yaml'])

def __read_from_disk(cls, path):
if os.path.exists(path) and os.path.isfile(path):
Expand All @@ -69,8 +69,9 @@ def __read_from_disk(cls, path):
elif path.endswith('.yml') or path.endswith('.yaml'):
return yaml.load(f, Loader=yaml.FullLoader)
else:
raise UknownFileError(provided_value=path, known_values=['.json', '.yml', '.yaml'])
raise UnknownFileError(provided_value=path, known_values=['.json', '.yml', '.yaml'])
except:
warnings.warn(message=f"The provided config file {path} is not in the correct format. Using default values instead.")
pass
return None

Expand Down
22 changes: 22 additions & 0 deletions pyattck/enterprise/technique.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,25 @@ def actors(self):
if item in item_dict:
return_list.append(AttckActor(attck_obj=self.__attck_obj, **item_dict[item]))
return return_list

@property
def tools(self):
"""
Returns all tool objects that are used in a technique
Returns:
[list] -- A list of tool objects defined within the
Enterprise MITRE ATT&CK Framework
"""
from .tools import AttckTools
return_list = []
item_dict = {}
for item in self.__attck_obj['objects']:
if 'type' in item:
if item['type'] == 'tool':
item_dict[item['id']] = item
if self._RELATIONSHIPS.get(self.stix):
for item in self._RELATIONSHIPS.get(self.stix):
if item in item_dict:
return_list.append(AttckTools(attck_obj=self.__attck_obj, **item_dict[item]))
return return_list
22 changes: 22 additions & 0 deletions pyattck/mobile/technique.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,25 @@ def actors(self):
except:
pass
return return_list

@property
def tools(self):
"""
Returns all tool objects that are used in a technique
Returns:
[list] -- A list of tool objects defined within the
Mobile MITRE ATT&CK Framework
"""
from .tools import MobileAttckTools
return_list = []
item_dict = {}
for item in self.__attck_obj['objects']:
if 'type' in item:
if item['type'] == 'tool':
item_dict[item['id']] = item
if self._RELATIONSHIPS.get(self.stix):
for item in self._RELATIONSHIPS.get(self.stix):
if item in item_dict:
return_list.append(MobileAttckTools(attck_obj=self.__attck_obj, **item_dict[item]))
return return_list
2 changes: 1 addition & 1 deletion pyattck/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ConfigurationException(Exception):
"""
pass

class UknownFileError(ValueError):
class UnknownFileError(ValueError):
"""Raised when the provided file extension is unkown or is not json, yml or yaml
"""
def __init__(self, provided_value=None, known_values=None):
Expand Down
2 changes: 1 addition & 1 deletion pyattck/utils/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = (5, 2, 2)
__version_info__ = (5, 3, 0)
__version__ = ".".join(map(str, __version_info__))

0 comments on commit 13e1687

Please sign in to comment.