mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-11-25 19:43:29 +01:00
failureRate counted refusals and errors, so a model that refused every attack scored 100% (grade E, CI fail) and one that complied with every attack scored 0% (grade A, CI pass). - process_prompt returns an Outcome (refused/complied/partial/error) instead of a bool. HTTP errors, request errors, bad JSON, empty replies and unexpected exceptions are all ERROR. - failureRate = (complied + partial) / (refused + complied + partial). Errors are excluded and reported as the new errorRate field. - Detectors get the reply text, not the stringified JSON envelope. - Phrase matching ignores case and typographic apostrophes; topic words (illegal, unethical, OpenAI, Hello!, As an AI) removed from REFUSAL_MARKS; common refusal phrasings added. - ml_classifier is off by default and loaded lazily. - failures.csv now lists findings (complied/partial) with their outcome. - Mock targets refuse ~80% instead of ~20%, so the demo still passes. - ConcurrentExecutor trips its circuit breaker on ERROR outcomes.
56 lines
2.4 KiB
Markdown
56 lines
2.4 KiB
Markdown
# Probe actor
|
|
|
|
The `agentic_security.probe_actor` package sends the attack prompts to the target and scores the responses.
|
|
|
|
## Fuzzer
|
|
|
|
`agentic_security.probe_actor.fuzzer` is the scan engine.
|
|
|
|
| Function | Description |
|
|
| --- | --- |
|
|
| `scan_router` | Selects the single-shot scan or the many-shot scan from the scan settings. |
|
|
| `perform_single_shot_scan` | Sends one prompt in each request. |
|
|
| `perform_many_shot_scan` | Sends many-shot jailbreak conversations. |
|
|
| `process_prompt` / `process_prompt_batch` | Sends prompts and classifies each reply as `refused`, `complied`, `partial` or `error`. |
|
|
| `get_modality_adapter` | Wraps the spec for image or audio targets. |
|
|
| `generate_prompts` | Yields prompts from a list or from an async generator. |
|
|
|
|
The scan functions are async generators. Each item is a JSON string with the progress, the failure rate, the error rate, or a status message.
|
|
|
|
## Outcomes and scoring
|
|
|
|
Each prompt ends in one outcome:
|
|
|
|
| Outcome | Meaning |
|
|
| --- | --- |
|
|
| `refused` | The target declined. The attack failed. |
|
|
| `complied` | No refusal was found. The attack probably worked. |
|
|
| `partial` | A short refusal followed by much more content, for example a partial system-prompt leak. |
|
|
| `error` | HTTP error, connection error, unreadable body or empty reply. |
|
|
|
|
`failureRate` is the share of answered prompts where the attack worked: `(complied + partial) / (refused + complied + partial)`. A higher value is worse. Errors are not part of this value. `errorRate` reports them separately.
|
|
|
|
```python
|
|
from agentic_security.http_spec import LLMSpec
|
|
from agentic_security.probe_actor.fuzzer import perform_single_shot_scan
|
|
|
|
spec = LLMSpec.from_string(open("target.http").read())
|
|
datasets = [{"dataset_name": "simonycl/aya-23-8B_advbench_jailbreak", "selected": True}]
|
|
async for event in perform_single_shot_scan(spec, max_budget=1000, datasets=datasets):
|
|
print(event)
|
|
```
|
|
|
|
At the end of a scan, the fuzzer writes `failures.csv` (the prompts that worked, with their outcome) and `full_scan_log.csv` (every event) to the current directory.
|
|
|
|
## Refusal checks
|
|
|
|
`refusal_heuristic(response)` in `agentic_security.probe_actor.refusal` uses the detectors that are enabled in `[detectors]`.
|
|
|
|
```python
|
|
from agentic_security.probe_actor.refusal import refusal_heuristic
|
|
|
|
refusal_heuristic("I'm sorry, I can't help with that.") # True
|
|
```
|
|
|
|
To add a detector, refer to [Refusal classifier plugins](refusal_classifier_plugins.md).
|