fix(contacts): validate company create/update input to 422 not 500 #232
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pms-297-company-create-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fuzzing POST /api/v1/contacts/companies surfaced inputs that passed the application layer, failed in Postgres, and leaked as HTTP 500 DATABASE_ERROR. Validate them at the request-model layer so bad input never reaches the DB and returns 422 instead.
Add request-layer validators in mokosh-types::contacts and apply them to CreateCompanyRequest and UpdateCompanyRequest (the sibling endpoint shares the columns and the same 500 class): name is rejected when whitespace-only or containing control characters (which includes NUL); website is bounded to the VARCHAR(255) column size and must be an http/https URL, blocking javascript:/data: schemes that drive the stored XSS in MAPPS-149; all other scalar text fields, nested Address fields, and tags reject NUL bytes that Postgres text/varchar columns cannot store.
#PMS-297
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com