Skip to content

Commit

Permalink
Merge branch 'main' into bug/multiple-control-to-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
jpower432 authored Mar 4, 2024
2 parents 8dc411f + 398c196 commit a2269d2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
tags: ${{ steps.set_image_repo.outputs.image_repo }}:${{ env.TAG }}

- name: Pre-push Image Scan
uses: aquasecurity/trivy-action@0.17.0
uses: aquasecurity/trivy-action@0.18.0
with:
image-ref: ${{ steps.set_image_repo.outputs.image_repo }}:${{ env.TAG }}
exit-code: 1
Expand Down
76 changes: 38 additions & 38 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ compliance-trestle = "^2.6.0"
github3-py = "^4.0.1"
python-gitlab = "^4.2.0"
ruamel-yaml = "^0.18.5"
pydantic = "1.10.13"
pydantic = "1.10.14"

[tool.poetry.group.dev.dependencies]
flake8 = "^6.0.0"
Expand Down
15 changes: 14 additions & 1 deletion tests/trestlebot/tasks/authored/test_ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,27 @@ def test_create_new_with_filter(tmp_trestle_dir: str) -> None:
)
assert model_path.exists()

assert len(ssp.system_implementation.components) == 1
assert len(ssp.system_implementation.components) == 2

component_names = [
component.title for component in ssp.system_implementation.components
]
assert test_comp_2 in component_names
assert const.SSP_MAIN_COMP_NAME in component_names
assert test_comp not in component_names

# Main comp only
authored_ssp.create_new_with_filter(ssp_name, input_ssp, main_comp_only=True)
ssp, model_path = load_validate_model_name(
trestle_root, ssp_name, ossp.SystemSecurityPlan, FileContentType.JSON
)
assert model_path.exists()

assert len(ssp.system_implementation.components) == 1
assert const.SSP_MAIN_COMP_NAME in [
component.title for component in ssp.system_implementation.components
]

# Check that the ssp_index is not updated
ssp_name = "new_ssp_2"
authored_ssp.create_new_with_filter(
Expand Down
10 changes: 8 additions & 2 deletions trestlebot/tasks/authored/ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pathlib
from typing import Any, Dict, List, Optional

from trestle.common.const import SSP_MAIN_COMP_NAME
from trestle.common.err import TrestleError
from trestle.common.model_utils import ModelUtils
from trestle.core.commands.author.ssp import SSPFilter
Expand Down Expand Up @@ -290,6 +291,7 @@ def create_new_with_filter(
input_ssp: str,
version: str = "",
profile_name: str = "",
main_comp_only: bool = False,
compdefs: Optional[List[str]] = None,
implementation_status: Optional[List[str]] = None,
control_origination: Optional[List[str]] = None,
Expand All @@ -302,7 +304,9 @@ def create_new_with_filter(
input_ssp: Input ssp to filter
version: Optional version to include in the output ssp
profile_name: Optional profile to filter by
compdefs: Optional list of component definitions to filter by
main_comp_only: Optional flag to include only the main component in the output ssp
compdefs: Optional list of component definitions to filter by.
The main component is added by default.
implementation_status: Optional implementation status to filter by
control_origination: Optional control origination to filter by
Expand All @@ -318,14 +322,16 @@ def create_new_with_filter(

components_title: Optional[List[str]] = None
if compdefs:
components_title = []
components_title = [SSP_MAIN_COMP_NAME]
for comp_def_name in compdefs:
comp_def, _ = ModelUtils.load_model_for_class(
trestle_path, comp_def_name, ComponentDefinition
)
components_title.extend(
[component.title for component in comp_def.components]
)
elif main_comp_only:
components_title = [SSP_MAIN_COMP_NAME]

try:
exit_code = ssp_filter.filter_ssp(
Expand Down

0 comments on commit a2269d2

Please sign in to comment.