Skip to content

Commit

Permalink
demo: Alice: Generate THREATS.md
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Jun 11, 2022
1 parent fa0ee27 commit c027d4e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
16 changes: 16 additions & 0 deletions auditor_overlay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys
import json
import unittest.mock

import dffml

from auditor import audit as untyped_audit
from parser import parse


@dffml.op
def audit(ltm: str) -> list:
return untyped_audit(parse(ltm))


AUDITOR_OVERLAY = dffml.DataFlow(*dffml.opimp_in(sys.modules[__name__]))
22 changes: 22 additions & 0 deletions auditor_overlay.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
definitions:
ThreatDragonThreatModelPath:
name: ThreatDragonThreatModelPath
primitive: str
auditor_overlay:audit.outputs.result:
name: auditor_overlay:audit.outputs.result
primitive: array
flow:
auditor_overlay:audit:
inputs:
ltm:
- seed
linked: true
operations:
auditor_overlay:audit:
inputs:
ltm: ThreatDragonThreatModelPath
name: auditor_overlay:audit
outputs:
result: auditor_overlay:audit.outputs.result
retry: 0
stage: processing
51 changes: 51 additions & 0 deletions demo/ALICE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Living THREATS.md
#################

Install Alice https://github.com/pdxjohnny/dffml/tree/manifest/entities/alice

Create the ``THREATS.md`` file

.. code-block:: console
$ alice threats \
-inputs \
models/good.json=ThreatDragonThreatModelPath \
models/GOOD_THREATS.md=ThreatsMdPath
We made ``auditor_overlay.py`` which is a data flow which calls the auditor. We
use ``sed`` to direct the data flow to run on the path to the threat model from
Threat Dragon used as input.

.. code-block:: console
$ dffml service dev export auditor_overlay:AUDITOR_OVERLAY \
-configloader yaml \
| sed -e 's/auditor_overlay:audit.inputs.ltm/ThreatDragonThreatModelPath/g' \
| tee auditor_overlay.yaml
Generate ``GOOD_THREATS.md`` with auditing overlay.

.. code-block:: console
$ alice threats -log debug \
-overlay auditor_overlay.yaml \
-inputs \
models/good.json=ThreatDragonThreatModelPath \
models/GOOD_THREATS.md=ThreatsMdPath
Generate ``BAD_THREATS.md`` with auditing overlay.

.. code-block:: console
$ alice threats -log debug \
-overlay auditor_overlay.yaml \
-inputs \
models/bad.json=ThreatDragonThreatModelPath \
models/BAD_THREATS.md=ThreatsMdPath
Dump out to HTTP to copy to GitHub for rendering.

.. code-block:: console
$ (echo -e 'HTTP/1.0 200 OK\n' && cat models/GOOD_THREATS.md) | nc -Nlp 9999;
$ (echo -e 'HTTP/1.0 200 OK\n' && cat models/BAD_THREATS.md) | nc -Nlp 9999;

0 comments on commit c027d4e

Please sign in to comment.