Experimental Livebook-friendly DSL for sketching STRIDE threat models.
This Lab DSL compiles to the stable, pipe-first Choreo.ThreatModel builders
and returns an ordinary %Choreo.ThreatModel{}. It is intentionally small: use
it to sketch external entities, processes, data stores, trust boundaries, and
data flows quickly, then use Choreo.ThreatModel.Analysis explicitly for the
real security review.
Examples
iex> import Choreo.Lab.DSL.ThreatModel
...> model = threat_model do
...> internet = boundary("Internet", level: 0)
...> app = boundary("Application", level: 2)
...> data = boundary("Data", level: 3)
...>
...> user = external_entity("User", boundary: internet)
...> api = process("API Gateway", boundary: app, privilege: :user)
...> db = data_store("Tenant DB", boundary: data, sensitivity: :confidential)
...>
...> user ~> api |> encrypted("HTTPS request", protocol: :https)
...> api ~> db |> flow("Reads tenant config", protocol: :sql)
...> end
iex> Enum.sort(Choreo.ThreatModel.elements(model))
[:api, :db, :user]
iex> Choreo.ThreatModel.boundary_of(model, :api)
"app"
iex> edges = Choreo.ThreatModel.edges_with_meta(model)
iex> Enum.any?(edges, fn {from, to, _, meta} -> from == :api and to == :db and meta.protocol == :sql end)
true
iex> Enum.any?(edges, fn {from, to, _, meta} -> from == :user and to == :api and meta.encrypted end)
trueEdges can use generic, typed, or pipe-modified forms:
user ~> api
user ~> api |> encrypted("HTTPS request", protocol: :https)
flow api ~> db, "SQL query", protocol: :sql
unencrypted worker ~> queue, "plain queue message"
Summary
Functions
Returns the vocabulary supported by the threat-model DSL.
Builds a %Choreo.ThreatModel{} from a compact Lab DSL block.
Compatibility alias for taxonomy/0.
Functions
@spec taxonomy() :: %{ boundaries: [atom()], nodes: [atom()], edges: [atom()], modifiers: [atom()], options: [atom()] }
Returns the vocabulary supported by the threat-model DSL.
iex> taxonomy = Choreo.Lab.DSL.ThreatModel.taxonomy()
iex> :boundary in taxonomy.boundaries
true
iex> :process in taxonomy.nodes
true
iex> :encrypted in taxonomy.modifiers
true
Builds a %Choreo.ThreatModel{} from a compact Lab DSL block.
@spec verbs() :: map()
Compatibility alias for taxonomy/0.