mirror of
https://github.com/monoscope-tech/monoscope.git
synced 2026-11-16 10:18:01 +00:00
Quality sweep: two cross-tenant reads, a secret leak, and thirteen other bugs
An overnight pass applying /hs-distill, /hs-lob-review and /hs-evasion-review across the feature groups worked on in the last six months: log explorer, service map, replay, bots, monitors, issues, endpoints, billing, auth/server/MCP, the pattern/AI pipeline, and the shared UI components. Security: - selectIssueById was unscoped -- it and selectIssueByIdScoped differed only by `AND project_id = ?`, so any tenant knowing an issue id could read the row. - EnvConfig derived Show while holding ~15 secrets, and is a field of BWConfig which also derives Show; one `show bwconf` in a log line printed the whole credential set. - Basic-auth credentials were compared with `==`; now constant-time. Correctness: - Monitors' `active` flag was DB-inert: the upsert omitted deactivated_at, so creating a monitor with active:false answered "disabled" while the row kept firing alerts. - Load-more paging silently skipped up to 999us of rows per page (a 1ms cursor epsilon against an inclusive bound). - The two log-level whitelists had drifted, so `fatal` fired rate-change alerts but never opened an issue. - HOST_URL's trailing slash produced `//p/` in every query-monitor alert URL and in the public share-link endpoint. - The dashboards empty-state CTA rendered a modal id as an href and did nothing. - Syntax highlighting never re-ran after any htmx swap; the highlight theme went stale on toggle. - updateUrlState existed twice with incompatible signatures; the surviving one dropped the URL fragment. - chart.updateRollup is implemented nowhere and threw on every use. - navigateSpans indexed past the last span; .waterfall-active accumulated forever. - Eq ZonedTime was `_ == _ = True`, making any test that compared a whole Issue vacuous on three fields. Consolidation and typing: - processBackgroundJob: 655 lines to 106, by extracting five inline case arms. - The HTML/API issue-listing fork unified behind one GADT-parameterised projection. - Three bot integrations reduced to one shared pipeline keyed on a sum type. - Billing's four adjacent transposable Text arguments became five newtypes. - Endpoints' 11-parameter signature became a record; its archive/unarchive boolean fork became one function over a sum type. - Every `any` removed from the service-map and session-replay TypeScript; five duplicated frontend helpers and three disagreeing level vocabularies unified. - One empty-state vocabulary across Table and Components; a second, entirely dead empty-state path deleted. Net -200 lines across ~75 files. Where lines were added it was deliberate type strengthening, called out per commit. Verified: 128 modules, 273 unit examples, 1382 doctests, 901 vitest, tsc clean under strict, and 793 integration examples / 0 failures. QUALITY-SWEEP-NOTES.md records nine open decisions deliberately not actioned -- most notably basic auth minting a persistent_sessions row per request (same failure class as the 2.5M-row incident documented in that file), and flushDrainTask writing orphaned pat:<hash> span tags. It also notes that weeder's binary is a dangling symlink, so the dead-code sweep CLAUDE.md mandates has been silently unavailable.
This commit is contained in:
commit
597fd51207
85 changed files with 3300 additions and 3347 deletions
Loading…
Add table
Add a link
Reference in a new issue