Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add-inheritance-view
Browse files Browse the repository at this point in the history
  • Loading branch information
jpower432 authored Sep 11, 2023
2 parents 33119d5 + 62e2f05 commit 7fd10e8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@

<!--next-version-placeholder-->

## 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
Expand Down
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dev =
setuptools
wheel
yapf
python-semantic-release
python-semantic-release==7.33.2
pep8-naming
pytest-random-order
python-dateutil
Expand All @@ -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
Expand Down
26 changes: 26 additions & 0 deletions tests/trestle/tasks/csv_to_oscal_cd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion trestle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
opinionated approach to OSCAL adoption.
"""

__version__ = '2.2.1'
__version__ = '2.3.0'
14 changes: 12 additions & 2 deletions trestle/tasks/csv_to_oscal_cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 7fd10e8

Please sign in to comment.