Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
arkid15r committed Sep 14, 2023
1 parent 6ada5ff commit e4db4d8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
28 changes: 14 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

sys.path.insert(0, os.path.abspath(".."))

# -- Project information -----------------------------------------------------
project = 'mitreattack-python'
copyright = '2022, The MITRE Corporation'
version = '2.0.0'
release = '2.0.0'
project = "mitreattack-python"
copyright = "2022, The MITRE Corporation"
version = "2.0.0"
release = "2.0.0"

# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.autosectionlabel',
'sphinx.ext.napoleon'
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
"sphinx.ext.napoleon",
]
autosummary_generate = True
autodoc_default_options = {"members": True}
add_module_names = True
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Options for HTML output -------------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
22 changes: 16 additions & 6 deletions examples/get_procedure_examples_by_tactic.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,22 @@ def main():
for technique in techniques:
technique_stix_id = technique["id"]
groups_using_technique = mitre_attack_data.get_groups_using_technique(technique_stix_id=technique_stix_id)
software_using_technique = mitre_attack_data.get_software_using_technique(technique_stix_id=technique_stix_id)
campaigns_using_technique = mitre_attack_data.get_campaigns_using_technique(technique_stix_id=technique_stix_id)

print_procedure_examples(mitre_attack_data=mitre_attack_data, attack_objects_using_technique=groups_using_technique)
print_procedure_examples(mitre_attack_data=mitre_attack_data, attack_objects_using_technique=software_using_technique)
print_procedure_examples(mitre_attack_data=mitre_attack_data, attack_objects_using_technique=campaigns_using_technique)
software_using_technique = mitre_attack_data.get_software_using_technique(
technique_stix_id=technique_stix_id
)
campaigns_using_technique = mitre_attack_data.get_campaigns_using_technique(
technique_stix_id=technique_stix_id
)

print_procedure_examples(
mitre_attack_data=mitre_attack_data, attack_objects_using_technique=groups_using_technique
)
print_procedure_examples(
mitre_attack_data=mitre_attack_data, attack_objects_using_technique=software_using_technique
)
print_procedure_examples(
mitre_attack_data=mitre_attack_data, attack_objects_using_technique=campaigns_using_technique
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion examples/get_revoked_techniques.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def main():
revoking_object = mitre_attack_data.get_revoking_object(revoked_stix_id=stix_id)
revoking_object_name = revoking_object.get("name")
revoking_object_attack_id = mitre_attack_data.get_attack_id(stix_id=revoking_object["id"])
print(f"[{revoked_technique_attack_id}] {revoked_technique_name} was revoked by [{revoking_object_attack_id}] {revoking_object_name}")
print(
f"[{revoked_technique_attack_id}] {revoked_technique_name} was revoked by [{revoking_object_attack_id}] {revoking_object_name}"
)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion mitreattack/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .attackToExcel import *
from .navlayers import *
from .collections import *
from .collections import *
2 changes: 1 addition & 1 deletion mitreattack/stix20/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .MitreAttackData import MitreAttackData
from .custom_attack_objects import StixObjectFactory, Matrix, Tactic, DataSource, DataComponent
from .custom_attack_objects import StixObjectFactory, Matrix, Tactic, DataSource, DataComponent
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def attack_stix_dir():
domains=["enterprise", "mobile", "ics"],
download_dir=download_dir,
all_versions=False,
stix_version="2.0"
stix_version="2.0",
)

yield download_dir
Expand Down
6 changes: 3 additions & 3 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def test_aggregate(tmp_path: Path, memstore_enterprise_latest: MemoryStore):
xlsx_output = tmp_path / f"layer-{test_layer.layer.name}.xlsx"
svg_output = tmp_path / f"layer-{test_layer.layer.name}.svg"

xlsx_exporter = ToExcel(domain=test_layer.layer.domain, source="memorystore", resource=memstore_enterprise_latest)
xlsx_exporter = ToExcel(
domain=test_layer.layer.domain, source="memorystore", resource=memstore_enterprise_latest
)
svg_exporter = ToSvg(domain=test_layer.layer.domain, source="memorystore", resource=memstore_enterprise_latest)

xlsx_exporter.to_xlsx(layerInit=test_layer, filepath=str(xlsx_output))
Expand Down Expand Up @@ -114,8 +116,6 @@ def test_upgrades():
assert all(["4.4" == x["versions"]["layer"] for x in [out1, out2, out3]])




def test_layer_ops():
"""Test layer lambda computation functionality"""

Expand Down
3 changes: 1 addition & 2 deletions tests/test_stix20.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ def test_stix_object_factory(self):
data = {"something": "else"}
assert StixObjectFactory(data) == data


def test_tactic(self):
name = "Tactic"
shortname = "Tactic shortname"
version = "Tactic version"
tactic = Tactic(**{"name":name, "x_mitre_shortname": shortname, "x_mitre_version": version})
tactic = Tactic(**{"name": name, "x_mitre_shortname": shortname, "x_mitre_version": version})

assert tactic.name == name
assert tactic.type == "x-mitre-tactic"
Expand Down

0 comments on commit e4db4d8

Please sign in to comment.