fix(cleanup): pagination offset overflow, constant-time code check, module docs (PMS-684) #463
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-684-cleanup"
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?
What
Three small, independent correctness/quality fixes from a codebase review, grouped into one cleanup PR (PMS-684).
Why
?page=99999999with the defaultper_page=25produces an offset of 2,499,999,950, which exceeds i32::MAX; theas i32cast wrapped it negative and Postgres rejected the OFFSET, returning HTTP 500 on the contacts and tickets list endpoints.==on two SHA-256 hex strings, inconsistent with the codebase's own constant-time convention for equivalent secret checks (practical risk is low given the SHA-256 preimage and the attempt cap, but it is a needless inconsistency).CLAUDE.mdanddocs/dev-docs/codebase-state.mdstill claimed only auth/contacts/tenants/tickets have real handlers and that most route groups return HTTP 501, which contradicts the currentapi/router.rs.Changes
pagination.offset() as i32casts (three incontacts/service.rs, two intickets/service.rs) toas i64, matching the ~30 other call sites;limitstays i32 because per_page is bounded.stored_hash == code_hashinverify_login_approvalwithconstant_time_eq::constant_time_eq(stored_hash.as_bytes(), code_hash.as_bytes()), consistent with the TOTP, RMM webhook, and bunyip webhook secret checks.CLAUDE.mdanddocs/dev-docs/codebase-state.md: ~30 modules now have real handlers, thestub_routes()501 mechanism is gone, and the only remaining HTTP 501 is the PDF report-export format (CSV is implemented).Tests
just pre-commit(Docker mirror of CI check.yml, since there is no host cargo): green. cargo fmt --check, clippy --all-targets -D warnings, cargo check --all-targets, 293 unit tests passed / 0 failed, doc tests passed.list_filter_pagination(12 passed) andlogin_approval(5 passed), alongside the rest of the suite. The RLS-isolation binaries (per_user_isolation,rls_isolation) additionally pass (4 and 1) when#[sqlx::test]runs as the superuser, matching CI's DATABASE_URL; with the local dev stack's migrator DATABASE_URL they cannot create the per-test unprivileged role (CREATEROLE), which is a pre-existing environment limitation unrelated to this change.