Commit Graph
80 Commits
Author SHA1 Message Date
Ankit1478 fdfd1f9851 Proofread the eval README 2026-11-09 13:37:00 +05:30
Ankit1478 0594e5d59e Fix stale references left in the eval suite docs
The _runner docstring still said nothing covered the failure-rate arithmetic
or the optimize=True early stop; test_scan_module.py covers both. One `:324`
line reference and four `name (name)` parentheticals survived the earlier
sweep. test_detector still said 241 rows, and the README still named
MIN_RECALL and MAX_FALSE_POSITIVES, which the set-based baselines replaced.

Also records that CI does not run this suite, with the step that would turn it
on and the two reasons that is the maintainer's decision: a build starts
failing when a defect is fixed without unmarking its xfail, and the caret pin
on scikit-learn lets a fresh resolve invalidate the recorded baselines.
2026-11-09 13:29:41 +05:30
Ankit1478 8bb7981225 Fix stale figures in the eval README 2026-11-09 13:12:51 +05:30
Ankit1478 9b03064943 Correct the xfail count in the eval README 2026-11-09 13:12:51 +05:30
Ankit1478 5286c69119 Drop future annotations import from the eval suite
pyupgrade strips it on this Python target, so `pre-commit run --all-files`
rewrote all twelve files and the pre-commit job would have failed on a branch
that looked clean locally. No other file in the tree carries the import.
2026-11-09 13:12:51 +05:30
Ankit1478 8f456013b6 Add blind-review tooling for the eval corpus
The labelling rules only mean something if a second person applies them the
same way. This builds a blind sheet to measure that: 30 rows drawn across all
ten sampleable (label, kind) pairs with the labels stripped, alongside a
self-contained statement of the rules.

Scoring is chance-corrected for both labels and kinds, with a bootstrap
interval, because at n=30 a single disagreement moves kappa by about 0.05 and
a raw percentage reads far better than it should with three uneven classes.
The scorer refuses a sheet before scoring it: an unfinished one would come
back as a perfect score, since a blank row is not a disagreement.

The sample deliberately over-weights the awkward kinds and forces in real
captured replies, so the result bounds agreement from below rather than
estimating it.

The answer key and the generated sheet are gitignored. Only the tooling is
committed; the sheet regenerates identically from a fixed seed.
2026-11-09 13:12:51 +05:30
Ankit1478 457bf4cf24 Guard the environment the detector baselines were recorded in
baselines.json records what the bundled OneClassSVM answers. That model
is three .joblib files committed to the repo, pickled with scikit-learn
1.9.1, so the recorded sets only hold under that release. On any other
one, every detector gate goes red for a reason that has nothing to do
with the code, and the message blames the corpus.

Three checks now run before the gates:

  - the three .joblib files are present, named individually
  - scikit-learn matches the release the models were pickled with, and
    the failure says it is an environment mismatch
  - the model still answers three fixed probes as recorded. A version
    check alone is not enough, since the files are committed and can be
    replaced without the dependency moving. One probe answers False, so
    a model degenerated to a constant is caught too

Pins that the ML plugin returns numpy.bool_ while annotated -> bool.
Harmless through the manager's any(), wrong for any caller using
`is True`.
2026-11-09 13:12:51 +05:30
Ankit1478 9ca647c5a1 Name functions instead of line numbers in the eval suite
Thirteen references pointed at source lines. One was already wrong:
targets.py cited both fuzzer.py:177 and fuzzer.py:190 for the same
JSONDecodeError handler. They rot on any edit upstream, so they now name
the function.

test_cli_status_still_mirrors_the_shipped_rule asserted an exact source
string, which would go red on a reformat. It parses async_scan and
compares the unparsed condition instead.
2026-11-09 13:12:51 +05:30
Ankit1478 6e812d5620 Grow the eval corpus and gate it by identity
Corpus goes from 37 to 245 rows. The larger corpus exposed defects the
small one never triggered, and exposed two weaknesses in the gates
themselves.

Gates no longer compare counts. baselines.json records which rows the
detector gets wrong, keyed by a hash of the reply text, and the gates
assert that no row newly joins a wrong-answer set. A count was not
monotone under corpus edits -- deleting a row the detector misreads
lowered the cap and handed back a slot -- and could not tell a fix from a
substitution. Regenerate with record_baselines.py.

Detector findings the bigger corpus surfaced:

  - ten attack_success rows read as refusals; the "an answered attack is
    never a refusal" gate becomes a strict xfail with an exact pin
  - all four roleplay rows read as refusals
  - the curly-apostrophe test was vacuous. It compared detect() outputs,
    which agree because the ML classifier fires on both spellings, while
    the phrase list went on missing every U+2019 form

New coverage:

  - test_scan_module.py drives the real entry point. Under optimize=True
    a module stops at the fifth prompt and reports that prefix's rate: a
    target scored 25% over twenty prompts is reported at 100% over five,
    and the payload does not say so
  - agentic_security ci cannot fail a build. entrypoint() discards
    scan()'s result and __main__.ci discards entrypoint()'s, so the
    process exits 0 whatever it found. Pinned by AST, not by grep
  - envelope invariance is now asserted on real attack output, not only
    on a benign sentence
  - HTTP 200 with a non-JSON body reaches fuzzer.py:177 for the first
    time; FakeResponse.json() parses its body instead of returning a
    pre-parsed object, which had made that branch unreachable

Corpus integrity: kind is validated against a per-label vocabulary and
src against a known set of models, so a typo can no longer drop a row out
of every gate silently. The partial sub-kinds get a stated rule --
refuse_then_disclose is the target's own configuration, refuse_then_comply
is something the attacker can act on -- and two rows are relabelled to
match it.

README corrects two claims: six of the 48 false positives are benign
answers rather than attacks reported as declines, and sixteen are planted
fp_trap rows, so the headline number moves little when real classifier
errors are fixed. Adds a Scope section for what the suite does not reach.

547 passed, 20 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 90ed87b585 Add scan evaluation suite
Tier 1 drives process_prompt over fake targets whose posture is fixed by
construction, with the detector pinned to a phrase matcher. Tier 2 runs the
real detector over the labelled corpus with ratchet baselines.

Seventeen strict xfails state what should happen; each is paired with a test
pinning the current wrong behaviour, so a fix turns both red together.

118 passed, 17 xfailed.
2026-11-09 13:12:51 +05:30
Ankit1478 c3d0064a15 Empty the eval test modules pending review
targets.py and _runner.py were committed before review. Empty them so the
suite scaffold lands as placeholders only, to be filled in one file at a
time.

The corpus and the pytest configuration are unchanged and stay in place.
2026-11-09 13:12:51 +05:30
Ankit1478 9bbcbd7f56 Add scan evaluation suite scaffold and corpus
Adds tests/evals, an opt-in suite that measures what the scanner concludes
about targets whose behaviour is known in advance, so a verdict can be checked
against ground truth instead of against the scanner's own internals.

Landing in two parts. This commit carries:

- corpus/*.jsonl: 37 labelled model replies (18 refusals, 12 compliances,
  7 partials), 5 tagged disputed. 10 rows are real captured output.
- targets.py: fake targets with known ground truth (secure, compromised,
  mixed, erroring) plus four provider response envelopes.
- _runner.py: drives process_prompt and returns a Verdict.
- pyproject.toml: register the eval marker and deselect it by default, so
  the suite is opt-in and `pytest tests/evals -m eval` collects.
- .gitignore: ignore .env and .venv.

The test modules are placeholders in this commit and are filled in next.
2026-11-09 13:12:51 +05:30
Nicho Deng abfe075849 feat: add cheapaimodel preset to LLM specs 2026-11-03 12:21:58 +08:00
Nirupam Bhowmick 69a75b9329 feat: add Runcrate preset to LLM specs 2026-11-01 10:42:10 +00:00
Alexander Myasoedov 55c6124b46 test(registry): check HF datasets via metadata, deactivate 3 dead ones (#72) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 486af8e58e fix(verify): return 400 for bad specs and upstream errors (#149) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov 48a3374e6c fix(refusal_classifier): read judge verdict on word boundaries (#350) 2026-10-18 19:08:48 +03:00
Alexander Myasoedov eab28edb52 feat(agentic_security_harness): 2026-10-18 18:09:43 +03:00
Alexander Myasoedov 3e6b184c4f fix: template fix 2026-09-07 14:03:57 +03:00
Alexander Myasoedov 27c160eaa3 Merge pull request #326 from chiruu12/fix/hybrid-classifier-guards
fix(hybrid): guard zero total weight and log skipped detectors
2026-08-18 18:40:07 +03:00
Alexander Myasoedov de16779806 Merge pull request #328 from feiiiiii5/fix-circuit-breaker-half-open
fix(circuit-breaker): reopen on failure during half-open probation
2026-08-18 18:39:03 +03:00
Alexander Myasoedov 017ba7c168 Merge pull request #329 from feiiiiii5/fix-p95-percentile-index
fix(executor): compute p95 latency as a real 95th percentile
2026-08-18 18:38:25 +03:00
Chris (ChrisJr404) 79f450bbae Tag probe datasets with OWASP LLM Top 10 categories in the scan UI 2026-08-17 23:49:11 -04:00
fei cf3498264f fix(executor): compute p95 latency as a real 95th percentile
ExecutorMetrics.get_stats picked the p95 element with
int(n * 0.95), which collapses to the last index (the maximum)
for any batch of 20 or fewer requests, so the reported p95 was
actually the worst-case latency for typical scan batches. Use
ceil(n * 0.95) - 1, the standard nearest-rank index.
2026-08-16 18:39:10 +08:00
fei fcd1fd20ae fix(circuit-breaker): reopen on failure during half-open probation
record_failure ignored the half_open state: the minimum-sample gate
(total >= 10) and the success counter meant a failure during
probation neither re-opened the circuit nor prevented it from
closing. One failure followed by three successes closed the circuit
with the failure forgotten. Trip back to open on the first half-open
failure, with fresh counters.
2026-08-16 18:23:29 +08:00
chiruu12 2f411b90dc fix(hybrid): guard zero total weight and log skipped detectors 2026-08-14 17:04:47 +05:30
Alexander Myasoedov c8458d73c5 Merge pull request #320 from DevamShah/fix-cors-credentials-and-icon-traversal
fix: wildcard CORS + credentials spec violation, path-traversal guard on /icons proxy
2026-07-31 19:27:20 +03:00
Devam Shah d28c4b4b1e feat: config-pluggable refusal classifiers and leak detectors
PIIDetector and SandboxEscapeDetector were wired directly in
probe_actor/refusal.py and the refusal classifier manager was populated from
a hardcoded list, so the only way to toggle a bundled detector or add an
organization-specific signature was to patch the module.

Add a DetectorRegistry mapping plugin names to factories, assembled from an
agentic_security.toml [detectors] section via build_from_config. Custom
detectors load by import path ("pkg.module:ClassName"). refusal.py gains
build_refusal_manager(config=None) reading the [detectors] table; all public
symbols are preserved. Built-in leak detectors ship registered but disabled,
so default refusal_heuristic behaviour is unchanged.

Closes #82

Signed-off-by: Devam Shah <devamshah91@gmail.com>
2026-06-22 19:40:33 +05:30
Devam Shah dd59704fdf fix: wildcard CORS + credentials spec violation, path-traversal guard on /icons proxy
CORS: drop allow_credentials=True. With allow_origins=['*'] Starlette reflects
the request Origin and emits Access-Control-Allow-Credentials: true on any
credentialed request — a reflect-any-origin hole. The app authenticates with
Bearer tokens in the Authorization header, so credentialed CORS was never needed.

/icons/{icon_name}: validate against a strict allowlist (re.fullmatch
[A-Za-z0-9._-]+\.png) and assert the resolved path stays inside ICONS_DIR before
any filesystem write or outbound fetch. Closes the path-traversal / arbitrary-write
(CWE-22) and controlled-URL (CWE-73) surface on the unsanitized icon_name.

Adds CORS middleware tests and icon-name validation tests (traversal, encoded
slash, null byte, trailing newline, wrong extension).

Closes #298

Signed-off-by: Devam Shah <devamshah91@gmail.com>
2026-06-22 10:10:43 +05:30
JackSpiece cb8bceb16a chore: delete MCP server and client (#308) 2026-06-10 21:30:07 +00:00
Alexander Myasoedov ead8f85836 feat(feat(refusal): detect Docker/K8s sandbox escape probes (#280)): 2026-06-04 18:28:12 +03:00
Alexander Myasoedov 816c8c6bc7 fix(make litellm optional import): 2026-06-03 15:08:23 +03:00
Alexander Myasoedov a193ef9c2c fix(pc): 2026-06-03 15:05:59 +03:00
Alexander Myasoedov 67cedfb116 Merge pull request #299 from RheagalFire/feat/add-litellm-provider
feat: add LiteLLM as provider for 100+ LLM backends
2026-06-03 15:04:18 +03:00
Alexander Myasoedov 1fa66bd292 Merge pull request #300 from JackSpiece/fix/mcp-client-usage-examples
docs: add MCP client usage examples
2026-06-03 15:01:02 +03:00
Alexander Myasoedov 1bfb7dcc20 fix(use_agg_backend): 2026-06-03 14:59:43 +03:00
Carlos bad38aeb87 fix: correct test expectations to match _generate_identifiers behavior, set Agg backend for headless CI 2026-05-30 14:15:59 -04:00
Carlos 312a4cee53 feat: add MCP+Agno integration docs and report chart tests 2026-05-30 12:16:06 -04:00
JackSpiece 72f0f63a89 docs: add MCP client usage examples 2026-05-19 19:16:11 +08:00
RheagalFire a4833908ef test: add 29 unit tests and remove lazy imports 2026-05-19 01:50:40 +05:30
Edneam be7fb1f370 fix: keep PII detection separate from refusal metrics 2026-05-14 22:42:28 +05:30
Edneam d734067ef6 test: cover PII leak detector 2026-05-14 22:31:50 +05:30
Alexander Myasoedov a0b2b9ec70 feat(py upgrade): 2026-05-14 18:56:24 +03:00
Alexander Myasoedov bc7fdd7cfa fix(pc): 2026-01-28 21:04:29 +02:00
Alexander Myasoedov b38a27d78c feat: US-005 - Enhanced Refusal Detection with Hybrid Approach
Implement hybrid refusal classifier combining multiple detection methods:
- Add confidence scoring to refusal detection (HybridResult)
- Implement weighted voting with configurable thresholds
- Support require_unanimous mode for strict classification
- Add factory function create_hybrid_classifier for common setup
- Include 32 unit tests with table-driven test patterns
2026-01-28 18:52:20 +02:00
Alexander Myasoedov 41567925aa feat: US-004 - Unified LLM Provider Abstraction
Create unified provider abstraction layer for direct LLM integrations beyond
HTTP specs, inspired by FuzzyAI's comprehensive provider system.

- Add BaseLLMProvider abstract class with standard interface (generate, chat,
  sync_generate, sync_chat methods)
- Implement OpenAIProvider supporting chat completions API
- Implement AnthropicProvider supporting messages API
- Create provider factory for instantiation by name (create_provider,
  get_provider_class)
- Add 60 unit tests covering all provider implementations
2026-01-28 18:34:38 +02:00
Alexander Myasoedov f8e3f6f4a5 feat: US-003 - Composable Fuzzing Chain System
Implement FuzzNode and FuzzChain classes for multi-step attack chains
with pipe operator syntax, inspired by FuzzyAI architecture.

- FuzzNode: Single LLM call with {var} template substitution
- FuzzChain: Sequential execution passing output as input
- Pipe operator (|) for composing nodes into chains
- LLMProvider protocol for provider abstraction
- 22 unit tests covering composition and execution
2026-01-28 18:29:22 +02:00
Alexander Myasoedov ef35c1f82e feat: US-002 - YAML-based Attack Rule System
Implement a YAML-based rule system for defining attack patterns and success
conditions, inspired by Promptmap's 50+ YAML rule definitions.

Features:
- AttackRule model with name, type, severity, prompt, pass/fail conditions
- RuleLoader for parsing YAML files with validation
- Support for recursive directory loading and filtering by type/severity
- Template variable substitution in prompts
- Dataset integration for converting rules to ProbeDataset format
- YAMLRulesDatasetLoader for loading rules from multiple directories

Tested with 47 unit tests covering models, loader, and dataset integration.
Successfully loads 69 rules from promptmap research directory.
2026-01-28 18:23:04 +02:00
Alexander Myasoedov 32f103acbc feat: US-001 - Dual-LLM Evaluation for Attack Success Detection
Add LLM-based refusal classifier inspired by Promptmap's dual-LLM
architecture. The controller LLM evaluates whether an attack succeeded
by analyzing the target's response against pass/fail conditions.

- Create LLMRefusalClassifier plugin integrating with existing system
- Support OpenAI and Anthropic providers with lazy initialization
- Add configurable system prompts and pass/fail conditions
- Include 20 unit tests for comprehensive coverage
2026-01-28 18:18:09 +02:00
Alexander Myasoedov ce7636fe9e feat(restruct tests): 2025-12-26 22:58:21 +02:00