test: add property-based fuzz coverage for Zod validators - #2384
Merged
Baskarayelu merged 1 commit intoJul 29, 2026
Conversation
- Add fuzz tests for all Zod schemas in invoices.ts, bids.ts, settlements.ts, shared.ts - Use fast-check to generate malformed payloads: unicode, very large ints, NaN/Infinity - Test prototype-pollution attempts (__proto__, constructor) cannot mutate output - Assert validators never throw unhandled errors on any input - Covers all exported schemas with 100% test pass rate (31/31 tests pass) - Security-checklist.md already has comprehensive fuzz strategy documentation (Section 12) Closes QuickLendX#2356
Contributor
Author
|
Hi @Baskarayelu Please check it out! |
Contributor
Author
|
Hi @Baskarayelu, The CI is failing on the Dependency Vulnerability Scan due to 22 high severity vulnerabilities in the existing dependencies. These vulnerabilities are pre-existing in the codebase and are not related to my changes (I only added fuzz test files for Zod validators). The vulnerabilities are in:
I tried Since these vulnerabilities are pre-existing and not introduced by my PR, I recommend:
Please let me know how you'd like to proceed. Also, I've reached out on Discord as well. Thanks! 🙏 |
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.
📝 Description
This PR adds property-based fuzz tests for all Zod validators in the backend. The tests use
fast-checkto generate malformed payloads and verify that validators never throw unhandled exceptions, preventing crashes from malicious or malformed input.🎯 Type of Change
🔧 Changes Made
Files Modified
backend/src/tests/validators.fuzz.test.ts- Added fuzz tests for all Zod schemasbackend/tests/validators.fuzz.test.ts- Fuzz tests (existing, verified passing)backend/docs/security-checklist.md- Already has Section 12 documenting fuzz strategyNew Files Added
backend/src/tests/validators.fuzz.test.tsKey Changes
__proto__,constructor) cannot mutate Object.prototype🧪 Testing
Test Coverage
All 11 exported schemas are covered:
hexStringSchemastellarAddressSchemapositiveAmountSchemapaginationSchemacreateInvoiceBodySchemacreateBidBodySchematransitionInputSchemagetSettlementsQuerySchemagetInvoicesQuerySchemagetBidsQuerySchemainvoiceIdParamSchemaTest categories covered:
📋 Contract-Specific Checks
Contract Testing Details
N/A - This is a backend validator test, not a contract change.
📋 Review Checklist
🔍 Code Quality
🚀 Performance & Security
📚 Documentation
🔗 Related Issues
Closes #2356
📋 Additional Notes
The fuzz strategy is already documented in
backend/docs/security-checklist.md(Section 12). No new documentation was needed as it was already complete and comprehensive.🧪 How to Test
Expected result: All 31 tests pass.
📸 Screenshots (if applicable)
N/A - This is a test addition, no UI changes.
None.
🔄 Migration Steps
None.
closes #2356