test(policies): adversarial test fixtures for v1 hook policies#26
Open
VibhorGautam wants to merge 6 commits intoc2siorg:mainfrom
Open
test(policies): adversarial test fixtures for v1 hook policies#26VibhorGautam wants to merge 6 commits intoc2siorg:mainfrom
VibhorGautam wants to merge 6 commits intoc2siorg:mainfrom
Conversation
Collaborator
|
I like the way you have defined the Jailbreak Patterns. Can you consider doing this for the latest version? |
Author
|
yea for sure, saw the phase 2 pipeline stages landed. will rebase against main and update the patterns to align with the new validate > normalise > scan > aggregate flow some of the test fixtures will need tweaking too since the strict_mode switch probably changes how certain edge cases get handled should have it updated in a day or two |
- bump jailbreak_patterns.json to v2.0.0 (24 patterns, 10 categories) - each pattern now has id, category, severity, owasp_llm mapping - update LoadPatterns to handle both structured and flat string formats - add loader tests for both formats - log warning on unparseable entries instead of silent skip
b1a3e8a to
476898d
Compare
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.
fills in the test stubs from #19 with actual adversarial test cases mapped to attack patterns from issue #2, updated for phase 2 pipeline
whats included
policies/tests/ (4 files, 30 test cases total):
prompt_test.rego- 11 tests: instruction override, jailbreak, role escalation, unicode obfuscation, split injection, false positive check, v2 state escalationtool_test.rego- 6 tests: unlisted tool block, param injection, shell exec, nested json override, fp check for security discussioncontext_test.rego- 6 tests: indirect injection in retrieved content, exfil attempt, cross-chunk injection, security docs fpmemory_test.rego- 5 tests: memory poisoning, cross-session access, trust escalation via accumulated writespolicies/v1/data/jailbreak_patterns.json (v2.0.0):
sidecar/internal/config/loader.go:
sidecar/internal/config/loader_test.go (new):
why this matters
pranjals #19 added the policy templates and test file headers but the actual test implementations were empty stubs. this fills those in w adversarial payloads so
opa testcatches regressions when policies changerebased against phase 2 main (validate > normalise > scan > aggregate pipeline). the loader update ensures the structured pattern format works with the aho-corasick scan stage
false positive tests are important too - a policy that blocks "how do i prevent sql injection" just bc it contains "sql injection" is worse than no policy at all imo
how to test
maps to the adversarial validation work from issue #2 and the payload library in PR #5