Fix bug-audit round 2: facets, tx safety, SSR layout, theme + DRY
Fix bug-audit round 2: facets, tx safety, SSR layout, theme + DRY
#48 in Riparion/riparion-cms — merged 2026-06-02
Summary
A fresh parallel multi-agent audit (DB layer, auth/security, server logic, frontend/SSR, KISS/DRY) following the round-1 fixes in #46. Findings were de-duplicated and verified against the code to rule out false positives. No Critical issues this round.
High
- Comment-status consts. Added
STATUS_APPROVED/STATUS_PENDING/STATUS_REJECTEDand routed the comment call sites through them — the same scattered-string-literal class as the already-fixedSTATUS_PUBLISHED, left half-done for comments (a typo would compile and silently break moderation). - Facet bind/SQL coupling.
facet_clausenow returns its ordered bind values alongside the SQL fragment (mirroringqueryloop_where), applied with a single loop. The four copy-pasted.bind()blocks could silently drift out of lockstep with the placeholder order, with no compiler help.
Medium
- Taxonomy delete transactions.
delete_category_db/delete_tag_dbran twoexecute()s with no transaction; a failure between them left a half-applied state. Now wrapped inpool.begin()/commit()likedelete_post_db. - SSR layout swap.
FeedHomeread the feed layout viause_resource(doesn't resolve during SSR), so the server rendered the default layout and the client re-rendered into the real one after hydration. Switched touse_server_future. - Hardcoded theme colors. Replaced
bg-[#111]/bg-[#0f1116]panel surfaces withbg-[var(--primary-color-2)]so they track the--surface-huetheme knob.
Low
insert_variant_dbbindswidth/heightasi32to match theINTEGER(int4) columns rather than relying on a Postgres int8→int4 assignment cast.- Dashboard "Top referrers" list keyed on
referrerinstead of the loop index. - Home
<head>emitsog:urlviahead::absolute_url+ a<link rel="canonical">(both omitted whenSITE_URLis unset, matching posts/pages). - Added
PAGE_COLUMNS/PAGE_SECTION_COLUMNSconsts; routed the four duplicated page SELECT projections through them.
A number of lower-impact / intentional findings were reviewed and deliberately left unchanged (anonymous SSE replaying draft chart data, shared media-library usage visibility, the comment burst cap, per-read syntect highlighting, etc.) — see the local audit notes.
Test plan
cargo fmt --all --checkcargo clippy— server (sqlite), server (postgres), and wasm client — all clean under-D warningscargo test --features server,sqlite— 42 passed- Migrations untouched, so the live-Postgres CI job is unaffected.
🤖 Generated with Claude Code
Last updated 2026-06-03
Links to this note
Credits
Merged pull requests, newest first.