feat(api): add length validation to all *Filter query types (F9) #54
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-123-filter-validate"
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?
Closes PMS-123. Subtask of PMS-121 (F9).
Background
Most
*Filtertypes insrc/modules/*/models.rsalready derivevalidator::Validate, but the derives were empty: no field-level constraints, so handlers callingfilter.validate()?were passing untrusted query-string strings straight into SQLILIKE/=patterns with no length cap.Five filters were already fully validated (TicketFilter, CompanyFilter, ContactFilter, InvoiceFilter, PaymentFilter). Nine filters had the derive but no attributes. One filter (CalendarEventFilter in
src/modules/calendar/mod.rs:41) lacked the derive entirely.Change
AuditLogFilter:length(max = 100)onentity_type,action.ContractFilter:length(max = 100)oncontract_type,status.KbArticleFilter:length(max = 100)onstatus,visibility;length(max = 200)on the free-text search fieldq.AppointmentFilter:length(max = 100)onappointment_type.TimeOffFilter:length(max = 100)onstatus.ProjectFilter:length(max = 100)onstatus.AssetFilter:length(max = 100)onstatus.CalendarEventFilter: add thevalidator::Validatederive and wirefilter.validate()?into theGET /api/v1/calendar/eventshandler (src/modules/calendar/routes.rs:65-70) so the route matches the convention even while it still returns an empty list.The 100 / 200 split mirrors the existing TicketFilter / CompanyFilter / ContactFilter pattern (q at 200, tags at 500, short identifier-like fields at 100).
TimeEntryFilterandTimesheetFilterhave noOption<String>fields, so the existingValidatederive plus the handler call are already sufficient.Acceptance
*Filterquery types validate input" is met after this PR.just check-docker(release-profile builder stage) compiles cleanly.Out of scope
filter.validate()?helper called out in the parent story; the existing inline?call site pattern is consistent across every list handler and works fine.