R145-Hygiene: limit-Floor + getContracts fail-closed (Konsistenz)

Pentester R145 (nice-to-have, keine Findings):
1) listAll: limit bekommt einen Floor (Math.max(1, ...)) - limit=-5
   ergab vorher take:-5 an Prisma. page ebenso auf >=1 geklemmt.
2) getContracts nutzte dasselbe 'if (isCustomerPortal && customerId)'-
   Muster und war NICHT fail-closed. Jetzt konsistent zu listAll:
   - Controller: Portal-Token immer gescoped (ohne customerId -> []).
   - Service getAllContracts: 'if (customerIds)' statt '.length > 0',
     damit ein leeres Array strikt auf IN () filtert (0 Treffer) statt
     durchzufallen. Einziger Caller ist der Contract-Controller ->
     keine Regression fuer den Normalfall.

Verifiziert: Staff -> alle; Portal customerIds=[] -> 0 Vertraege/Belege.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-12 11:32:21 +02:00
co-authored by Claude Opus 4.8
parent 4c5548ea3c
commit 8d93c1767b
3 changed files with 20 additions and 14 deletions
@@ -66,8 +66,8 @@ export async function listAll(req: AuthRequest, res: Response): Promise<void> {
}
}
const page = parseInt((req.query.page as string) || '1') || 1;
const limit = Math.min(parseInt((req.query.limit as string) || '50') || 50, 200);
const page = Math.max(parseInt((req.query.page as string) || '1') || 1, 1);
const limit = Math.min(Math.max(parseInt((req.query.limit as string) || '50') || 50, 1), 200);
const search = typeof req.query.search === 'string' ? req.query.search : undefined;
const result = await creditNoteService.getAllCreditNotes({ customerIds, page, limit, search });