fix: validate acceptedAssets to prevent silent malformed input (#9)#36
Open
CodeMayor wants to merge 2 commits into
Open
fix: validate acceptedAssets to prevent silent malformed input (#9)#36CodeMayor wants to merge 2 commits into
CodeMayor wants to merge 2 commits into
Conversation
Author
|
Hi there! I've submitted this PR to address the acceptedAssets malformed input validation. All the core checks (build, lint, formatting, and unit tests) are passing successfully. It looks like the CI / Test (e2e) workflow hit a timeout and was automatically cancelled after 360m, which seems like a CI glitch. Could you take a look at the implementation when you have a moment and let me know if you have any feedback or if any changes are needed? Thanks |
Author
|
@Alqku any update ? |
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.
parseAcceptedAssetspreviously silenced malformed asset strings by returningnulland filtering them out, causing campaigns to silently fall back to native XLM acceptance without any error to the creator. This fix adds proper validation at both the DTO and service boundary levels.What I've Built
✅
AcceptedAssetInputDTO (src/campaigns/dto/accepted-asset-input.dto.ts)string[]@MaxLength(100)prevents oversized payloads@Matchesregex enforcesXLMorCODE:ISSUERformat at intake400before reaching service logic✅ Updated
CreateCampaignDto(src/campaigns/dto/create-campaign.dto.ts)acceptedAssetsnow typed asAcceptedAssetInput[]@ValidateNested({ each: true })ensures per-entry validation@ArrayMaxSize(10)guards against array flooding attacks✅ Hardened
parseAcceptedAssets(src/campaigns/campaigns.service.ts)BadRequestExceptionfor empty values, missing code, missing issuer, wrong separator formatSecurity Implementation
Testing
✅ 14 unit tests (
src/campaigns/tests/parse-accepted-assets.spec.ts)Files Changed
src/campaigns/dto/accepted-asset-input.dto.tsNew hardened input DTOsrc/campaigns/dto/create-campaign.dto.tsUpdated to use structured asset inputsrc/campaigns/campaigns.service.tsparseAcceptedAssetsnow throws on malformed inputsrc/campaigns/tests/parse-accepted-assets.spec.ts14 passing unit tests