Validation hardening: split math, DTO cross-field checks, and strict body whitelisting - #217
Merged
chonilius merged 1 commit intoAug 26, 2026
Conversation
…ields - apportionBasisPoints now throws BadRequestException when its input percentages don't sum to ~100 (matching splitStroops's existing precondition guard) instead of silently force-normalizing an arbitrarily wrong input to a valid-looking 10,000 bps output. Adds a regression test for the not-summing-to-100 case. - Global ValidationPipe now sets forbidNonWhitelisted: true so requests with unrecognized body fields are rejected with a 400 instead of silently having those fields stripped. Closes MergeFi#169 Closes MergeFi#170
|
@OlaGreat is attempting to deploy a commit to the chonilius' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@OlaGreat 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! 🚀 |
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.
Summary
Hardens several validation gaps across the escrow and DTO layers:
apportionBasisPointshad no precondition guard on its own input, unlikesplitStroopsin the same file. It would silently force-normalize any input (even one summing to 20%) into a valid-looking 10,000 bps output instead of failing loudly. Added the sameMath.abs(sum - 100) > 0.01guardsplitStroops/assertValidSplitsalready use, plus a regression test for the not-summing-to-100 case.ValidationPipeusedforbidNonWhitelisted: false, so requests with unrecognized body fields on money-moving endpoints (FundEscrowDto,SplitReleaseDto,CreateBountyDto, etc.) were silently stripped rather than rejected. Flipped toforbidNonWhitelisted: trueso an unrecognized field now returns a clear 400 instead of a silently-succeeded request.CreateMilestoneDto.deadlineaccepted any syntactically valid ISO-8601 date, including past dates, with no downstream expiry handling to catch it later (same gap as CreateBountyDto doesn't validate that deadline is in the future #108 forCreateBountyDto).FundEscrowDtohad no DTO-level cross-field validation for "exactly one ofbountyId/milestoneId/maintenancePoolId"; the rule was enforced only inEscrowService.assertExactlyOneParent()at the service layer, so Swagger docs didn't reflect the constraint and the resulting error shape differed from other class-validator-driven 400s.Closes #169
Closes #170
Closes #171
Closes #172
Test plan
split-math.util.spec.tscovers the new not-summing-to-100 rejection forapportionBasisPointsapportionBasisPoints/splitStroopstests still pass (no behavior change for valid input)