Skip to content

Commit

Permalink
Add latest STIG Path
Browse files Browse the repository at this point in the history
Add path that always links to the newest STIG
  • Loading branch information
Mab879 committed Sep 16, 2023
1 parent c313929 commit 7a0265e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stigaview_static/html_output.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os.path
import shutil
from multiprocessing import Process

from jinja2 import Environment, FileSystemLoader
Expand All @@ -23,6 +24,7 @@ def render_product(product: models.Product, out_path: str):
real_out_path = render_stig_detail(out_product, product, stig)
for control in stig.controls:
render_control(control, real_out_path)
_copy_latest_stig(out_product, product)


def render_stig_detail(out_product, product, stig):
Expand Down Expand Up @@ -111,3 +113,12 @@ def render_srg_details(srgs: dict, out_path: str) -> None:
os.makedirs(full_out_path, exist_ok=True)
full_out = os.path.join(full_out_path, "index.html")
render_template("srg_detail.html", full_out, controls=controls, srg_id=srg_id)


def _copy_latest_stig(out_product: str, product: models.Product):
latest_stig = product.latest_stig
current_versioned_root = os.path.join(
out_product, latest_stig.short_version.lower()
)
product_latest_path = os.path.join(out_product, "latest")
shutil.copytree(current_versioned_root, product_latest_path)
5 changes: 5 additions & 0 deletions stigaview_static/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,8 @@ def __gt__(self, other):
@property
def url(self) -> str:
return f"/products/{self.short_name}"

@property
def latest_stig(self) -> Stig:
self.sort_stigs()
return self.stigs[-1]
1 change: 1 addition & 0 deletions templates/product.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% block content %}
<h1>{{ product.full_name }} ({{ product.short_name }})</h1>
<a href="{{ product.url }}/latest">View the latest STIG</a>
<table class="table">
<thead>
<tr>
Expand Down

0 comments on commit 7a0265e

Please sign in to comment.