From ea5607f9f404f38da1abf1c40f907196ea79c567 Mon Sep 17 00:00:00 2001 From: AleJo2995 Date: Tue, 5 Sep 2023 15:52:48 -0600 Subject: [PATCH 1/5] fix: moving watch config a level up (#1447) * fix: moving watch config a level up Signed-off-by: Alejandro Jose Leiva Palomo * fix: disable check for changes build to make the change in mkdocs config Signed-off-by: Alejandro Jose Leiva Palomo * fix: revert changes Signed-off-by: Alejandro Jose Leiva Palomo * fix: change mkdocs version Signed-off-by: Alejandro Jose Leiva Palomo * fix: fix typo Signed-off-by: Alejandro Jose Leiva Palomo * fix: downgrade version to 1.5.0 Signed-off-by: Alejandro Jose Leiva Palomo * fix: change mkdocstrings version to stable Signed-off-by: Alejandro Jose Leiva Palomo * fix: change mkdocs to pull latest version Signed-off-by: Alejandro Jose Leiva Palomo --------- Signed-off-by: Alejandro Jose Leiva Palomo --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a0517b587..624f3cd6e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,7 +77,7 @@ dev = types-setuptools # # Docs website mkdocs - mkdocstrings[python-legacy]>=0.19.0 + mkdocstrings[python-legacy]==0.19.0 mkdocs-material markdown-include pymdown-extensions From a8cb9b9f1f11485ac70fa2f35a3e52b917b7a783 Mon Sep 17 00:00:00 2001 From: Alejandro Jose Leiva Palomo Date: Wed, 6 Sep 2023 11:57:36 -0600 Subject: [PATCH 2/5] fix: correcting python semantice release version Signed-off-by: Alejandro Jose Leiva Palomo --- setup.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 624f3cd6e..449d5cbbd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,7 @@ dev = setuptools wheel yapf - python-semantic-release + python-semantic-release==7.33.2 pep8-naming pytest-random-order python-dateutil @@ -76,8 +76,8 @@ dev = types-requests types-setuptools # # Docs website - mkdocs - mkdocstrings[python-legacy]==0.19.0 + mkdocs==1.5.0 + mkdocstrings[python-legacy]>=0.19.0 mkdocs-material markdown-include pymdown-extensions From 181000731ada7af1348219581994bd58f2285329 Mon Sep 17 00:00:00 2001 From: Alejandro Jose Leiva Palomo Date: Wed, 6 Sep 2023 12:10:39 -0600 Subject: [PATCH 3/5] fix: correcting typo Signed-off-by: Alejandro Jose Leiva Palomo --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 449d5cbbd..3c84d3b32 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,7 +77,7 @@ dev = types-setuptools # # Docs website mkdocs==1.5.0 - mkdocstrings[python-legacy]>=0.19.0 + mkdocstrings[python-legacy]==0.19.0 mkdocs-material markdown-include pymdown-extensions From 5e9fc45c7fbc13c4be0891b656814c7d18d11106 Mon Sep 17 00:00:00 2001 From: semantic-release Date: Wed, 6 Sep 2023 18:24:33 +0000 Subject: [PATCH 4/5] 2.3.0 Automatically generated by python-semantic-release --- CHANGELOG.md | 16 ++++++++++++++++ trestle/__init__.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f67363fdb..0be2b899f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ +## v2.3.0 (2023-09-06) +### Feature +* Extend multiple templates validation to trestle author folders ([#1430](https://github.com/IBM/compliance-trestle/issues/1430)) ([`c7bef58`](https://github.com/IBM/compliance-trestle/commit/c7bef589a6e671b96170e93feb88c6436a094da6)) +* Adds agile authoring functionality to public API in repository.py ([#1432](https://github.com/IBM/compliance-trestle/issues/1432)) ([`08b2559`](https://github.com/IBM/compliance-trestle/commit/08b255902efb911c99422d49920c5ddaea98ef32)) +* Support validation component_type for task csv-to-oscal-cd ([#1431](https://github.com/IBM/compliance-trestle/issues/1431)) ([`80aaa72`](https://github.com/IBM/compliance-trestle/commit/80aaa72fe96217d1c7dd93e4c1d5bd9c34cb012b)) + +### Fix +* Correcting typo ([`1810007`](https://github.com/IBM/compliance-trestle/commit/181000731ada7af1348219581994bd58f2285329)) +* Correcting python semantice release version ([`a8cb9b9`](https://github.com/IBM/compliance-trestle/commit/a8cb9b9f1f11485ac70fa2f35a3e52b917b7a783)) +* Moving watch config a level up ([#1447](https://github.com/IBM/compliance-trestle/issues/1447)) ([`ea5607f`](https://github.com/IBM/compliance-trestle/commit/ea5607f9f404f38da1abf1c40f907196ea79c567)) +* Xccdf parameter type ([#1440](https://github.com/IBM/compliance-trestle/issues/1440)) ([`431670c`](https://github.com/IBM/compliance-trestle/commit/431670cd468693ca4581ec43d8de5d32413ec113)) +* Headings levels validation is not working properly ([#1436](https://github.com/IBM/compliance-trestle/issues/1436)) ([`22b65a9`](https://github.com/IBM/compliance-trestle/commit/22b65a9b84af36d8c12c32c6e5c0dae88208ea49)) +* Default set-parameter values as list ([#1438](https://github.com/IBM/compliance-trestle/issues/1438)) ([`419025d`](https://github.com/IBM/compliance-trestle/commit/419025dfad47cf9f61b5e20a35a9683a84ed26e8)) +* Expected nist profile missing ([#1435](https://github.com/IBM/compliance-trestle/issues/1435)) ([`c96f9ce`](https://github.com/IBM/compliance-trestle/commit/c96f9ce82e453c83a07d9d4c1061833f38c7f104)) +* Provide description and meaning to parameters in markdown ([#1423](https://github.com/IBM/compliance-trestle/issues/1423)) ([`266f67b`](https://github.com/IBM/compliance-trestle/commit/266f67bd220e15922caacb4de0e702f4d0927ceb)) + ## v2.2.1 (2023-07-05) ### Fix diff --git a/trestle/__init__.py b/trestle/__init__.py index 22d3908eb..967548cb7 100644 --- a/trestle/__init__.py +++ b/trestle/__init__.py @@ -23,4 +23,4 @@ opinionated approach to OSCAL adoption. """ -__version__ = '2.2.1' +__version__ = '2.3.0' From 62e2f059dd2ae08616895ebdfd6e37258483019d Mon Sep 17 00:00:00 2001 From: Lou DeGenaro Date: Mon, 11 Sep 2023 07:33:36 -0400 Subject: [PATCH 5/5] fix: prevent duplicates in set-parameters (#1450) Signed-off-by: Lou DeGenaro --- tests/trestle/tasks/csv_to_oscal_cd_test.py | 26 +++++++++++++++++++++ trestle/tasks/csv_to_oscal_cd.py | 14 +++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/tests/trestle/tasks/csv_to_oscal_cd_test.py b/tests/trestle/tasks/csv_to_oscal_cd_test.py index 82913ef83..639db26e8 100644 --- a/tests/trestle/tasks/csv_to_oscal_cd_test.py +++ b/tests/trestle/tasks/csv_to_oscal_cd_test.py @@ -661,6 +661,32 @@ def test_execute_add_rule(tmp_path: pathlib.Path) -> None: assert len(component.control_implementations[1].set_parameters) == 1 +def test_execute_param_duplicate_value(tmp_path: pathlib.Path) -> None: + """Test execute param duplicate default value.""" + _, section = _get_config_section_init(tmp_path, 'test-csv-to-oscal-cd-bp.config') + # duplicate default param default value + rows = _get_rows('tests/data/csv/bp.sample.v2.csv') + row = rows[3] + assert row[13] == 'allowed_admins_per_account' + assert row[15] == '10' + row = rows[2] + row[13] = 'allowed_admins_per_account' + row[15] = '10' + rows[2] = row + with mock.patch('trestle.tasks.csv_to_oscal_cd.csv.reader') as mock_csv_reader: + mock_csv_reader.return_value = rows + tgt = csv_to_oscal_cd.CsvToOscalComponentDefinition(section) + retval = tgt.execute() + assert retval == TaskOutcome.SUCCESS + row[15] = '11' + rows[2] = row + with mock.patch('trestle.tasks.csv_to_oscal_cd.csv.reader') as mock_csv_reader: + mock_csv_reader.return_value = rows + tgt = csv_to_oscal_cd.CsvToOscalComponentDefinition(section) + retval = tgt.execute() + assert retval == TaskOutcome.FAILURE + + def test_execute_missing_param_default_value(tmp_path: pathlib.Path) -> None: """Test execute missing param default_value.""" _, section = _get_config_section_init(tmp_path, 'test-csv-to-oscal-cd-bp.config') diff --git a/trestle/tasks/csv_to_oscal_cd.py b/trestle/tasks/csv_to_oscal_cd.py index e792c54cf..0a9fb4053 100644 --- a/trestle/tasks/csv_to_oscal_cd.py +++ b/trestle/tasks/csv_to_oscal_cd.py @@ -331,7 +331,7 @@ def _calculate_set_params(self, mod_rules: List) -> tuple: logger.debug(f'params mod: {key}') else: add_set_params.append(key) - logger.debug(f'prams add: {key}') + logger.debug(f'params add: {key}') return (del_set_params, add_set_params, mod_set_params) def _calculate_control_mappings(self, mod_rules: List) -> tuple: @@ -824,7 +824,17 @@ class _OscalHelper(): @staticmethod def add_set_parameter(set_parameter_list: List[SetParameter], set_parameter: SetParameter) -> None: """Add set parameter.""" - set_parameter_list.append(set_parameter) + add = True + # don't add duplicate + for sp in set_parameter_list: + if sp.param_id == set_parameter.param_id: + add = False + if sp.values != set_parameter.values: + text = f'set-parameter id={sp.param_id} conflicting values' + raise RuntimeError(text) + break + if add: + set_parameter_list.append(set_parameter) @staticmethod def remove_rule_statement(statements: List[Statement], rule_id: str, smt_id: str) -> List[Statement]: