Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds fedramp-transform command implementation #39

Merged
merged 24 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
17adc20
chore: adds FedRAMP SSP Appendix A template to resources
jpower432 Feb 12, 2024
6d7033d
feat: adds fedramp-transform command
jpower432 Feb 12, 2024
e3704f4
test: adds unit test for transform command and related classes
jpower432 Feb 12, 2024
0e0670b
fix: handles control with no labels
jpower432 Feb 17, 2024
2477f79
chore: moves FEDRAMP constant from class data to const.py
jpower432 Feb 19, 2024
7227207
feat: adds support for multiple checked boxes
jpower432 Feb 19, 2024
2f2fd73
feat: updates FedRAMPSSPReader to collect control responses
jpower432 Feb 19, 2024
5c93eb0
feat: adds FedRampDocx and ControlImplementation description classes
jpower432 Feb 19, 2024
afc9313
chore: updates class organization and add check for invalid control o…
jpower432 Feb 21, 2024
825e700
feat: adds filtering for responses by component
jpower432 Feb 21, 2024
9c30499
test: moves check functions to test_utils and adds test in transform_…
jpower432 Feb 21, 2024
dbe66f5
chore: removes include_components and tests
jpower432 Feb 22, 2024
26d4166
chore: updates docx response format in the cell
jpower432 Feb 26, 2024
68ebbde
feat: adds get_implementation_status to FedRAMPSSPReader
jpower432 Mar 5, 2024
7c42bac
feat: populates the implementation status cell in the FedRAMP template
jpower432 Mar 6, 2024
f58f3b1
fix: refines error message when multiple implementation statuses are set
jpower432 Mar 14, 2024
fe2544a
feat: adds reading parameters values in the FedRAMPSSPReader
jpower432 Mar 14, 2024
a3a5478
feat: add FedRAMP parameter populate in the SSP Appendix A template
jpower432 Mar 19, 2024
c15cf90
refactor: only adds parameter values when set
jpower432 Mar 20, 2024
c2daaf0
feat: adds responsible role processing to FedRAMPSSPReader class
jpower432 Apr 22, 2024
456e236
feat: adds responsible role population in docx template
jpower432 Apr 23, 2024
09051de
fix: addresses PR feedback
jpower432 Jul 29, 2024
faf4d37
Merge branch 'develop' into feat/fedramp-transform-responsible-role
jpower432 Jul 29, 2024
fb4440f
Merge branch 'develop' into feat/fedramp-transform-responsible-role
jpower432 Sep 18, 2024
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
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ include_package_data = True
install_requires =
compliance-trestle>=3.3.0
saxonche>=12.4.1.0
python-docx>=1.1.0

[options.packages.find]
include = trestle_fedramp*
Expand Down
110 changes: 109 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,27 @@
# limitations under the License.
"""Common fixtures."""

import argparse
import os
import pathlib
import sys
from typing import Iterator
from typing import Iterator, Tuple

from docx import Document # type: ignore
from docx.document import Document as DocxDocument # type: ignore

import pytest
from pytest import MonkeyPatch

from tests import test_utils

from trestle.cli import Trestle
from trestle.common.err import TrestleError
from trestle.core.commands.import_ import ImportCmd

from trestle_fedramp import const
from trestle_fedramp.core.baselines import BaselineLevel
from trestle_fedramp.core.ssp_reader import FedrampControlDict, FedrampSSPData


@pytest.fixture(scope='function')
Expand All @@ -46,3 +57,100 @@ def tmp_trestle_dir(tmp_path: pathlib.Path, monkeypatch: MonkeyPatch) -> Iterato
yield tmp_path
finally:
os.chdir(pytest_cwd)


@pytest.fixture(scope='function')
def tmp_trestle_dir_with_ssp(tmp_path: pathlib.Path, monkeypatch: MonkeyPatch) -> Iterator[Tuple[pathlib.Path, str]]:
"""Create initialized trestle workspace and import the model into it."""
pytest_cwd = pathlib.Path.cwd()
model_name = 'ssp'
file_path = test_utils.JSON_TEST_DATA_PATH / test_utils.TEST_SSP_JSON
os.chdir(tmp_path)
testargs = ['trestle', 'init']
monkeypatch.setattr(sys, 'argv', testargs)
try:
Trestle().run()
i = ImportCmd()
args = argparse.Namespace(
trestle_root=tmp_path, file=str(file_path), output=model_name, verbose=1, regenerate=False
)
assert i._run(args) == 0
except Exception as e:
raise TrestleError(f'Error creating trestle workspace with ssp: {e}')
else:
yield (tmp_path, model_name)
finally:
os.chdir(pytest_cwd)


@pytest.fixture(scope='function')
def docx_document() -> Iterator[DocxDocument]:
"""Return a docx document."""
template = pathlib.Path(BaselineLevel.get_template('high')).resolve()
with open(template, 'rb') as file:
document: DocxDocument = Document(file)
yield document


@pytest.fixture(scope='function')
def test_ssp_control_dict() -> Iterator[FedrampControlDict]:
"""Return a dictionary of control data."""
control_dict: FedrampControlDict = {
'AC-1': FedrampSSPData(
control_implementation_description={
'a': 'Part a example for AC-1', 'b': 'Part b example for AC-1', 'c': 'Part c example for AC-1'
},
parameters={
'AC-1(a)': 'AC-1(a) parameter example',
'AC-1(a)(1)': 'AC-1(a)(1) parameter example',
'AC-1(b)': 'AC-1(b) parameter example',
'AC-1(c)(1)-1': 'AC-1(c)(1)-1 parameter example',
'AC-1(c)(1)-2': 'AC-1(c)(1)-2 parameter example',
'AC-1(c)(2)-1': 'AC-1(c)(2)-1 parameter example',
'AC-1(c)(2)-2': 'AC-1(c)(2)-2 parameter example',
},
control_origination=None,
implementation_status=None,
responsible_roles=None
),
'AC-2(1)': FedrampSSPData(
control_implementation_description={'': 'Overall description for AC-2(1)'},
parameters={
'AC-2(2)-1': 'AC-2(2)-1 parameter example',
'AC-2(2)-2': 'AC-2(2)-2 parameter example',
},
control_origination=[const.FEDRAMP_SP_SYSTEM],
implementation_status=const.FEDRAMP_PLANNED,
responsible_roles=['Customer']
),
'AC-20': FedrampSSPData(
control_implementation_description={
'a': 'Part a example for AC-20',
'b': 'Part b example for AC-20',
},
parameters={
'AC-20(a)': 'AC-20(a) parameter example',
'AC-20(b)': 'AC-20(b) parameter example',
},
control_origination=[const.FEDRAMP_SP_CORPORATE, const.FEDRAMP_INHERITED],
implementation_status=const.FEDRAMP_PARTIAL,
responsible_roles=['Admin', 'Customer']
),
'CM-6': FedrampSSPData(
control_implementation_description={
'a': 'Part a example for CM-6',
'b': 'Part b example for CM-6',
'c': 'Part c example for CM-6',
'd': 'Part d example for CM-6',
},
parameters={
'CM-6(a)': 'CM-6(a) parameter example',
'CM-6(c)-1': 'CM-6(c)-1 parameter example',
'CM-6(c)-2': 'CM-6(c)-2 parameter example',
},
control_origination=[const.FEDRAMP_SHARED],
implementation_status=const.FEDRAMP_IMPLEMENTED,
responsible_roles=['Provider']
)
}
yield control_dict
Loading
Loading