Skip to content

Commit

Permalink
Operation hardening guide DOCS
Browse files Browse the repository at this point in the history
testingGuide POC
  • Loading branch information
DavidCervigni committed Mar 11, 2024
1 parent f8ba07a commit 23dd4a9
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python: Module createtickets",
"type": "python",
Expand Down Expand Up @@ -253,6 +254,26 @@
"CordaHardeningGuide"
]
},
{
"name": "Corda Testing Guide ",
"type": "python",
"request": "launch",
"module": "r3threatmodeling.report_generator",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"--rootTMYaml",
"../Corda5ThreatModels/threatModels/C5/C5.yaml",
"--TMID",
"C5",
"--outputDir",
"../Corda5ThreatModels/build/generated_reports/C5",
"--template",
"testingGuide",
"--baseFileName",
"TestingGuide"
]
},
{
"name": "Corda Keys summary report ",
"type": "python",
Expand Down
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,49 @@ It is possible to tell via YAML to what versions a specific asset, threat or cou
This information will be used in two ways:

1. The ``appliesToVersions`` information will be displayed in the report
2. By adding the parameters ``"--versionsFilter" "5.0,5.1"`` to the report generator, the report will not show the assets, threat and countermeasures that do not match the list of versions provided as parameter. See [https://pypi.org/project/semantic-version/]() for more info on the versions format
2. By adding the parameters ``"--versionsFilter" "5.0,5.1"`` to the report generator, the report will not show the assets, threat and countermeasures that do not match the list of versions provided as parameter. See [https://pypi.org/project/semantic-version/]() for more info on the versions format

### Operation hardening guide

The template system also creates a Security Hardening Guideline. It collects all the operational countermeasures `operational: true` grouping it by operator `operator: ADMIN`.
An operational countermeasure is something an operator (same as threat model defined actors/attackers) needs to do to prevent a threat; it is not a enabled by default/coded feature (`operational: false`).

To make the *Operation hardening guide* readable the title and description of an operational countermeasure should precisely answer to the question "what the operator needs to do (and why, how ...)" instead of a desired state of things or other phrasing.

For example, this phrasing may be not optimal to generate the most useful Hardening guide
```yaml
threats:
- ID: ACCIDENTAL_DATA_LOSS
title: Data from the main DataBase is lost ...
[...]
countermeasures:
- ID: DATA_BACKUP
title: Data backup allows to restore the production system...
description: |
To restore data after an incident Backups allows...
operational: false
operator: INFRASTRUCTURE_OPERATOR
inPlace: true
public: true
```

We can rephrase it in as way `title:` and `description:` refers to a precise action:


```yaml
threats:
- ID: ACCIDENTAL_DATA_LOSS
title: Data from the main DataBase is lost ...
[...]
countermeasures:
- ID: DATA_BACKUP
title: Perform data backup
description: |
The infrastructure operator performs regular backup in an separate network and those backup are secured with encryption....
operational: false
operator: INFRASTRUCTURE_OPERATOR
inPlace: true
public: true
```
2 changes: 1 addition & 1 deletion src/r3threatmodeling/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def processSingleTMID(tmoRoot, TMID, args):
if tmoRoot._id == rootID:
tmo = tmoRoot
else:
raise Exception('root id: '+ rootID +' not recognized, should be : '+tmoRoot._id)
raise Exception('parameter root id: '+ rootID +' not recognized, should be : '+tmoRoot._id)


for idPathPart in TMID.split('.')[1:]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<% dataModel = tmo.getOperationalGuideData() %>

${makeMarkdownLinkedHeader(1, 'Corda NextGen operational security hardening guides', skipTOC = False)}
${makeMarkdownLinkedHeader(1, 'Operational security hardening guides', skipTOC = False)}

% if printTOC:
__TOC_PLACEHOLDER__
Expand Down
40 changes: 40 additions & 0 deletions src/r3threatmodeling/template/testingGuide.mako
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%! import html %>
<%! from r3threatmodeling.template_utils import createTitleAnchorHash, makeMarkdownLinkedHeader, mermaid_escape, valueOr %>
<%page args="printTOC=True"/>
<% PAGEBREAK = """<div class="pagebreak"></div>"""%>
<% H6 = "######" %>
<%namespace name="lib" file="lib.mako"/>

## <% dataModel = tmo.getOperationalGuideData() %>

${makeMarkdownLinkedHeader(1, 'Testing guide', skipTOC = False)}


This guide lists all testable attacks described in the threat model

<table>
<tr><th>Seq</th><th>Test ID</th><th>Attack to test</th><th>Pass/Fail/NA</th></tr>
<tr>

<%
ts = [t for t in tmo.getAllDown('threats') if ( hasattr(t, 'pentestTestable') and t.pentestTestable is True)]
%>

% for idx, threat in enumerate(ts):

## ${makeMarkdownLinkedHeader(3, threat.ID + " Test")}
<td>${idx+1}</td><td> ${threat.ID}</td>
<td>${threat.attack}
% if hasattr(threat, 'conditional'):
\n**Valid when:** ${threat.conditional}
% endif
</td>
<td></td>

</tr>
% endfor # threats
</table>




7 changes: 7 additions & 0 deletions src/r3threatmodeling/threatmodel_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,13 @@ def getAssetsByProps(self, **kwargs ):
return res


# def getOperationalGuideData(self):

# #TODO group threats by attack vector (represented by dataflow)
# guideData = {}
# return guideData


def getOperationalGuideData(self):

guideData = {}
Expand Down

0 comments on commit 23dd4a9

Please sign in to comment.