Skip to content

Commit

Permalink
PSCE-202 - Adds create utility function to create ssps with ssp-filter (
Browse files Browse the repository at this point in the history
#38)

* feat: adds create_new_with_filter function for AuthoredSSP

Signed-off-by: Jennifer Power <[email protected]>

* tests create_new_with_filter

Signed-off-by: Alex Flom <[email protected]>

* test: adds tests to verify the ssp-index during create_with_filter

Signed-off-by: Jennifer Power <[email protected]>

---------

Signed-off-by: Jennifer Power <[email protected]>
Signed-off-by: Alex Flom <[email protected]>
Co-authored-by: Jennifer Power <[email protected]>
  • Loading branch information
Alex Flom and jpower432 authored Aug 29, 2023
1 parent 1d24f1d commit c5a0990
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 13 deletions.
80 changes: 80 additions & 0 deletions tests/data/json/simplified_filter_profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"profile": {
"uuid": "1019f424-1556-4aa3-9df3-337b97c2c857",
"metadata": {
"title": "Simple profile for filtering",
"last-modified": "2021-06-08T13:57:34.337491-04:00",
"version": "Final",
"oscal-version": "1.0.0",
"roles": [
{
"id": "creator",
"title": "Document Creator"
},
{
"id": "contact",
"title": "Contact"
}
],
"parties": [
{
"uuid": "cde369ce-57f8-4ec1-847f-2681a9a881e7",
"type": "organization",
"name": "Joint Task Force, Transformation Initiative",
"email-addresses": [
"[email protected]"
],
"addresses": [
{
"addr-lines": [
"National Institute of Standards and Technology",
"Attn: Computer Security Division",
"Information Technology Laboratory",
"100 Bureau Drive (Mail Stop 8930)"
],
"city": "Gaithersburg",
"state": "MD",
"postal-code": "20899-8930"
}
]
}
],
"responsible-parties": [
{
"role-id": "creator",
"party-uuids": [
"cde369ce-57f8-4ec1-847f-2681a9a881e7"
]
},
{
"role-id": "contact",
"party-uuids": [
"cde369ce-57f8-4ec1-847f-2681a9a881e7"
]
}
]
},
"imports": [
{
"href": "trestle://catalogs/simplified_nist_catalog/catalog.json",
"include-controls": [
{
"with-ids": [
"ac-1",
"ac-2",
"ac-2.1",
"ac-2.2",
"ac-2.3",
"ac-2.4",
"ac-2.5"
]
}
]
}
],
"merge": {
"as-is": true
},
"modify": {}
}
}
2 changes: 1 addition & 1 deletion tests/data/json/test_comp.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{
"uuid": "8220b305-0271-45f9-8a21-40ab6f197f70",
"type": "Service",
"title": "test comp",
"title": "test_comp",
"description": "test comp",
"props": [
{
Expand Down
273 changes: 273 additions & 0 deletions tests/data/json/test_comp_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"component-definition": {
"uuid": "2652b814-2a6b-4b6d-a0ae-8bc7a007209e",
"metadata": {
"title": "comp def b",
"last-modified": "2021-07-19T14:03:03+00:00",
"version": "0.21.0",
"oscal-version": "1.0.2",
"roles": [
{
"id": "prepared-by",
"title": "Indicates the organization that created this content."
},
{
"id": "prepared-for",
"title": "Indicates the organization for which this content was created.."
},
{
"id": "content-approver",
"title": "Indicates the organization responsible for all content represented in the \"document\"."
}
],
"parties": [
{
"uuid": "ce1f379a-fcdd-485a-a7b7-6f02c0763dd2",
"type": "organization",
"name": "ACME",
"remarks": "ACME company"
},
{
"uuid": "481856b6-16e4-4993-a3ed-2fb242ce235b",
"type": "organization",
"name": "Customer",
"remarks": "Customer for the Component Definition"
},
{
"uuid": "2dc8b17f-daca-44a1-8a1d-c290120ea5e2",
"type": "organization",
"name": "ISV",
"remarks": "ISV for the Component Definition"
}
],
"responsible-parties": [
{
"role-id": "prepared-by",
"party-uuids": [
"ce1f379a-fcdd-485a-a7b7-6f02c0763dd2"
]
},
{
"role-id": "prepared-for",
"party-uuids": [
"481856b6-16e4-4993-a3ed-2fb242ce235b",
"2dc8b17f-daca-44a1-8a1d-c290120ea5e2"
]
},
{
"role-id": "content-approver",
"party-uuids": [
"ce1f379a-fcdd-485a-a7b7-6f02c0763dd2"
]
}
]
},
"components": [
{
"uuid": "8220b305-0271-45f9-8a21-40ab6f197f70",
"type": "Service",
"title": "test_comp_2",
"description": "test comp 2",
"props": [
{
"name": "Rule_Id",
"ns": "http://comp_ns",
"value": "top_shared_rule_1",
"class": "Rule_Id",
"remarks": "rule_1"
},
{
"name": "Rule_Description",
"ns": "http://comp_ns",
"value": "top shared rule 1 in aa",
"remarks": "rule_1"
},
{
"name": "Parameter_Id",
"ns": "http://comp_ns",
"value": "shared_param_x",
"class": "Parameter_Id",
"remarks": "rule_x"
},
{
"name": "Parameter_Description",
"ns": "http://comp_ns",
"value": "shared param x in aa",
"class": "Parameter_Description",
"remarks": "rule_x"
},
{
"name": "Parameter_Value_Alternatives",
"ns": "http://comp_ns",
"value": "[\"shared_param_x_aa_opt_1\", \"shared_param_x_aa_opt_2\", \"shared_param_x_aa_opt_3\"]",
"class": "Parameter_Value_Alternatives",
"remarks": "rule_x"
}
],
"control-implementations": [
{
"uuid": "76e89b67-3d6b-463d-90df-ec56a46c6069",
"source": "trestle://profiles/simplified_nist_profile/profile.json",
"description": "test comp 2",
"props": [
{
"name": "profile_name",
"ns": "https://trestle/prof_ns",
"value": "trestle prof aa",
"class": "trestle_profile_name"
},
{
"name": "Rule_Id",
"ns": "http://comp_ns",
"value": "comp_rule_aa_1",
"class": "Rule_Id",
"remarks": "rule_2"
},
{
"name": "Rule_Description",
"ns": "http://comp_ns",
"value": "comp rule aa 1",
"remarks": "rule_2"
},
{
"name": "Rule_Id",
"ns": "http://comp_ns",
"value": "comp_rule_aa_2",
"class": "Rule_Id",
"remarks": "rule_3"
},
{
"name": "Rule_Description",
"ns": "http://comp_ns",
"value": "comp rule aa 2",
"class": "Rule_Description",
"remarks": "rule_3"
},
{
"name": "Parameter_Id",
"ns": "http://comp_ns",
"value": "shared_param_1",
"class": "Parameter_Id",
"remarks": "rule_1"
},
{
"name": "Parameter_Description",
"ns": "http://comp_ns",
"value": "shared param 1 in aa",
"class": "Parameter_Description",
"remarks": "rule_1"
},
{
"name": "Parameter_Value_Alternatives",
"ns": "http://comp_ns",
"value": "[\"shared_param_1_aa_opt_1\", \"shared_param_1_aa_opt_2\", \"shared_param_1_aa_opt_3\"]",
"class": "Parameter_Value_Alternatives",
"remarks": "rule_1"
}
],
"set-parameters": [
{
"param-id": "shared_param_1",
"values": [
"shared_param_1_aa_opt_1"
],
"remarks": "set shared param aa 3"
},
{
"param-id": "ac-1_prm_3",
"values": [
"set by comp aa ci"
]
}
],
"implemented-requirements": [
{
"uuid": "ca5ea4c5-ba51-4b1d-932a-5606891b7500",
"control-id": "ac-1",
"description": "imp req prose for ac-1 from comp b",
"props": [
{
"name": "Rule_Id",
"value": "top_shared_rule_1"
},
{
"name": "implementation-status",
"value": "implemented"
}
],
"set-parameters": [
{
"param-id": "shared_param_1",
"values": [
"shared_param_1_aa_opt_1"
],
"remarks": "set shared param aa 1"
},
{
"param-id": "ac-1_prm_3",
"values": [
"set by comp aa imp req"
]
}
],
"responsible-roles": [
{
"role-id": "prepared-by",
"party-uuids": [
"ce1f379a-fcdd-485a-a7b7-6f02c0763dd2"
]
},
{
"role-id": "prepared-for",
"party-uuids": [
"481856b6-16e4-4993-a3ed-2fb242ce235b",
"2dc8b17f-daca-44a1-8a1d-c290120ea5e2"
]
},
{
"role-id": "content-approver",
"party-uuids": [
"ce1f379a-fcdd-485a-a7b7-6f02c0763dd2"
]
}
],
"statements": [
{
"statement-id": "ac-1_smt.a",
"uuid": "2652b814-2a6b-4b6d-a0ae-8bc7a0072200",
"description": "statement prose for part a. from comp b",
"props": [
{
"name": "Rule_Id",
"value": "comp_rule_aa_1"
},
{
"name": "implementation-status",
"value": "partial"
}
]
}
]
},
{
"uuid": "ca5ea4c5-ba51-4b1d-932a-5606891b7599",
"control-id": "ac-2",
"description": "imp req prose for ac-2 from comp b",
"props": [
{
"name": "Rule_Id",
"value": "top_shared_rule_1"
},
{
"name": "implementation-status",
"value": "implemented"
}
]
}
]
}
]
}
]
}
}
13 changes: 10 additions & 3 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ def load_from_json(


def setup_for_ssp(
tmp_trestle_dir: pathlib.Path, prof_name: str, comp_name: str, output_name: str
tmp_trestle_dir: pathlib.Path,
prof_name: str,
comps: List[str],
output_name: str,
) -> argparse.Namespace:
"""Setup trestle temp directory for ssp testing"""
load_from_json(tmp_trestle_dir, comp_name, comp_name, comp.ComponentDefinition) # type: ignore
for comp_name in comps:
load_from_json(tmp_trestle_dir, comp_name, comp_name, comp.ComponentDefinition) # type: ignore

comp_list = ",".join(comps)

load_from_json(tmp_trestle_dir, prof_name, prof_name, prof.Profile) # type: ignore
load_from_json(
tmp_trestle_dir,
Expand All @@ -73,7 +80,7 @@ def setup_for_ssp(
args = argparse.Namespace(
trestle_root=tmp_trestle_dir,
profile=prof_name,
compdefs=comp_name,
compdefs=comp_list,
output=output_name,
verbose=0,
overwrite_header_values=False,
Expand Down
Loading

0 comments on commit c5a0990

Please sign in to comment.