Skip to content

Commit

Permalink
Merge pull request #120 from swimlane/6_2_0
Browse files Browse the repository at this point in the history
6.2.0
  • Loading branch information
MSAdministrator authored Jul 29, 2022
2 parents 9a33b3c + f322250 commit bd44fb4
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 197 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ from pyattck import Attck
attack = Attck()
```

By default, `sub-techniques` are accessible under each technique object. You can turn this behavior off by passing `nested_subtechniques=False` when creating your `Attck` object.
By default, `sub-techniques` are accessible under each technique object. You can turn this behavior off by passing `nested_techniques=False` when creating your `Attck` object.

As an example, the default behavior looks like the following example:

Expand All @@ -98,7 +98,7 @@ attack = Attck()
for technique in attack.enterprise.techniques:
print(technique.id)
print(technique.name)
for subtechnique in technique.subtechniques:
for subtechnique in technique.techniques:
print(subtechnique.id)
print(subtechnique.name)
```
Expand Down Expand Up @@ -161,7 +161,7 @@ For more information on object types under the `ics` property, see [ICS](docs/ic
from pyattck import Attck

attck = Attck(
nested_subtechniques=True,
nested_techniques=True,
use_config=False,
save_config=False,
config_file_path='~/pyattck/config.yml',
Expand Down
6 changes: 3 additions & 3 deletions docs/attck.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ attack = Attck()
for technique in attack.enterprise.techniques:
print(technique.id)
print(technique.name)
for subtechnique in technique.subtechniques:
for subtechnique in technique.techniques:
print(subtechnique.id)
print(subtechnique.name)
```

You can turn this behavior off by passing `nested_subtechniques=False` when creating your `Attck` object. When turning this feature off you can access subtechniques on the same level as all other techniques. Here's an example:
You can turn this behavior off by passing `nested_techniques=False` when creating your `Attck` object. When turning this feature off you can access subtechniques on the same level as all other techniques. Here's an example:

```python
from pyattck import Attck
Expand All @@ -38,7 +38,7 @@ attack = Attck()
for technique in attack.enterprise.techniques:
print(technique.id)
print(technique.name)
print(f"checking if technique is subtechnique: {technique.subtechnique}")
print(f"checking if technique is subtechnique: {technique.techniques}")
```

## Attck Class
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyattck import Attck

attck = Attck(
nested_subtechniques=True,
nested_techniques=True,
use_config=False,
save_config=False,
config_file_path='~/pyattck/config.yml',
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ from pyattck import Attck
attack = Attck()
```

By default, `sub-techniques` are accessible under each technique object. You can turn this behavior off by passing `nested_subtechniques=False` when creating your `Attck` object.
By default, `sub-techniques` are accessible under each technique object. You can turn this behavior off by passing `nested_techniques=False` when creating your `Attck` object.

As an example, the default behavior looks like the following example:

Expand Down Expand Up @@ -161,7 +161,7 @@ For more information on object types under the `ics` property, see [ICS](ics.md)
from pyattck import Attck

attck = Attck(
nested_subtechniques=True,
nested_techniques=True,
use_config=False,
save_config=False,
config_file_path='~/pyattck/config.yml',
Expand Down
2 changes: 1 addition & 1 deletion docs/technique.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Additionally, a `Technique` object allows the user to access additional relation
* Actor or Group(s) identified as using this technique
* Tools used with a given technique
* Malware used with a given technique
* Subtechniques of a technique if `nested_subtechniques` is set to `True`
* Subtechniques of a technique if `nested_techniques` is set to `True`
* NIST 800-53 Controls related to a technique
* Data Components of a technique
* Data Sources of a technique
Expand Down
206 changes: 35 additions & 171 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions pyattck/attck.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Attck(Base):
# etc.
Arguments:
nested_subtechniques (bool, optional): Whether not to iterate over nested subtechniques. Defaults to True.
nested_techniques (bool, optional): Whether not to iterate over nested subtechniques. Defaults to True.
use_config (bool, optional): Specifies if a configuration file should be used or not. Defaults to False.
save_config (bool, optional): Specifies if pyattck should save a configuration file based on the provided
values. Defaults to False.
Expand Down Expand Up @@ -141,7 +141,7 @@ class Attck(Base):

def __init__(
self,
nested_subtechniques=True,
nested_techniques=True,
use_config=False,
save_config=False,
config_file_path="~/pyattck/config.yml",
Expand All @@ -161,10 +161,10 @@ def __init__(
new subtechniques to be nested underneath their parent techniques
or not.
Setting nested_subtechniques to False will result in all techniques
Setting nested_techniques to False will result in all techniques
accessible under the techniques property. If using the default value
of True, subtechniques will be accessible underneath
technique.subtechniques.
technique.techniques.
When instantiating an Attck object you can access either the
Enterprise, PRE-ATT&CK, or Mobile MITRE Frameworks. Specify
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(
The default is your user home path.
Args:
nested_subtechniques (bool, optional): Whether not to iterate over nested subtechniques. Defaults to True.
nested_techniques (bool, optional): Whether not to iterate over nested subtechniques. Defaults to True.
use_config (bool, optional): Specifies if a configuration file should be used or not. Defaults to False.
save_config (bool, optional): Specifies if pyattck should save a configuration file based on the
provided values. Defaults to False.
Expand All @@ -220,7 +220,7 @@ def __init__(
Defaults to None.
"""
Base.config = Options(
nested_subtechniques=nested_subtechniques,
nested_techniques=nested_techniques,
use_config=use_config,
save_config=save_config,
config_file_path=config_file_path,
Expand Down
2 changes: 1 addition & 1 deletion pyattck/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _validate_json_value(self, attribute, value):

@define(frozen=True)
class Options:
nested_subtechniques: bool = field(default=False)
nested_techniques: bool = field(default=False)
use_config: bool = field(default=False)
save_config: bool = field(default=False)
config_file_path: FilePath = field(default="~/pyattck/config.yml", converter=get_absolute_path)
Expand Down
2 changes: 1 addition & 1 deletion pyattck/enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def techniques(self):
if not self.__techniques:
for item in self.__attck.objects:
if item.type == "attack-pattern":
if item.techniques and not Base.config.nested_subtechniques:
if item.techniques and not Base.config.nested_techniques:
for i in item.techniques:
self.__techniques.append(i)
self.__techniques.append(item)
Expand Down
2 changes: 1 addition & 1 deletion pyattck/ics.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def techniques(self):
if not self.__techniques:
for item in self.__attck.objects:
if item.type == "attack-pattern":
if item.techniques and not Base.config.nested_subtechniques:
if item.techniques and not Base.config.nested_techniques:
for i in item.techniques:
self.__techniques.append(i)
self.__techniques.append(item)
Expand Down
2 changes: 1 addition & 1 deletion pyattck/mobile.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def techniques(self):
if not self.__techniques:
for item in self.__attck.objects:
if item.type == "attack-pattern":
if item.techniques and not Base.config.nested_subtechniques:
if item.techniques and not Base.config.nested_techniques:
for i in item.techniques:
self.__techniques.append(i)
self.__techniques.append(item)
Expand Down
2 changes: 1 addition & 1 deletion pyattck/preattck.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def techniques(self):
if not self.__techniques:
for item in self.__attck.objects:
if item.type == "attack-pattern":
if item.techniques and not Base.config.nested_subtechniques:
if item.techniques and not Base.config.nested_techniques:
for i in item.techniques:
self.__techniques.append(i)
self.__techniques.append(item)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyattck"
version = "6.1.2"
version = "6.2.0"
description = "A Python package to interact with the Mitre ATT&CK Frameworks"
authors = ["Swimlane <[email protected]>"]
license = "MIT"
Expand All @@ -13,7 +13,7 @@ python = "^3.7"
requests = "^2.27.1"
fire = "^0.4.0"
attrs = "^21.4.0"
pyattck-data = "^2.4.2"
pyattck-data = "^2.5.0"

[tool.poetry.dev-dependencies]
pytest = "^7.1.2"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ requests
PyYaml>=5.4.1
fire==0.3.1
attrs==21.4.0
pyattck-data>=2.4.2
pyattck-data>=2.5.0
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def attck_fixture():


@pytest.fixture
def attck_fixture_nested_subtechniques_false():
def attck_fixture_nested_techniques_false():
from pyattck import Attck

yield Attck(nested_subtechniques=False)
yield Attck(nested_techniques=False)


@pytest.fixture
Expand Down

0 comments on commit bd44fb4

Please sign in to comment.