# `Choreo.Lab.DSL.ThreatModel`
[🔗](https://github.com/code-shoily/choreo/blob/v0.14.1/lib/choreo/lab/dsl/threat_model.ex#L1)

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)
    true

Edges 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"

# `actor`

# `api`

# `authenticated`

# `boundary`

# `bucket`

# `cache`

# `carries`

# `client`

# `controls`

# `data_flow`

# `data_store`

# `database`

# `db`

# `edge`

# `encrypted`

# `external`

# `external_entity`

# `flow`

# `function`

# `label`

# `on`

# `process`

# `protects`

# `protocol`

# `queue`

# `reads`

# `sends`

# `sensitivity`

# `service`

# `store`

# `taxonomy`

```elixir
@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
    iex> :authenticated in taxonomy.modifiers
    true

# `third_party`

# `threat_model`
*macro* 

Builds a `%Choreo.ThreatModel{}` from a compact Lab DSL block.

# `threat_model`
*macro* 

# `trust_boundary`

# `unencrypted`

# `user`

# `verbs`

```elixir
@spec verbs() :: map()
```

Compatibility alias for `taxonomy/0`.

# `worker`

# `writes`

# `zone`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
