test(protect): per-vuln-class rule corpus + rename example-rule test - #91
Merged
Conversation
Add tests/protect/rule-corpus.test.ts: canonical vpatch rules (one per vuln class — prototype pollution, path traversal, SQLi, XSS/inline_xss, command injection, request-side SSRF/internal_host, NoSQL, scanner UA, malicious cookie, base64 mutation chain) run END-TO-END through fetchGuard (real Request → shaping → engine), each pairing an exploit (must block) with a benign request (must not — false-positive guard). Plus dry-run detect-not-block, inclusive AND, and whitelist suppression end-to-end. Complements the engine-primitive unit tests, which evaluate hand-shaped objects. Also rename dave-example-rule.test.ts → example-rule.test.ts and drop the personal name from its titles (test names shouldn't carry individuals' names). +23 tests, 518 total. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thorough end-to-end test corpus covers each vulnerability class with clear exploit and benign cases. 🎯 Quality: 100% Elite · 📦 Size: Medium 📈 This month: Your 40th PR — above team average · Averaging Excellent |
Contributor
Author
|
/review |
mariojgt
approved these changes
Jul 16, 2026
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.
Two rule-test changes:
1.
rule-corpus.test.ts— end-to-end coverage per vuln class. Canonical vpatch rules run through the real request path (fetchGuard→fromFetchRequest→ engine), not a hand-shaped engine object. Each class pairs an exploit (must block) with a benign request (must pass — the false-positive guard): prototype pollution, path traversal, SQLi, reflected XSS (inline_xss), command injection, request-side SSRF (internal_host), NoSQL, scanner User-Agent (server.HTTP_*), malicious cookie (cookie.*), and a base64 mutation chain. Plus dry-run (detect, don't block), inclusive AND, and whitelist suppression — all end-to-end. Complements the engine-primitive unit tests (which callevaluate()on pre-shaped objects).2. Rename
dave-example-rule.test.ts→example-rule.test.tsand drop the personal name from its titles — test names shouldn't carry individuals' names.+23 tests. Tests only.