Skip to content

fix(shipping): audit depth + security tightening (SR-5/SR-8) — bia-shared 1.0.0 - #60

Merged
LongXL6 merged 1 commit into
mainfrom
feat/shipping-sr5-sr8-audit-security
Jul 2, 2026
Merged

fix(shipping): audit depth + security tightening (SR-5/SR-8) — bia-shared 1.0.0#60
LongXL6 merged 1 commit into
mainfrom
feat/shipping-sr5-sr8-audit-security

Conversation

@LongXL6

@LongXL6 LongXL6 commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fourth PR of the 2026-07-03 shipping refinement.

SR-5 — the audit log can now reconstruct what happened

  • Payment PATCH (the money trail): reads prior state first; audit payload carries {prior, next} for amount/paid_at/paid_by/method/note — an undo no longer erases who/when/how. Missing parcel → 404 (was a 500 via .single()). Un-marking paid clears the orphaned paid_note (prior value survives in the audit row).
  • parcel.create seeds parcel_events — the status trigger only fires on UPDATE, so officer-created parcels had an empty timeline.
  • routes/contacts audits carry old→new values — these are the public-facing price/dates/contact fields; fields: [...] alone couldn't answer "what was it before".
  • CSV export audited (shipment.export) — it contains member payment data.

SR-8 — the imaginary guardrail is now real

  • bia-shared 1.0.0 (BREAKING): import "server-only" in the service-role factory + root-barrel re-export removed. CLAUDE.md claimed the factory "lives in a server-only export path" — it didn't; 10+ client components import that barrel. Now a client-graph import fails the build. All in-repo importers (members routes, blog/members pages, audit-log, auth callback) switched to the subpath; bia-roommate/george pin ^0.6 and never imported the factory from the barrel (verified by grep), so nothing breaks downstream; they pick this up whenever they bump majors.
  • zod on routes/contacts PATCH (the last hand-rolled mutation bodies): NaN pricing rejected (page sends "12.5" strings — coerced, null preserved), qr_code_url must be http(s), length caps everywhere.
  • qr-upload: storage extension from the validated MIME type, never the client filename.
  • CSV formula guard catches =+-@ behind leading whitespace/control chars (Excel strips them before evaluating).
  • parcels list: NaN limit/offset → 400 instead of a PostgREST 500; shipments/requests lists bounded at 500 rows.

Tests

250 passed (new: value-audit assertions on routes/contacts, NaN rejection, URL validation, timeline-seed, id-set audit); bia-shared 67 passed; server-only aliased to a stub for Node test runs; tsc clean; production build green (which itself now proves no client component pulls the factory).

🤖 Generated with Claude Code

…ared 1.0.0

SR-5 (audit depth):
- payment PATCH: read-before-write, audit carries prior AND next money
  values (undo no longer erases who/when/how); missing parcel is now 404;
  un-marking paid clears the orphaned paid_note (prior survives in audit)
- parcel.create seeds a parcel_events row — officer-created parcels no
  longer start with an empty/misleading timeline
- routes/contacts PATCH audits old→new values (public-facing pricing/
  contact info), not just field names
- CSV export is audited (shipment.export, row count) — it exports member
  payment data

SR-8 (security/validation):
- bia-shared: `import "server-only"` in the service-role factory and the
  root-barrel re-export REMOVED — the CLAUDE.md "server-only export path"
  guardrail is now real, enforced at build time. BREAKING → 1.0.0 (all
  in-repo importers switched to the subpath; bia-roommate/george pin 0.6.x
  and don't import the factory from the barrel — verified)
- routes/contacts PATCH: zod (last hand-rolled mutation bodies) — NaN
  pricing rejected, qr_code_url must be an http(s) URL, length caps
- qr-upload: storage-key extension from the validated MIME type, never
  the client filename
- CSV formula-injection guard also catches =+-@ hidden behind leading
  whitespace/control chars
- parcels list: limit/offset validated (NaN was a PostgREST 500);
  shipments/requests lists bounded (limit 500)

Tests: value-audit + NaN + URL-validation + timeline-seed assertions;
vitest aliases server-only to a stub for Node runs. 250 passed;
bia-shared suite 67 passed; tsc clean; build green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bia-admin-bia-admin Ready Ready Preview, Comment Jul 2, 2026 7:44pm

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@LongXL6, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3426845f-a647-4e2b-8ec7-361c15f932bd

📥 Commits

Reviewing files that changed from the base of the PR and between 32b1e67 and a411be9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (31)
  • bia-admin/app/(admin)/admin/blog/page.tsx
  • bia-admin/app/(admin)/admin/members/page.tsx
  • bia-admin/app/api/admin/members/[id]/__tests__/route.test.ts
  • bia-admin/app/api/admin/members/[id]/route.ts
  • bia-admin/app/api/admin/members/invitations/[id]/__tests__/route.test.ts
  • bia-admin/app/api/admin/members/invitations/[id]/route.ts
  • bia-admin/app/api/admin/members/invite/__tests__/route.test.ts
  • bia-admin/app/api/admin/members/invite/route.ts
  • bia-admin/app/api/admin/shipping/contacts/__tests__/route.test.ts
  • bia-admin/app/api/admin/shipping/contacts/qr-upload/route.ts
  • bia-admin/app/api/admin/shipping/contacts/route.ts
  • bia-admin/app/api/admin/shipping/parcels/[id]/payment/route.ts
  • bia-admin/app/api/admin/shipping/parcels/__tests__/route.test.ts
  • bia-admin/app/api/admin/shipping/parcels/route.ts
  • bia-admin/app/api/admin/shipping/requests/__tests__/route.test.ts
  • bia-admin/app/api/admin/shipping/requests/route.ts
  • bia-admin/app/api/admin/shipping/routes/__tests__/route.test.ts
  • bia-admin/app/api/admin/shipping/routes/route.ts
  • bia-admin/app/api/admin/shipping/shipments/[id]/export/route.ts
  • bia-admin/app/api/admin/shipping/shipments/__tests__/route.test.ts
  • bia-admin/app/api/admin/shipping/shipments/route.ts
  • bia-admin/app/auth/callback/__tests__/route.test.ts
  • bia-admin/app/auth/callback/route.ts
  • bia-admin/lib/admin/__tests__/audit-log.test.ts
  • bia-admin/lib/admin/audit-log.ts
  • bia-admin/lib/auth/__tests__/require-role.test.ts
  • bia-admin/test/server-only-stub.ts
  • bia-admin/vitest.config.ts
  • packages/bia-shared/package.json
  • packages/bia-shared/src/index.ts
  • packages/bia-shared/src/supabase/service-role.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/shipping-sr5-sr8-audit-security

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@LongXL6
LongXL6 merged commit 1002ad0 into main Jul 2, 2026
5 checks passed
@LongXL6
LongXL6 deleted the feat/shipping-sr5-sr8-audit-security branch July 2, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant