Skip to content

Commit 68ab023

Browse files
feat(cli): unified run.spec plugin selection grammar; deprecate --probes/--probe_tags/--buffs
Signed-off-by: Patricia Pampanelli <ppampanelli@nvidia.com>
1 parent 7d6ca53 commit 68ab023

19 files changed

Lines changed: 1097 additions & 156 deletions

docs/source/_spec.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
run.spec selection grammar
2+
===========================
3+
4+
5+
``garak/_spec.py`` implements the unified ``run.spec`` selection grammar: a
6+
single internal ``Spec`` (a list of ``Selector`` with explicit polarity) that
7+
both transports parse to.
8+
9+
* CLI string (comma separated), via ``parse_spec_string``
10+
* config file form (YAML/JSON ``include``/``exclude`` lists), via ``parse_spec_file``
11+
12+
Selectors carry a category-prefixed plugin path (``probes.<module>[.<Class>]``,
13+
``buffs.<module>[.<Class>]``) or a probe filter (``tag:<prefix>``,
14+
``tier:<N|name>``). A leading ``-`` excludes; ``tier:N`` is inclusive
15+
("log level": tiers ``1..N``). ``Spec.resolve()`` orchestrates probe and buff
16+
selection plus the filters; the single plugin-path resolution core,
17+
``_resolve_plugin_paths``, is shared with the ``parse_plugin_spec`` adapter used
18+
for detectors.
19+
20+
See :doc:`configurable` for the user-facing grammar and examples.
21+
22+
23+
Code
24+
^^^^
25+
26+
27+
garak._spec
28+
-----------
29+
30+
.. automodule:: garak._spec
31+
:members:
32+
:undoc-members:
33+
:show-inheritance:

docs/source/cliref.rst

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CLI reference for garak
33

44
::
55

6-
garak LLM vulnerability scanner v0.15.1.pre1 ( https://github.com/NVIDIA/garak ) at 2026-05-01T13:01:25.835551
6+
garak LLM vulnerability scanner v0.15.1.pre1 ( https://github.com/NVIDIA/garak ) at 2026-06-02T11:24:39.583036
77
usage: python -m garak [-h] [--verbose] [--report_prefix REPORT_PREFIX]
88
[--narrow_output]
99
[--parallel_requests PARALLEL_REQUESTS]
@@ -12,15 +12,15 @@ CLI reference for garak
1212
[--eval_threshold EVAL_THRESHOLD]
1313
[--generations GENERATIONS] [--config CONFIG]
1414
[--target_type TARGET_TYPE] [--target_name TARGET_NAME]
15-
[--probes PROBES] [--probe_tags PROBE_TAGS]
16-
[--detectors DETECTORS] [--extended_detectors]
17-
[--buffs BUFFS]
15+
[--run-spec RUN_SPEC] [--probes PROBES]
16+
[--probe_tags PROBE_TAGS] [--detectors DETECTORS]
17+
[--extended_detectors] [--buffs BUFFS]
1818
[--buff_option_file BUFF_OPTION_FILE | --buff_options BUFF_OPTIONS]
1919
[--detector_option_file DETECTOR_OPTION_FILE | --detector_options DETECTOR_OPTIONS]
2020
[--generator_option_file GENERATOR_OPTION_FILE | --generator_options GENERATOR_OPTIONS]
2121
[--harness_option_file HARNESS_OPTION_FILE | --harness_options HARNESS_OPTIONS]
2222
[--probe_option_file PROBE_OPTION_FILE | --probe_options PROBE_OPTIONS]
23-
[--taxonomy TAXONOMY]
23+
[--intents INTENTS] [--taxonomy TAXONOMY]
2424
[--confidence_interval_method {bootstrap,none}]
2525
[--bootstrap_num_iterations BOOTSTRAP_NUM_ITERATIONS]
2626
[--bootstrap_confidence_level BOOTSTRAP_CONFIDENCE_LEVEL]
@@ -29,9 +29,9 @@ CLI reference for garak
2929
[--list_detectors] [--list_generators] [--list_buffs]
3030
[--list_config] [--version] [--report REPORT]
3131
[--interactive] [--fix]
32-
32+
3333
LLM safety & security scanning tool
34-
34+
3535
options:
3636
-h, --help show this help message and exit
3737
--verbose, -v add one or more times to increase verbosity of output
@@ -60,20 +60,28 @@ CLI reference for garak
6060
--target_name TARGET_NAME, --model_name TARGET_NAME, -n TARGET_NAME
6161
name of the target, e.g.
6262
'timdettmers/guanaco-33b-merged'
63+
--run-spec RUN_SPEC, --run_spec RUN_SPEC
64+
unified selection spec, e.g. 'probes.dan,
65+
-dan.DanInTheWild, tag:owasp:llm01'. Selectors:
66+
probes.<module>[.<Class>], buffs.<module>[.<Class>],
67+
tag:<prefix>, tier:<N|name>; '-' excludes, tier:N is
68+
inclusive (tiers 1..N).
6369
--probes PROBES, -p PROBES
64-
list of probe names to use, or 'all' for all
65-
(default).
70+
DEPRECATED, use --run-spec. list of probe names to
71+
use, or 'all'.
6672
--probe_tags PROBE_TAGS
67-
only include probes with a tag that starts with this
68-
value (e.g. owasp:llm01)
73+
DEPRECATED, use --run-spec 'tag:<value>'. only include
74+
probes with a tag starting with this value (e.g.
75+
owasp:llm01)
6976
--detectors DETECTORS, -d DETECTORS
7077
list of detectors to use, or 'all' for all. Default is
7178
to use the probe's suggestion.
7279
--extended_detectors If detectors aren't specified on the command line,
7380
should we run all detectors? (default is just the
7481
primary detector, if given, else everything)
7582
--buffs BUFFS, -b BUFFS
76-
list of buffs to use. Default is none
83+
DEPRECATED, use --run-spec 'buffs.<name>'. list of
84+
buffs to use. Default is none
7785
--buff_option_file BUFF_OPTION_FILE, -B BUFF_OPTION_FILE
7886
path to JSON file containing options to pass to buff
7987
--buff_options BUFF_OPTIONS
@@ -97,6 +105,9 @@ CLI reference for garak
97105
path to JSON file containing options to pass to probe
98106
--probe_options PROBE_OPTIONS
99107
options to pass to probe, formatted as a JSON dict
108+
--intents INTENTS, -i INTENTS
109+
comma-separated list of intents & intent prefixes to
110+
use. Default is empty, for all
100111
--taxonomy TAXONOMY specify a MISP top-level taxonomy to be used for
101112
grouping probes in reporting. e.g. 'avid-effect',
102113
'owasp'
@@ -134,5 +145,5 @@ CLI reference for garak
134145
--fix Update provided configuration with fixer migrations;
135146
requires one of --config / --*_option_file, /
136147
--*_options
137-
148+
138149
See https://github.com/NVIDIA/garak

docs/source/configurable.rst

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,20 @@ Let's take a look at the core config.
5757
deprefix: true
5858
eval_threshold: 0.5
5959
generations: 5
60-
probe_tags:
60+
spec:
61+
include:
62+
- probes.dan
63+
- tag: owasp:llm01
64+
exclude:
65+
- probes.dan.DanInTheWild
6166
user_agent: "garak/{version} (LLM vulnerability scanner https://garak.ai)"
6267
soft_probe_prompt_cap: 256
6368
6469
plugins:
6570
target_type:
6671
target_name:
67-
probe_spec: all
6872
detector_spec: auto
6973
extended_detectors: false
70-
buff_spec:
7174
buffs_include_original_prompt: false
7275
buff_max:
7376
detectors: {}
@@ -123,7 +126,7 @@ Run Config Items
123126
""""""""""""""""
124127

125128
* ``system_prompt`` -- If given and not overriden by the probe itself, probes will pass the specified system prompt when possible for generators that support chat modality.
126-
* ``probe_tags`` - If given, the probe selection is filtered according to these tags; probes that don't match the tags are not selected
129+
* ``spec`` - The unified selection spec for probes and buffs (``run.spec``); see "Selecting probes and buffs with run.spec" below. If absent, the default is all active probes (``probes.*``)
127130
* ``generations`` - How many times to send each prompt for inference
128131
* ``deprefix`` - Remove the prompt from the start of the output (some models return the prompt as part of their output)
129132
* ``seed`` - An optional random seed
@@ -138,11 +141,15 @@ Plugins Config Items
138141

139142
* ``target_type`` - The type of target generator, e.g. "nim" or "huggingface"
140143
* ``target_name`` - The specific name of the target to be used (optional - if blank, type-specific default is used)
141-
* ``probe_spec`` - A comma-separated list of probe modules or probe classnames (in ``module.classname``) format to be used. If a module is given, only ``active`` plugin in that module are chosen, this is equivalent to passing `-p` to the CLI
142144
* ``detector_spec`` - An optional spec of detectors to be used, if overriding those recommended in probes. Specifying ``detector_spec`` means the ``pxd`` harness will be used. This is equivalent to passing `-d` to the CLI
143145
* ``extended_detectors`` - Should just the primary detector be used per probe, or should the extended detectors also be run? The former is fast, the latter thorough.
144-
* ``buff_spec`` - Comma-separated list of buffs and buff modules to use; same format as ``probe_spec``.
145146
* ``buffs_include_original_prompt`` - When buffing, should the original pre-buff prompt still be included in those posed to the model?
147+
148+
.. note::
149+
``plugins.probe_spec``, ``plugins.buff_spec`` and ``run.probe_tags`` are
150+
**deprecated**. They still work (and are mapped onto ``run.spec`` with a
151+
deprecation notice) but will be removed in a future release; use
152+
``run.spec`` instead (see below).
146153
* ``buff_max`` - Upper bound on how many items a buff should return
147154
* ``detectors`` - Root node for detector plugin configs
148155
* ``generators`` - Root note for generator plugin configs
@@ -153,6 +160,57 @@ Plugins Config Items
153160
For an example of how to use the ``detectors``, ``generators``, ``buffs``,
154161
``harnesses``, and ``probes`` root entries, see :ref:`Configuring plugins with YAML <config_with_yaml>` below.
155162

163+
Selecting probes and buffs with run.spec
164+
""""""""""""""""""""""""""""""""""""""""
165+
166+
``run.spec`` is the single source of truth for selecting probes and buffs. It
167+
has two transports that parse to the same internal spec: a CLI string
168+
(``--run-spec``) and the config-file form (``include`` / ``exclude`` lists).
169+
170+
Selectors (a category prefix is mandatory):
171+
172+
* ``probes.*`` - all active probes (the default when no ``run.spec`` is given)
173+
* ``probes.<module>`` - an active family; ``probes.<module>.<Class>`` - one class
174+
* ``buffs.<module>[.<Class>]`` - selects buffs (no buffs are run by default)
175+
* ``tag:<prefix>`` - filters probes by tag (e.g. ``tag:owasp:llm01``)
176+
* ``tier:<N|name>`` - filters probes by tier; **inclusive** ("log level"): ``tier:N``
177+
admits tiers ``1..N`` (``tier:1`` is the most critical). Names work too
178+
(``tier:of_concern`` == ``tier:1``).
179+
180+
Polarity: a bare selector (or ``+``) includes; a leading ``-`` removes. Note
181+
the asymmetry of ``tier``: ``tier:N`` is the inclusive filter, while ``-tier:N``
182+
removes *exactly* tier ``N``. Resolution applies excludes last (exclude wins),
183+
and if a spec resolves to no probes garak aborts with an actionable message.
184+
``tier:`` and ``tag:`` filters apply to the whole candidate set, including
185+
explicitly-named classes, so e.g. ``probes.foo.Bar, tier:1`` yields nothing when
186+
``foo.Bar`` is tier 3.
187+
188+
.. code-block:: bash
189+
190+
# whole family minus one class
191+
garak --run-spec "probes.dan, -probes.dan.DanInTheWild"
192+
# family filtered by tag
193+
garak --run-spec "probes.grandma, tag:owasp:llm06"
194+
# all active buffs except one, over all active probes
195+
garak --run-spec "probes.*, buffs.*, -buffs.paraphrase"
196+
# tiers {1,3}: tier:3 admits 1..3, then -tier:2 removes exactly tier 2
197+
garak --run-spec "+probes.*, +tier:3, -tier:2"
198+
199+
.. code-block:: yaml
200+
201+
run:
202+
spec:
203+
include:
204+
- probes.dan
205+
- tag: owasp:llm01
206+
exclude:
207+
- probes.dan.DanInTheWild
208+
209+
The deprecated ``--probes`` / ``--probe_tags`` / ``--buffs`` flags (and the
210+
``plugins.probe_spec`` / ``plugins.buff_spec`` / ``run.probe_tags`` config keys)
211+
are mapped onto ``run.spec`` with a deprecation notice; ``--run-spec`` wins if
212+
both are given.
213+
156214
Reporting Config Items
157215
""""""""""""""""""""""
158216

@@ -231,9 +289,9 @@ probes and run each prompt just once:
231289
---
232290
run:
233291
generations: 1
234-
235-
plugins:
236-
probe_spec: latentinjection
292+
spec:
293+
include:
294+
- probes.latentinjection
237295
238296
If we save this as ``latent1.yaml`` somewhere, then we can use it with ``garak --config latent1.yaml``.
239297
Note: YAML configs require the explicit ``.yaml`` or ``.yml`` extension (case-insensitive).
@@ -244,10 +302,11 @@ Note: YAML configs require the explicit ``.yaml`` or ``.yml`` extension (case-in
244302
245303
{
246304
"run": {
247-
"generations": 1
248-
},
249-
"plugins": {
250-
"probe_spec": "latentinjection"
305+
"generations": 1,
306+
"spec": {
307+
"include": ["probes.latentinjection"],
308+
"exclude": []
309+
}
251310
}
252311
}
253312

docs/source/faster.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ You can get help by running ``python -m garak.analyze.aggregate_reports``.
104104
Probe aggregation
105105
^^^^^^^^^^^^^^^^^
106106

107-
One way of achieving parallel probing is by splitting garak probing up into many jobs each with one probe given in ``plugins.probe_spec``.
107+
One way of achieving parallel probing is by splitting garak probing up into many jobs each selecting one probe via ``run.spec`` (e.g. ``--run-spec probes.dan.AutoDANCached``).
108108
Each job should write to a distinct report file.
109109
When complete, the resulting report JSONL files can be aggregated into one using the ``aggregate_reports`` tool.
110110

docs/source/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Check out the :doc:`usage` section for further information, including :doc:`inst
6969
intents
7070
payloads
7171
_plugins
72+
_spec
7273
cas
7374
report
7475
services

docs/source/usage.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ You can list the probes by running the following command:
1515
1616
You can limit the probes to run by specifying more arguments.
1717

18-
For example, you can specify ``--probes promptinject`` to run only the PromptInject framework's methods. for example.
19-
You can also specify specific probes instead of a probe family such as ``--probes lmrc.SlurUsage`` to probe a model for generating slurs based on the Language Model Risk Cards framework.
18+
For example, you can specify ``--run-spec probes.promptinject`` to run only the PromptInject framework's methods.
19+
You can also specify specific probes instead of a probe family such as ``--run-spec probes.lmrc.SlurUsage`` to probe a model for generating slurs based on the Language Model Risk Cards framework.
2020

2121
Running a Scan
2222
--------------
@@ -37,11 +37,11 @@ Probe a commercial model for encoding-based prompt injection (OSX/\*nix) (replac
3737
.. code-block:: console
3838
3939
export OPENAI_API_KEY="sk-123XXXXXXXXXXXX"
40-
garak --target_type openai --target_name gpt-5-nano --probes encoding
40+
garak --target_type openai --target_name gpt-5-nano --run-spec probes.encoding
4141
4242
4343
Determine if the Hugging Face version of GPT2 is vulnerable to DAN 11.0:
4444

4545
.. code-block:: console
4646
47-
garak --target_type huggingface --target_name gpt2 --probes dan.Dan_11_0
47+
garak --target_type huggingface --target_name gpt2 --run-spec probes.dan.Dan_11_0

0 commit comments

Comments
 (0)