Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/tools/create_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@
from tools.logging_config import setup_logging # noqa: F401


@click.command("create-files")
@click.option(
"--templates",
"-t",
"templates",
required=False,
default="templates/",
type=click.Path(exists=False, dir_okay=True, file_okay=False),
help="Template directory",
)
def create_files_cmd(templates: str):
def create_files(templates: str | Path):
"""
Render files from templates using secrender.

Expand Down Expand Up @@ -72,6 +62,20 @@ def create_files_cmd(templates: str):
find_toc_tag(file=str(new_file))


@click.command("create-files")
@click.option(
"--templates",
"-t",
"templates",
required=False,
default="templates/",
type=click.Path(exists=False, dir_okay=True, file_okay=False),
help="Template directory",
)
def create_files_cmd(templates: str):
create_files(templates)


def rewrite(template_file: Path, template_dir: Path, output_dir: Path) -> str:
sub_path = [
p[0]
Expand Down
8 changes: 4 additions & 4 deletions src/tools/helpers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ def get_standards(self) -> tuple:

def sort_component_controls(self, component_name: str) -> dict:
controls: dict = {}
for component_dir in self.project.components:
if not isinstance(component_dir, str):
for comp_dir in self.project.components:
if not isinstance(comp_dir, str):
continue
component_path = (
Path(component_dir).joinpath(component_name).with_suffix(".yaml")
)
self.project_path / "rendered" / comp_dir / component_name
).with_suffix(".yaml")

if component_path.exists():
component_data = load_yaml_files(component_path)
Expand Down
8 changes: 6 additions & 2 deletions src/tools/make_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def create_family(
return families_data


@click.command("make-families")
def make_families_cmd():
def make_families():
"""Create control family files from project data."""
project = Project()
project_path = get_project_path()
Expand All @@ -162,3 +161,8 @@ def make_families_cmd():
create_family(controls_dir=controls_dir, project=project)
logger.info(f"Families created at {controls_dir.as_posix()}")
print("Process complete.")


@click.command("make-families")
def make_families_cmd():
make_families()
17 changes: 12 additions & 5 deletions src/tools/make_ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from tools.helpers.ssp import Ssp
from tools.helpers.ssptoolkit import find_toc_tag
from tools.logging_config import setup_logging # noqa: F401
from tools.make_families import create_family
from tools.create_files import create_files
from tools.make_families import make_families, create_family


def get_family_data(family_data: dict, write_to: Path, project: OpenControl) -> Ssp:
Expand Down Expand Up @@ -89,17 +90,23 @@ def write_ssp(ssp_data: Ssp, write_to: Path, project: OpenControl):
print(f"Wrote SSP to {ssp_file}")


@click.command("make-ssp")
def make_ssp_cmd():
"""Generate a System Security Plan (SSP) from the control families."""
def make_ssp():
project_path = get_project_path()
project = Project()
write_to = project_path / "rendered" / "docs"
controls_dir = project_path / "rendered" / "controls"
controls_dir = write_to / "controls"
create_files(templates="templates")
make_families()
families = create_family(
controls_dir=controls_dir, project=project, return_data=True
)
ssp_data = get_family_data(
family_data=families, write_to=write_to, project=project.project
)
write_ssp(ssp_data=ssp_data, write_to=write_to, project=project.project)


@click.command("make-ssp")
def make_ssp_cmd():
"""Generate a System Security Plan (SSP) from the control families."""
make_ssp()
Loading