added input validation for dispute evidence size and content validation#701
Merged
Baskarayelu merged 4 commits intoQuickLendX:mainfrom Apr 1, 2026
Merged
added input validation for dispute evidence size and content validation#701Baskarayelu merged 4 commits intoQuickLendX:mainfrom
Baskarayelu merged 4 commits intoQuickLendX:mainfrom
Conversation
|
@Cofez Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Cofez Please resolve the conflicts |
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.
CLOSES #548
📝 Description
Implement input validation for dispute reason, evidence, and resolution fields to prevent abusive on-chain storage growth. Adds bounded string validation with explicit error codes, wires up the full dispute lifecycle as contract methods, registers comprehensive test suites, and updates documentation with security considerations.
🎯 Type of Change
🔧 Changes Made
Files Modified
quicklendx-contracts/src/lib.rs— Added 7 dispute contract methods to#[contractimpl]block; registeredtest_disputeandtest_string_limitstest modulesquicklendx-contracts/src/verification.rs— Added 4 dispute validation functions (validate_dispute_reason,validate_dispute_evidence,validate_dispute_resolution,validate_dispute_eligibility)quicklendx-contracts/src/dispute.rs— Added NatSpec-style documentation to all functions, types, and module header with security notesdocs/contracts/dispute.md— Rewrote to reflect actual implementation: corrected field limits, added validation section, error code table, test coverage matrix, and security assumptionsquicklendx-contracts/TEST_OUTPUT.txt— Updated with full test report and security notesNew Files Added
Key Changes
MAX_DISPUTE_REASON_LENGTH)MAX_DISPUTE_EVIDENCE_LENGTH)MAX_DISPUTE_RESOLUTION_LENGTH)test_dispute.rs(29 tests) andtest_string_limits.rs(8 tests) were previously uncompiled — now registered as#[cfg(test)]modulesInvalidDisputeReason(1905) andInvalidDisputeEvidence(1906)🧪 Testing
Test Coverage
30 tests pass (29 dispute + 1 string limits):
Estimated coverage: 95%+
📋 Contract-Specific Checks
Contract Testing Details
cargo checkpasses with 0 errors (129 pre-existing warnings, none from this PR)cargo test --lib test_dispute— 30/30 passcargo test --lib— 76/78 pass (2 pre-existing failures unrelated to this PR:test_init::test_initialization_requires_admin_authandtest_string_limits::test_tag_trim_to_limit_valid)require_auth()for caller verificationAdminStorage::require_admin()📋 Review Checklist
🔍 Code Quality
🚀 Performance & Security
Security details:
DisputeAlreadyExistscheck📚 Documentation
Documentation updates:
dispute.rs— NatSpec-style@notice,@dev,@param,@returnon all public functions and typesverification.rs— NatSpec comments on all 4 new validation functionslib.rs— NatSpec comments on all 7 new contract methodsdocs/contracts/dispute.md— Complete rewrite with corrected limits, validation tables, error codes, test matrix, and deployment checklist🔗 Related Issues
Closes #
Fixes #
Related to #
📋 Additional Notes
dispute.rsmodule contains a standalone storage variant (using persistent storage keyed by("dispute", invoice_id)) that is retained for reference. The active contract methods use the invoice-embedded dispute model whereDisputeandDisputeStatusare fields on theInvoicestruct.MAX_DISPUTE_REASON_LENGTH,MAX_DISPUTE_EVIDENCE_LENGTH,MAX_DISPUTE_RESOLUTION_LENGTH) were already defined inprotocol_limits.rs— this PR adds the validation functions that enforce them.InvalidDisputeReason(1905) andInvalidDisputeEvidence(1906) are reused for all dispute field validation.🧪 How to Test
test_dispute+ 1 intest_string_limits)src/verification.rs(bottom of file, search forvalidate_dispute_reason)src/lib.rs(search forDispute Resolution Functions)📸 Screenshots (if applicable)
N/A — backend smart contract changes only.
None. All changes are additive — new contract methods and validation functions. Existing functionality is unchanged.
🔄 Migration Steps (if applicable)
No migration required. New contract methods are immediately available after deployment.
📋 Reviewer Checklist
Code Review
Contract Review