feat: AI security benchmark adapters (JBB, DoNotAnswer, OPI, AICGSecEval, SecCodeBench, AgentDojo) - #27
Open
AnandShivansh wants to merge 4 commits into
Open
Conversation
Introduce SecurityBenchmark with safety-dimension scoring, taxonomy metadata on Golden/EvalCase, and prompt-level adapters for JailbreakBench, DoNotAnswer, OpenPromptInjection, and JailBreakV-28K. Co-authored-by: Cursor <cursoragent@cursor.com>
Add AICGSecEval with bundled CWE tasks and sandbox checks, plus a thin SecCodeBench adapter with optional benchmarks-seccode extra. Co-authored-by: Cursor <cursoragent@cursor.com>
Add AgentDojo adapter with BaseTarget support and separate utility and attack-success reporting for agent prompt-injection evaluation. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
Document HF-backed vs fixture-backed loading, cache/offline usage, and upstream manifest paths so users can run beyond bundled smoke fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds AI security benchmark adapters for issue #24, built on a shared
SecurityBenchmarkbase with safety-dimension scoring (1.0 = safe/refusal, never averaged into correctness).Phase 1 — Prompt/refusal benchmarks
JailbreakBench— HFJailbreakBench/JBB-BehaviorsDoNotAnswer— HFLibrAI/do-not-answerOpenPromptInjection— indirect prompt injection scenariosJailBreakV28K— HFSaFoLab/JailBreakV-28Kwith JBB fallbackPhase 2 — Secure code generation
AICGSecEval— CWE tasks with HumanEval-style sandbox checksSecCodeBench— thin adapter with optional[benchmarks-seccode]extraPhase 3 — Agent security
AgentDojo— utility vs attack-success metrics; supportsrun(model=...)orrun(target=BaseTarget)Also adds
_security_utils.py,fetch_github_json()indataset_cache.py, bundled smoke fixtures underbenchmarks/data/, and unit tests for all adapters.Running full datasets
See README AI Security Benchmarks → Running full datasets for details. Quick reference:
limit— full dataset fetched from HuggingFace and cached under~/.cache/harness_evals/benchmarks/fetch_github_json()SecCodeBench(manifest_path="sec-code-bench/datasets/benchmark/python/python.json")AgentDojo(tasks_path="/path/to/full_tasks.json")Use
offline=Trueafter the first download. Check size withlen(await benchmark.load_dataset())before running.Follow-up: remote-first loading so bundled fixtures are test/offline-only (no file rename workaround).
Test plan
pytest tests/benchmarks/ -v -m unit— 160 tests passruff check src/ tests/— cleanJailbreakBench().run(model=...)with HF cache populatedAgentDojo().run(target=...)with bundled tasksNotes
benchmarks/data/is intentionally minimal (2–3 items) for offline CI; HF-backed benchmarks load full datasets.