Files
agentic_security/docs/api_reference.md
Alexander Myasoedov 48349bbd12 fix(scan): score attacks that succeeded, not refusals (#358)
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.
2026-10-29 19:30:41 +02:00

44 lines
1.4 KiB
Markdown

# API reference
The server (`agentic_security server`) has test endpoints. Use them to test a spec before you scan a real target.
## POST /v1/self-probe
A mock LLM for text. It refuses approximately 80% of prompts at random.
Request body:
```json
{"prompt": "<<PROMPT>>"}
```
The response has the OpenAI chat-completion format.
## POST /v1/self-probe-image
A mock LLM for images. It ignores the request body and always gives the same response.
## POST /v1/self-probe-file
A mock audio transcription endpoint. It accepts a multipart upload.
| Part | Description |
| --- | --- |
| `file` | An `.m4a`, `.mp3`, or `.wav` file. |
| `model` | Optional. The default is `whisper-large-v3`. |
The request must have the header `Authorization: Bearer <any value>`. The endpoint does not examine the key. The response is `{"text": "...", "model": "..."}`.
## Other endpoints
| Method | Path | Description |
| --- | --- | --- |
| GET | `/health` | Returns `{"status": "ok"}`. |
| GET | `/v1/llm-specs` | Returns the built-in spec templates. |
| GET | `/v1/data-config` | Returns the dataset registry. The response is very large. |
| POST | `/verify` | Sends a test request with a spec. |
| POST | `/scan` | Starts a scan. The response is a stream of JSON lines. |
| POST | `/stop` | Stops the current scan. |
| POST | `/scan-csv` | Starts a scan with an uploaded CSV file. |
| GET | `/failures` | Returns the failures of the last scan. |