Skip to content

Commit

Permalink
update index layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbr3 committed Sep 15, 2023
1 parent eb656dc commit b4e427f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
20 changes: 19 additions & 1 deletion src/r3threatmodeling/fullBuildDirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generateIndexPage(tm_list, outputDir):
, output_encoding='utf-8', preprocessor=[lambda x: x.replace("\r\n", "\n")]
))

outText = mdTemplate.render(tm_list=tm_list)
outText = mdTemplate.render(tm_list=tm_list, outputDir=outputDir)
outputFilename = outMDPath = os.path.join(outputDir, "index.html")
with open(outputFilename, 'w') as f:
print(f"OUTPUT: {f.name}")
Expand Down Expand Up @@ -123,6 +123,24 @@ def main():
TMDir = args.TMDirectory

tm_list = [{'name':f.stem, 'path':str(f)} for f in pathlib.Path(TMDir).glob("*/*.yaml") if pathlib.Path(f).parent.name == pathlib.Path(f).stem]

tm_list = []#{'name':f.stem, 'path':str(f)}
for f in pathlib.Path(TMDir).glob("*/*.yaml"):
if pathlib.Path(f).parent.name == pathlib.Path(f).stem:
#tm_list
path = str(f)
name = f.stem
print(path)
import yaml
tm = yaml.safe_load(open(f))
title = tm['title']
version = tm['version']
pdfname = f'{title} Threat Model-{version}.pdf'
pdfname = re.sub('[^\w_.)(_-]', '_', pdfname) # replace invalid chars with underscore

tm_list.append({'name': name, 'path': path, 'title': title, 'pdf':pdfname})

print(tm_list)

generateIndexPage(tm_list, outputDir)

Expand Down
32 changes: 25 additions & 7 deletions src/r3threatmodeling/template/index_tm_list.mako
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,35 @@
2023.v1-DRAFT (ZIP file containing PDF)
</a>

% for tm in tm_list:
<h2>Latest SNAPSHOT</h2>


<h2>Latest SNAPSHOT</h2>
Latest published SNAPSHOT: __VERSION__ <br/>
Generated on: __TIMEGEN__
<p><a href="${tm['path']}/${tm['name']}.html">HTML version</a></p><br/>
<p><a href="__PDF_FILENAME__">PDF version</a></p><br/>
<p><a href="https://github.com/corda/threat-modeling/blob/master/threatModels/${tm['name']}">Source (yaml)</a></p><br/>
<p><a href="CordaHardeningGuide.html">Security hardening operational guides (PoC)</a></p><br/>
<p><a href="keysSummary.html">Keys and crypto sensitive assets summary report annex(PoC)</a></p><br/>

<table>
<thead>
<tr>
<th>Threat Model</th><th>PDF Report</th><th>Source</th><th>Hardening Guide</th><th>Key Summary</th>
</tr>
</thead>
<tbody>
% for tm in tm_list:
<%
tmOutputDir = tm['name']
tmName = tm['name']
tmPDF = tm['pdf']
%>
<tr>
<td><a href="${tmOutputDir}/${tmName}.html">${tmName}</a></td>
<td><a href="${tmOutputDir}/${tmPDF}">${tmPDF}</a></td>
<td><a href="https://github.com/corda/threat-modeling/blob/master/threatModels/${tm['name']}">Source (yaml)</a></td>
<td><a href="${tmOutputDir}/SecurityGuide.html">Security hardening guide (${tmName})</a></td>
<td><a href="${tmOutputDir}/KeysSummary.html">Keys summary (${tmName})</a></td>
</tr>
% endfor
</tbody>
</table>

</body>
</html>

0 comments on commit b4e427f

Please sign in to comment.