Behaviour for red-team attack generators.
A plugin produces a list of adversarial test cases targeted at a specific
failure mode (policy violations, prompt extraction, hijacking, etc.). Each
generated case is a regular Tribunal dataset entry with metadata identifying
the plugin and an expected clause naming the assertion to run against the
target's response.
Implementing a plugin
defmodule MyApp.RedTeam.Plugins.Custom do
@behaviour Tribunal.RedTeam.Plugin
@impl true
def id, do: :custom
@impl true
def severity, do: :medium
@impl true
def generate(opts) do
# ...
{:ok, [%{input: ..., metadata: ..., expected: ...}, ...]}
end
endBuilt-in plugins live under Tribunal.RedTeam.Plugins.*. Custom plugins are
registered via:
config :tribunal, :red_team_plugins, [MyApp.RedTeam.Plugins.Custom]
Summary
Functions
Returns the list of registered plugin ids.
Returns all plugin modules (built-in + custom).
Returns built-in plugin modules.
Returns custom plugin modules registered via application config.
Extracts and validates the attacker's attacks list.
Fetches required options, returning a friendly error instead of raising.
Finds a plugin module by its id/0 value.
Types
Callbacks
Functions
Returns the list of registered plugin ids.
Returns all plugin modules (built-in + custom).
Returns built-in plugin modules.
Returns custom plugin modules registered via application config.
Extracts and validates the attacker's attacks list.
Accepts the attacker response with an attacks list keyed by either string
or atom. Every attack must carry a non-empty prompt; otherwise the whole
batch is rejected with {:error, {:invalid_attack, attack}} rather than
emitting a case with input: nil. An unrecognised shape returns
{:error, {:unexpected_attacker_response, other}}.
Fetches required options, returning a friendly error instead of raising.
Returns {:ok, values} with values in the same order as keys, or
{:error, {:missing_options, missing}} listing every absent key. Plugins
use this in generate/1 so a missing required option surfaces as a
{:error, _} the caller can handle, rather than a raw KeyError.
Finds a plugin module by its id/0 value.
Returns {:ok, module} or :error.