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

Switch to jinja filters in ssp markdown #45

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
32 changes: 9 additions & 23 deletions templates/ssp-rendering/lato/templates/approvals.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@

# Approvals

**System Owner**
## System Owner
<br>
<br>
<br>
<br>
<div style="width:400px"><hr style="border-top:solid 2px #333 !important;color:#333;background-color:#333;" /></div>
{% set owners = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "system-owner") | 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]') }}
<br>
System Owner

**Information System Security Officer**
## Information System Security Officer
<br>
<br>
<br>
<br>
<div style="width:400px"><hr style="border-top:solid 2px #333 !important;color:#333;background-color:#333;" /></div>
{% set isso = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-officer") | 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]') }}
Comment on lines -25 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are much easier to read 👍🏼

<br>
Information System Security Officer

**Information System Security Manager**
## Information System Security Manager
<br>
<br>
<br>
<br>
<div style="width:400px"><hr style="border-top:solid 2px #333 !important;color:#333;background-color:#333;" /></div>
{% set issm = ssp_interface.get_parties_for_role(ssp.system_characteristics.responsible_parties, "information-system-security-manager") | 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]') }}
<br>
Information System Security Manager

<div class="pagebreak"></div>
49 changes: 16 additions & 33 deletions templates/ssp-rendering/lato/templates/frontmatter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<center>

# U.S. General Services Administration

# {{ ssp.system_characteristics.system_name }} ({{ ssp.system_characteristics.system_name_short }})
Expand All @@ -9,42 +7,27 @@

![GSAIT Logo](./img/gsa_it_logo.png)

</center>

<div class="pagebreak"></div>
## Document Prepared By
{% for party in ssp.metadata.responsible_parties | parties_for_role("prepared-by", ssp) %}

Document Prepared By
<table>
<tbody>
{% for party in ssp_interface.get_parties_for_role(ssp.metadata.responsible_parties, "prepared-by") %}
<tr>
<th scope="row">{{ party.type.value.title() }} Name</th><td>{{ party.name }}</td>
</tr>
<tr>
{% set address = ssp_interface.first_array_entry(party.addresses) %}
{% set addr_lines = ssp_interface.safe_retrieval(address, "addr_lines", []) %}
<th scope="row">Address Line 1</th><td>{{ addr_lines[0] }}</td>
</tr>
<tr>
<th scope="row">Address Line 2</th><td>{{ addr_lines[1] }}</td>
</tr>
<tr>
<th scope="row">City, State Zip</th><td>{{ ssp_interface.safe_retrieval(address, "city") }}, {{ ssp_interface.safe_retrieval(address, "state") }} {{ ssp_interface.safe_retrieval(address, "postal_code") }}</td>
</tr>
| | |
| - | - |
| **{{ 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 }} |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: are these 1 indexed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

{% endfor %}
{% if address %}
| **City, State Zip** | {{ address.city }}, {{ address.state }} {{ address.postal_code }} |
{% endif %}
{% endfor %}
</tbody>
</table>

<div class="pagebreak"></div>

Document Revision History
## 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 %}

<div class="pagebreak"></div>
10 changes: 0 additions & 10 deletions templates/ssp-rendering/lato/templates/gsa_template.md.jinja
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<style>
@media print {
.pagebreak {
break-after: page
}
}
</style>

{% md_clean_include 'ssp-render/templates/frontmatter.md' heading_level=1 %}

{% md_clean_include 'ssp-render/templates/guidance.md' %}
Expand All @@ -14,8 +6,6 @@

<TableOfContents />

<div class="pagebreak"></div>

{% md_clean_include 'ssp-render/templates/approvals.md' heading_level=1 %}

{% md_clean_include 'ssp-render/templates/section_1.md' heading_level=1 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
<table>
<tbody>
<tr>
<th scope="row">Name</th><td>{{ party.name }}</td>
</tr>
<tr>
<th scope="row">Title</th><td>{{ control_interface.get_prop(party, 'title') }}</td>
</tr>
<tr>
{% set organization = ssp_interface.get_party_by_uuid(ssp_interface.first_array_entry(party.member_of_organizations)) %}
<th scope="row">Organization</th><td>{{ ssp_interface.safe_retrieval(organization, "name") }}</td>
</tr>
<tr>
<th scope="row">Address</th><td>
{% if organization and organization.addresses %}
{% set address = ssp_interface.first_array_entry(organization.addresses) %}
{% set organization = party.member_of_organizations | first_or_none | get_party(ssp) %}
{% set address = organization.addresses | first_or_none %}
| | |
| - | - |
| **Name** | {{ party.name }} |
| **Title** | {{ control_interface.get_prop(party, 'title') }} |
| **Organization** | {{ organization.name }} |
{% if address %}
{{ ssp_interface.safe_retrieval(address, 'addr_lines', []) | 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 %}
{% endif %}
</td>
</tr>
<tr>
<th scope="row">Phone Number</th><td>{{ ssp_interface.first_array_entry(party.telephone_numbers, "number") }}</td>
</tr>
<tr>
<th scope="row">Email Address</th><td>{{ ssp_interface.first_array_entry(party.email_addresses, "__root__") }}</td>
</tr>
</tbody>
</table>
| **Phone Number** | {{ (party.telephone_numbers | first_or_none).number }} |
| **Email Address** | {{ (party.email_addresses | first_or_none).__root__ }} |
4 changes: 2 additions & 2 deletions templates/ssp-rendering/lato/templates/section_10.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})
<br/>Figure 10-{{loop.index}}. Data Flow Diagram
{% endfor %}

Expand Down
2 changes: 1 addition & 1 deletion templates/ssp-rendering/lato/templates/section_3.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 +%}
2 changes: 1 addition & 1 deletion templates/ssp-rendering/lato/templates/section_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 +%}
4 changes: 2 additions & 2 deletions templates/ssp-rendering/lato/templates/section_5.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 +%}
2 changes: 1 addition & 1 deletion templates/ssp-rendering/lato/templates/section_6.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 +%}
4 changes: 2 additions & 2 deletions templates/ssp-rendering/lato/templates/section_9.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})
<br/>Figure 9-{{loop.index}}. Network Diagram
{% endfor %}