Repository navigation
fix(backend): accept only plain integers in route params and DTOs - #4342
Conversation
The global ValidationPipe converts numeric params with `+value` before any param pipe runs, so ParseIntPipe let "0x10", "1e3" or "007" through. - parseStrictInt + IntParam decorator read the raw param (digits only, no leading zero, min / max bounds); usagerRef and etapeDemande use it - StrictIntTransform for DTOs: converts "3" to 3, leaves anything else raw so @ISINT rejects it; replaces @type(() => Number) and Number(value) - MetabaseStatsDto.structureId is now a validated integer
There was a problem hiding this comment.
Revi — aucun problème détecté dans le périmètre revu.
À confirmer
- Is the Metabase dashboard's
structureidparameter defined as a numeric filter so the signed value now sent as a number (previously a string) still matches — if it is text-typed, the structure filter on the structure stats screen could silently stop applying? - USAGER_REF_MAX = 100_000 is a silent hard cap on the usagerRef param: refs are per-structure sequential from 1, but if any structure ever crossed 100k its records would become API-unreachable (400) — is that bound confirmed safe for all production structures?
Détails du run IA · Iterion
Run : 01a17d43-53c5-74a1-978c-12a13cf00f2a
Tokens du run au moment de publier : 112 799.
Périmètre revu : correctness: packages/backend/src/_common/decorators/parse-pipes/ParseStrictInt.pipe.ts (regex, bounds, IntParam) ; correctness: packages/backend/src/_common/decorators/parse-pipes/ParseUsagerRef.pipe.ts, ParseEtapeDemande.pipe.ts ; correctness: packages/backend/src/_common/decorators/transformers/StrictIntDecorator.ts (toStrictInt passthrough semantics) ; security: packages/backend/src/auth/guards/usager-access.guard.ts, usager-note-access.guard.ts (strict parse, throw paths, log-level change) ; correctness: usagers controllers (usagers, usager-docs, usager-notes, usager-options, usagers-decision) — param decorator swaps, next-step bounds moved into EtapeDemandeParam ; correctness: interactions.controller.ts, portail-usagers-manager.controller.ts, users-supervisor/users.public controllers (IntParam on userId, procuration index) ; data: DTOs — page-options, brevo-email-events, sessions-stats, suspicious-activity, MetabaseStats, structure-registration (activeUsersCount IsNumber→IsInt), reset-password, new-referrer-id, update-role, assign-referrers (transform + @ISINT pairing) ; integration (surrounding code): metabase-embed.helper.ts + check-territories.ts consumption of now-numeric structureId; usagersCreator.service.ts ref generation (min 1, sequential); remaining :usagerRef routes without the decorator (agenda, usager-structure-docs, enable-access, patch/delete) verified guard-covered; global ValidationPipe config (app.bootstrap.ts, transform:true, implicitConversion:false); ParseIntPipe leftovers (none); frontend padStart on refs (none) ; tests: parse-usager-ref-pipe.spec.ts, parse-etape-demande-pipe.spec.ts accept/reject matrices; usagers.controller.security-tests.ts 999999→99999
Revue mono (single model family).
| Étape | Modèle | Harness | Effort demandé | Tokens |
|---|---|---|---|---|
| Revue GLM | glm-5.3 | claude_code | max | 78 857 |
| Synthèse · GLM | glm-5.3 | claude_code | medium | 33 942 |
Tokens cumulés des appels IA, pas la taille du contexte. L’effort indiqué est le réglage demandé au modèle.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## fix/usagers-search-partial-results #4342 +/- ##
======================================================================
+ Coverage 64.18% 64.27% +0.08%
======================================================================
Files 1076 1080 +4
Lines 22856 22899 +43
Branches 4534 4566 +32
======================================================================
+ Hits 14670 14718 +48
- Misses 7891 8100 +209
+ Partials 295 81 -214
... and 80 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
|
🎉 This PR is included in version 2.288.6 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |



Stacked on #4341.
Problem
The global
ValidationPipe(transform: true) converts numeric params with+valuebefore any param pipe runs.@Param("x", new ParseIntPipe()) x: numbertherefore accepted"0x10"(→ 16),"1e3"(→ 1000),"007". Same for@Type(() => Number)/Number(value)in DTOs.Changes
parseStrictInt(value, { min, max }): digits only, no sign, no leading zero, no exponent / hex / decimal, then bounds@IntParam({ name, min, max }): custom param decorator reading the raw param (replacesParseIntPipeonuserId×2 and procurationindex)UsagerRefParam/EtapeDemandeParamand the usager guards use the same parser@StrictIntTransform()/toStrictIntfor DTOs:"3"→3, anything else left raw so@IsInt/@Min/@Maxreject it. Replaces@Type(() => Number)(pagination, Brevo, suspicious-activity, sessions-stats) andNumber(value)(newReferrerId, reset-passworduserId,activeUsersCount, Metabaseyear)MetabaseStatsDto.structureId:@IsNumberString→@IsInt+@Min(1), now a real numberuserId(rdv) andreferrerId(search, create-usager):@IsNumber→@StrictIntTransform+@IsInt+@Min(1)contact-support form data (
userId,structureId):cleanFormDataValueusesparseStrictIntinstead ofNumber()Reset password form (frontend, portail-admins, portail-stats): drop the unused
parseInt(userId); the raw route value is sent anduserIdis typedstringin the serviceRejected:
3X3,1e3,0x10,007,-1,1.5," 1","".To check
structureIdas a number instead of a string (structure stats screen in portail-admins)