From 3958ef10debe700edf901b12a7bfee71aab4275d Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Thu, 25 Jan 2024 17:08:53 -0500 Subject: [PATCH] chore: removes markdown creation from create_new_with_filter Removing unused portions of this function. The SSP filter funtionality is meant for reporting purposes only and not for editing. Signed-off-by: Jennifer Power --- tests/trestlebot/tasks/authored/test_ssp.py | 33 +++------------------ trestlebot/tasks/authored/ssp.py | 28 ++--------------- 2 files changed, 7 insertions(+), 54 deletions(-) diff --git a/tests/trestlebot/tasks/authored/test_ssp.py b/tests/trestlebot/tasks/authored/test_ssp.py index d07cd4ac..f685578a 100644 --- a/tests/trestlebot/tasks/authored/test_ssp.py +++ b/tests/trestlebot/tasks/authored/test_ssp.py @@ -234,35 +234,10 @@ def test_create_new_with_filter(tmp_trestle_dir: str) -> None: _ = testutils.setup_for_profile(trestle_root, test_prof_filter, test_prof_filter) ssp_name = "new_ssp" - new_md_path = os.path.join(markdown_dir, ssp_name) input_ssp = test_ssp_output - # Call create_new_with_filter with new profile - authored_ssp.create_new_with_filter( - ssp_name, input_ssp, markdown_path=new_md_path, profile_name=test_prof_filter - ) - - ssp_index.reload() - - assert ssp_index.get_profile_by_ssp(ssp_name) == test_prof_filter - assert test_comp in ssp_index.get_comps_by_ssp(ssp_name) - model_path = ModelUtils.get_model_path_for_name_and_class( - trestle_root, ssp_name, ossp.SystemSecurityPlan, FileContentType.JSON - ) - assert model_path.exists() - - ssp_name = "new_ssp_2" - new_md_path = os.path.join(markdown_dir, ssp_name) - # Call create_new_with_filter with a single compdef - authored_ssp.create_new_with_filter( - ssp_name, input_ssp, markdown_path=new_md_path, compdefs=[test_comp_2] - ) - - ssp_index.reload() - assert ssp_index.get_profile_by_ssp(ssp_name) == test_prof - assert test_comp not in ssp_index.get_comps_by_ssp(ssp_name) - assert test_comp_2 in ssp_index.get_comps_by_ssp(ssp_name) + authored_ssp.create_new_with_filter(ssp_name, input_ssp, compdefs=[test_comp_2]) ssp, model_path = load_validate_model_name( trestle_root, ssp_name, ossp.SystemSecurityPlan, FileContentType.JSON @@ -277,13 +252,13 @@ def test_create_new_with_filter(tmp_trestle_dir: str) -> None: assert test_comp_2 in component_names assert test_comp not in component_names - # Check that without markdown path the ssp_index is not updated - ssp_name = "new_ssp_3" + # Check that the ssp_index is not updated + ssp_name = "new_ssp_2" authored_ssp.create_new_with_filter( ssp_name, input_ssp, implementation_status=["implemented"] ) ssp_index.reload() with pytest.raises( - AuthoredObjectException, match="SSP new_ssp_3 does not exists in the index" + AuthoredObjectException, match="SSP new_ssp_2 does not exists in the index" ): ssp_index.get_profile_by_ssp(ssp_name) diff --git a/trestlebot/tasks/authored/ssp.py b/trestlebot/tasks/authored/ssp.py index c263120d..866269c6 100644 --- a/trestlebot/tasks/authored/ssp.py +++ b/trestlebot/tasks/authored/ssp.py @@ -242,7 +242,6 @@ def create_new_with_filter( ssp_name: str, input_ssp: str, version: str = "", - markdown_path: str = "", profile_name: str = "", compdefs: Optional[List[str]] = None, implementation_status: Optional[List[str]] = None, @@ -254,16 +253,15 @@ def create_new_with_filter( Args: ssp_name: Output name for ssp 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 implementation_status: Optional implementation status to filter by control_origination: Optional control origination to filter by - markdown_path: Optional top-level markdown path to write to for continued editing. Notes: - This will transform the SSP with filters. If markdown_path is provided, it will - also generate SSP markdown and an index entry for a new managed SSP for continued - management in the workspace. + The purpose of this function is to allow users to create a new SSP for reporting + purposes without having to modify the source SSP. """ # Create new ssp by filtering input ssp @@ -303,23 +301,3 @@ def create_new_with_filter( raise AuthoredObjectException( f"Trestle filtering failed for {input_ssp}: {e}" ) - - # If markdown_path is provided, create a new managed ssp. - # this will eventually need to have a JSON to MD recovery to - # reduce manual editing. - if markdown_path: - if not profile_name: - profile_name = self.ssp_index.get_profile_by_ssp(input_ssp) - - if not compdefs: - compdefs = self.ssp_index.get_comps_by_ssp(input_ssp) - - leveraged_ssp = self.ssp_index.get_leveraged_by_ssp(input_ssp) - - self.create_new_default( - ssp_name, - profile_name, - compdefs, - markdown_path, - leveraged_ssp, - )