From d25f023ceda02902cbdbfe1da87ecf0c30674b39 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 25 Sep 2024 11:51:56 -0400 Subject: [PATCH 1/3] Update compliance-trestle to jinja-extension-plugins branch --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index dc16312..6f457e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -# switch back to a released version of compliance-trestle once the jinja tags work is merged and released -compliance-trestle @ git+https://github.com/gsa-tts/compliance-trestle.git@77a6d5d0 +# switch back to a released version of compliance-trestle once the jinja filters/plugins work is merged and released +compliance-trestle @ git+https://github.com/gsa-tts/compliance-trestle.git@576c4369 compliance-trestle-gsa @ git+https://github.com/GSA-TTS/compliance-trestle-gsa.git@39ce4167 From 0ccb8575631a4a64c21121b2f31939240ce85b23 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 25 Sep 2024 12:17:21 -0400 Subject: [PATCH 2/3] Switch templates from ssp_interface jinja helper to custom filters --- .../ssp-rendering/lato/templates/approvals.md | 6 +++--- .../lato/templates/frontmatter.md | 20 +++++++++---------- .../templates/partials/poc_contact_table.md | 14 ++++++------- .../lato/templates/section_10.md | 4 ++-- .../ssp-rendering/lato/templates/section_3.md | 2 +- .../ssp-rendering/lato/templates/section_4.md | 2 +- .../ssp-rendering/lato/templates/section_5.md | 4 ++-- .../ssp-rendering/lato/templates/section_6.md | 2 +- .../ssp-rendering/lato/templates/section_9.md | 4 ++-- 9 files changed, 27 insertions(+), 31 deletions(-) diff --git a/templates/ssp-rendering/lato/templates/approvals.md b/templates/ssp-rendering/lato/templates/approvals.md index b4c3d41..6a5c4fc 100644 --- a/templates/ssp-rendering/lato/templates/approvals.md +++ b/templates/ssp-rendering/lato/templates/approvals.md @@ -7,7 +7,7 @@


-{% set owners = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "system-owner") | list %} +{% set owners = ssp.system_characteristics.responsible_parties | parties_for_role("system-owner", ssp) | list %} {% if owners | count > 0 %} {{ owners[0].name }} {% else %} @@ -22,7 +22,7 @@ System Owner


-{% set isso = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-officer") | list %} +{% set isso = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-officer", ssp) | list %} {% if isso | count > 0 %} {{ isso[0].name }} {% else %} @@ -37,7 +37,7 @@ Information System Security Officer


-{% set issm = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-manager") | list %} +{% set issm = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-manager", ssp) | list %} {% if issm | count > 0 %} {{ issm[0].name }} {% else %} diff --git a/templates/ssp-rendering/lato/templates/frontmatter.md b/templates/ssp-rendering/lato/templates/frontmatter.md index 919c760..860866a 100644 --- a/templates/ssp-rendering/lato/templates/frontmatter.md +++ b/templates/ssp-rendering/lato/templates/frontmatter.md @@ -16,20 +16,18 @@ Document Prepared By -{% for party in ssp_interface.get_parties_for_role(ssp.metadata.responsible_parties, "prepared-by") %} +{% for party in ssp.metadata.responsible_parties | parties_for_role("prepared-by", ssp) %} +{% set address = party.addresses | first_or_none %} +{% for addr_line in address.addr_lines | as_list %} -{% set address = ssp_interface.first_array_entry(party.addresses) %} -{% set addr_lines = ssp_interface.safe_retrieval(address, "addr_lines", []) %} - - - - + +{% endfor %} - + {% endfor %} @@ -39,11 +37,11 @@ Document Prepared By Document Revision History -{% set prepared_by = ssp_interface.first_array_entry(ssp_interface.get_parties_for_role(ssp.metadata.responsible_parties, "prepared-by")) %} +{% set prepared_by = ssp.metadata.responsible_parties | parties_for_role("prepared-by", ssp) | first_or_none %} | Date | Comments | Version | Author | | ---- | -------- | ------- | ------ | -{% for revision in ssp_interface.safe_retrieval(ssp.metadata, 'revisions', []) %} -{% set revision_prepared_by = ssp_interface.get_party_by_uuid(control_interface.get_prop(revision, 'prepared-by')) or prepared_by %} +{% for revision in ssp.metadata.revisions | as_list %} +{% set revision_prepared_by = control_interface.get_prop(revision, "prepared-by") | get_party(ssp) | get_default(prepared_by) %} | {{ revision.last_modified.strftime('%Y-%m-%d') if revision.last_modified else '' }} | {{ revision.title }} | {{ revision.version }} | {{ revision_prepared_by.name }} | {% endfor %} diff --git a/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md b/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md index 1d3ebe7..6c5fe35 100644 --- a/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md +++ b/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md @@ -7,24 +7,22 @@ -{% set organization = ssp_interface.get_party_by_uuid(ssp_interface.first_array_entry(party.member_of_organizations)) %} - +{% set organization = party.member_of_organizations | first_or_none | get_party(ssp) %} + - + - +
{{ party.type.value.title() }} Name{{ party.name }}
Address Line 1{{ addr_lines[0] }}
Address Line 2{{ addr_lines[1] }}Address Line {{ loop.index }}{{ addr_line }}
City, State Zip{{ ssp_interface.safe_retrieval(address, "city") }}, {{ ssp_interface.safe_retrieval(address, "state") }} {{ ssp_interface.safe_retrieval(address, "postal_code") }}City, State Zip{{ address.city }}, {{ address.state }} {{ address.postal_code }}
Title{{ control_interface.get_prop(party, 'title') }}
Organization{{ ssp_interface.safe_retrieval(organization, "name") }}Organization{{ organization.name }}
Address -{% if organization and organization.addresses %} -{% set address = ssp_interface.first_array_entry(organization.addresses) %} +{% set address = organization.addresses | first_or_none %} {% if address %} -{{ ssp_interface.safe_retrieval(address, 'addr_lines', []) | join(' ') }} {{ address.city }}, {{ address.state }} {{ address.postal_code }} -{% endif %} +{{ address.addr_lines | as_list | join(' ') }} {{ address.city }}, {{ address.state }} {{ address.postal_code }} {% endif %}
Phone Number{{ ssp_interface.first_array_entry(party.telephone_numbers, "number") }}Phone Number{{ (party.telephone_numbers | first_or_none).number }}
Email Address{{ ssp_interface.first_array_entry(party.email_addresses, "__root__") }}Email Address{{ (party.email_addresses | first_or_none).__root__ }}
diff --git a/templates/ssp-rendering/lato/templates/section_10.md b/templates/ssp-rendering/lato/templates/section_10.md index d5d55af..faa2edc 100644 --- a/templates/ssp-rendering/lato/templates/section_10.md +++ b/templates/ssp-rendering/lato/templates/section_10.md @@ -35,8 +35,8 @@ Ensure the following elements are incorporated into the data flow diagrams and n The Data Flow Diagram (DFD) below maps out the flow of information traveling within an information system and between infrormation systems. -{% for diagram in ssp_interface.safe_retrieval(ssp.system_characteristics.data_flow, 'diagrams', []) %} -![{{diagram.caption}}]({{ ssp_interface.get_diagram_href(diagram) }}) +{% for diagram in ssp.system_characteristics.data_flow.diagrams | as_list %} +![{{diagram.caption}}]({{ diagram | diagram_href }})
Figure 10-{{loop.index}}. Data Flow Diagram {% endfor %} diff --git a/templates/ssp-rendering/lato/templates/section_3.md b/templates/ssp-rendering/lato/templates/section_3.md index b987e70..20d5d63 100644 --- a/templates/ssp-rendering/lato/templates/section_3.md +++ b/templates/ssp-rendering/lato/templates/section_3.md @@ -2,6 +2,6 @@ The following individual is identified as the System Owner for this system. -{% for party in ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "system-owner") %} +{% for party in ssp.system_characteristics.responsible_parties | parties_for_role("system-owner", ssp) %} {% include "ssp-render/templates/partials/poc_contact_table.md" +%} {% endfor +%} diff --git a/templates/ssp-rendering/lato/templates/section_4.md b/templates/ssp-rendering/lato/templates/section_4.md index 41c6b44..3bc587a 100644 --- a/templates/ssp-rendering/lato/templates/section_4.md +++ b/templates/ssp-rendering/lato/templates/section_4.md @@ -2,6 +2,6 @@ The Authorizing Official (AO) for this information system is identified below. -{% for party in ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "authorizing-official") %} +{% for party in ssp.system_characteristics.responsible_parties | parties_for_role("authorizing-official", ssp) %} {% include "ssp-render/templates/partials/poc_contact_table.md" +%} {% endfor +%} diff --git a/templates/ssp-rendering/lato/templates/section_5.md b/templates/ssp-rendering/lato/templates/section_5.md index cf3c7a8..24ad8d7 100644 --- a/templates/ssp-rendering/lato/templates/section_5.md +++ b/templates/ssp-rendering/lato/templates/section_5.md @@ -2,12 +2,12 @@ The Information System Security Manager (ISSM) has been appointed and is identified below. -{% for party in ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-manager") %} +{% for party in ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-manager", ssp) %} {% include "ssp-render/templates/partials/poc_contact_table.md" +%} {% endfor +%} The Information System Security Officer (ISSO) has been appointed and is identified below. -{% for party in ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-officer") %} +{% for party in ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-officer", ssp) %} {% include "ssp-render/templates/partials/poc_contact_table.md" +%} {% endfor +%} diff --git a/templates/ssp-rendering/lato/templates/section_6.md b/templates/ssp-rendering/lato/templates/section_6.md index 3527881..897a91d 100644 --- a/templates/ssp-rendering/lato/templates/section_6.md +++ b/templates/ssp-rendering/lato/templates/section_6.md @@ -2,6 +2,6 @@ The individual(s) identified below possess in-depth knowledge of this system and/or its functions and operation. -{% for party in ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "system-poc-technical") %} +{% for party in ssp.system_characteristics.responsible_parties | parties_for_role("system-poc-technical", ssp) %} {% include "ssp-render/templates/partials/poc_contact_table.md" +%} {% endfor +%} diff --git a/templates/ssp-rendering/lato/templates/section_9.md b/templates/ssp-rendering/lato/templates/section_9.md index 41f2e14..8c90b7f 100644 --- a/templates/ssp-rendering/lato/templates/section_9.md +++ b/templates/ssp-rendering/lato/templates/section_9.md @@ -59,7 +59,7 @@ The network architecture must follow the criteria listed in CIO-IT Security-19-9 The following architectural diagram provides a visual depiction of the major hardware components of the {{ ssp.system_characteristics.system_name_short }}. -{% for diagram in ssp_interface.safe_retrieval(ssp.system_characteristics.authorization_boundary, 'diagrams', []) %} -![{{diagram.caption}}]({{ ssp_interface.get_diagram_href(diagram) }}) +{% for diagram in ssp.system_characteristics.authorization_boundary.diagrams | as_list %} +![{{diagram.caption}}]({{ diagram | diagram_href }})
Figure 9-{{loop.index}}. Network Diagram {% endfor %} From 76c8599fa55f206aba40883875ea456d6d538192 Mon Sep 17 00:00:00 2001 From: Ryan Ahearn Date: Wed, 25 Sep 2024 17:15:04 -0400 Subject: [PATCH 3/3] Clean up markdown formats that didn't translate well to pdf --- .../ssp-rendering/lato/templates/approvals.md | 32 +++++------------ .../lato/templates/frontmatter.md | 35 ++++++------------- .../lato/templates/gsa_template.md.jinja | 10 ------ .../templates/partials/poc_contact_table.md | 34 ++++++------------ 4 files changed, 29 insertions(+), 82 deletions(-) diff --git a/templates/ssp-rendering/lato/templates/approvals.md b/templates/ssp-rendering/lato/templates/approvals.md index 6a5c4fc..b23aaeb 100644 --- a/templates/ssp-rendering/lato/templates/approvals.md +++ b/templates/ssp-rendering/lato/templates/approvals.md @@ -1,49 +1,35 @@ # Approvals -**System Owner** +## System Owner




-{% set owners = ssp.system_characteristics.responsible_parties | parties_for_role("system-owner", ssp) | list %} -{% if owners | count > 0 %} -{{ owners[0].name }} -{% else %} -[Name] -{% endif %} +{% set owner = ssp.system_characteristics.responsible_parties | parties_for_role("system-owner", ssp) | first_or_none %} +{{ owner.name | default('[Name]') }}
System Owner -**Information System Security Officer** +## Information System Security Officer




-{% set isso = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-officer", ssp) | list %} -{% if isso | count > 0 %} -{{ isso[0].name }} -{% else %} -[Name] -{% endif %} +{% set isso = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-officer", ssp) | first_or_none %} +{{ isso.name | default('[Name]') }}
Information System Security Officer -**Information System Security Manager** +## Information System Security Manager




-{% set issm = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-manager", ssp) | list %} -{% if issm | count > 0 %} -{{ issm[0].name }} -{% else %} -[Name] -{% endif %} +{% set issm = ssp.system_characteristics.responsible_parties | parties_for_role("information-system-security-manager", ssp) | first_or_none %} +{{ issm.name | default('[Name]') }}
Information System Security Manager - -
diff --git a/templates/ssp-rendering/lato/templates/frontmatter.md b/templates/ssp-rendering/lato/templates/frontmatter.md index 860866a..e460f20 100644 --- a/templates/ssp-rendering/lato/templates/frontmatter.md +++ b/templates/ssp-rendering/lato/templates/frontmatter.md @@ -1,5 +1,3 @@ -
- # U.S. General Services Administration # {{ ssp.system_characteristics.system_name }} ({{ ssp.system_characteristics.system_name_short }}) @@ -9,33 +7,22 @@ ![GSAIT Logo](./img/gsa_it_logo.png) -
- -
- -Document Prepared By - - +## Document Prepared By {% for party in ssp.metadata.responsible_parties | parties_for_role("prepared-by", ssp) %} - - - + +| | | +| - | - | +| **{{ party.type.value | title }} Name** | {{ party.name }} | {% set address = party.addresses | first_or_none %} {% for addr_line in address.addr_lines | as_list %} - - - +| **Address Line {{ loop.index }}** | {{ addr_line }} | {% endfor %} - - - +{% if address %} +| **City, State Zip** | {{ address.city }}, {{ address.state }} {{ address.postal_code }} | +{% endif %} {% endfor %} - -
{{ party.type.value.title() }} Name{{ party.name }}
Address Line {{ loop.index }}{{ addr_line }}
City, State Zip{{ address.city }}, {{ address.state }} {{ address.postal_code }}
- -
-Document Revision History +## Document Revision History {% set prepared_by = ssp.metadata.responsible_parties | parties_for_role("prepared-by", ssp) | first_or_none %} | Date | Comments | Version | Author | @@ -44,5 +31,3 @@ Document Revision History {% set revision_prepared_by = control_interface.get_prop(revision, "prepared-by") | get_party(ssp) | get_default(prepared_by) %} | {{ revision.last_modified.strftime('%Y-%m-%d') if revision.last_modified else '' }} | {{ revision.title }} | {{ revision.version }} | {{ revision_prepared_by.name }} | {% endfor %} - -
diff --git a/templates/ssp-rendering/lato/templates/gsa_template.md.jinja b/templates/ssp-rendering/lato/templates/gsa_template.md.jinja index 5d3c60d..90da9a0 100644 --- a/templates/ssp-rendering/lato/templates/gsa_template.md.jinja +++ b/templates/ssp-rendering/lato/templates/gsa_template.md.jinja @@ -1,11 +1,3 @@ - - {% md_clean_include 'ssp-render/templates/frontmatter.md' heading_level=1 %} {% md_clean_include 'ssp-render/templates/guidance.md' %} @@ -14,8 +6,6 @@ -
- {% md_clean_include 'ssp-render/templates/approvals.md' heading_level=1 %} {% md_clean_include 'ssp-render/templates/section_1.md' heading_level=1 %} diff --git a/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md b/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md index 6c5fe35..45862f2 100644 --- a/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md +++ b/templates/ssp-rendering/lato/templates/partials/poc_contact_table.md @@ -1,28 +1,14 @@ - - - - - - - - - {% set organization = party.member_of_organizations | first_or_none | get_party(ssp) %} - - - - - - - - - - - - -
Name{{ party.name }}
Title{{ control_interface.get_prop(party, 'title') }}
Organization{{ organization.name }}
Address {% set address = organization.addresses | first_or_none %} +| | | +| - | - | +| **Name** | {{ party.name }} | +| **Title** | {{ control_interface.get_prop(party, 'title') }} | +| **Organization** | {{ organization.name }} | {% if address %} -{{ address.addr_lines | as_list | join(' ') }} {{ address.city }}, {{ address.state }} {{ address.postal_code }} +| **Address** | {{ address.addr_lines | as_list | join(' ') }} {{ address.city }}, {{ address.state }} {{ address.postal_code }} | +{% else %} +| **Address** | | {% endif %} -
Phone Number{{ (party.telephone_numbers | first_or_none).number }}
Email Address{{ (party.email_addresses | first_or_none).__root__ }}
+| **Phone Number** | {{ (party.telephone_numbers | first_or_none).number }} | +| **Email Address** | {{ (party.email_addresses | first_or_none).__root__ }} |