fix(disputes): validate evidence URLs, reject duplicates, cap per-dispute evidence (closes #1609) - #1800
Open
rudrasatani13 wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 #1609.
One thing worth knowing before you review: another contributor asked to be assigned this issue on 10 September and never opened a pull request (no assignee was ever set, and a repo-wide PR search for this issue returns only this one). If you would rather they take it, say so and I will close this.
What was missing
attachEvidencechecked the MIME type and the file size, and nothing else:fileUrlwas whatever string arrived. The DTO's@IsUrl()rejects obvious garbage, but that is a transport-layer check - the service itself accepted any scheme it was handed, softp:orjavascript:URLs would be persisted and later rendered to participants and arbiters.What changed
normalizeEvidenceUrl()- parses the URL, requires http/https, requires a hostname, rejects anything longer than the 2048-character column, and stores the normalised form rather than the raw string.assertEvidenceIsNew()- rejects a duplicate(disputeId, fileUrl)pair.assertEvidenceCountAllowed()- caps a dispute atDISPUTE_EVIDENCE_MAX_COUNT(default 10), read through the same ConfigService pattern as the existing MIME and size settings.Tests
Three new cases in
disputes.service.spec.ts: a non-http(s) scheme is rejected and nothing is persisted, a duplicate URL is rejected before the write, and the cap is enforced at the boundary. The evidence repository mock gained thefindOne/countthe new checks use.Verification:
npx jest src/disputes-> 2 suites, 65 tests passing.npx tsc --noEmit-> the same 66 pre-existing errors as before this branch, none in the files touched here.Assignment and reward are not confirmed on my side, so please treat this as a voluntary contribution.