Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonrobbins committed Feb 21, 2024
1 parent 4349c10 commit 2a01c76
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions src/mappings_explorer/site_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,14 @@ def load_projects():
return projects


def replace_mapping_type(mapping, type_list):
def replace_mapping_type(mapping: dict, type_list: list):

Check warning on line 313 in src/mappings_explorer/site_builder.py

View check run for this annotation

Codecov / codecov/patch

src/mappings_explorer/site_builder.py#L313

Added line #L313 was not covered by tests
"""Replace the mapping_type value with the more descriptive name found in mappings
file metadata
Args:
mapping: individual mapping object to replace mapping_type value on
typeList: table of mapping_type values to lookup and replace
"""
for mapping_type in type_list:
if mapping["mapping_type"] == mapping_type:
return type_list[mapping_type]["name"]
Expand All @@ -322,8 +329,21 @@ def replace_mapping_type(mapping, type_list):


def parse_capability_groups(

Check warning on line 331 in src/mappings_explorer/site_builder.py

View check run for this annotation

Codecov / codecov/patch

src/mappings_explorer/site_builder.py#L331

Added line #L331 was not covered by tests
project, attack_version, project_version, attack_domain, reset_descriptions
project: ExternalControl,
attack_version: str,
project_version: str,
attack_domain: str,
):
"""Load mappings data from files, then find and create capability group objects
and capability objects for the objects in the mapping files
Args:
project: the mapping framework to parse mappings for
attack_version: version of ATT&CK to parse mappings for
project_version: version of project to parse mappings for
attack_domain: domain of ATT&CK to parse mappings for
(ex. Enterprise, mobile, or ics)
"""
project_id = project.id
if project_id == "nist":
project_id = "nist_800_53"
Expand Down Expand Up @@ -390,7 +410,12 @@ def parse_capability_groups(
get_security_stack_descriptions(project=project)


def get_security_stack_descriptions(project):
def get_security_stack_descriptions(project: ExternalControl):

Check warning on line 413 in src/mappings_explorer/site_builder.py

View check run for this annotation

Codecov / codecov/patch

src/mappings_explorer/site_builder.py#L413

Added line #L413 was not covered by tests
"""Pull capability descriptions from data files for security stack projects
Args:
project: project to provide descriptions for
"""
root = DATA_DIR / "SecurityStack"
data_dir = os.listdir(root)
for dir in data_dir:
Expand Down Expand Up @@ -781,18 +806,14 @@ def build_external_landing(
)


def build_external_pages(
projects: list, url_prefix: str, breadcrumbs: list, reset_descriptions: bool
):
def build_external_pages(projects: list, url_prefix: str, breadcrumbs: list):
"""Parse ATT&CK data and build all pages for ATT&CK objects
Args:
projects: the list of projects and their mappings to parse into ATT&CK objects
url_prefix: the root url for the built site
breadcrumbs: the navigation tree above the pages being built in this function
used to render the breadcrumbs on each page
reset_descriptions: whether or not to reset the saved descriptions for nist and
cve capabilities to save time on the build
"""
logger.info("Parsing and building external pages...")
for project in projects:
Expand All @@ -816,7 +837,6 @@ def build_external_pages(
attack_version=attack_version,
project_version=project_version,
attack_domain=attack_domain,
reset_descriptions=reset_descriptions,
)
m = [
m
Expand Down Expand Up @@ -1825,7 +1845,6 @@ def main():
projects=projects,
url_prefix=url_prefix,

Check warning on line 1846 in src/mappings_explorer/site_builder.py

View check run for this annotation

Codecov / codecov/patch

src/mappings_explorer/site_builder.py#L1846

Added line #L1846 was not covered by tests
breadcrumbs=breadcrumbs,
reset_descriptions=reset_descriptions,
)
breadcrumbs = [
(f"{url_prefix}", "Home"),
Expand Down

0 comments on commit 2a01c76

Please sign in to comment.