Skip to content

fix: hardening kesiapan rilis (header keamanan, bootstrap DB baru, rate limit demo, 503 gateway) - #5

Merged
ronalandroid merged 2 commits into
mainfrom
fix/launch-readiness
Nov 19, 2026
Merged

ronalandroid merged 2 commits into
mainfrom
fix/launch-readiness

Conversation

@ronalandroid

Copy link
Copy Markdown
Owner

Ringkasan

Perbaikan dari audit kesiapan rilis. Semua masalah ini ditemukan saat menguji sistem live dan menjalankan suite lokal.

Yang berubah

  • Header keamanan web (public/serve.json): Coolify menyajikan dist/ dengan serve, yang mengabaikan _headers milik Netlify, sehingga situs live tidak mengirim header keamanan sama sekali. Sekarang ada nosniff, X-Frame-Options: DENY, referrer/permissions policy, HSTS, dan aturan cache yang sama dengan _headers.
  • Database baru menyiapkan diri sendiri (backend/scripts/run-migrations.mjs, backend/bootstrap/): kalau public.stores belum ada, runner menerapkan base-schema dan production-bootstrap sebelum migrasi. Sebelumnya deploy ke database kosong crash di 20260430_0002. File SQL disalin ke backend/ karena konteks Docker hanya backend/; bootstrapSql.test.ts memastikan salinannya identik dengan database/.
  • Rate limit /api/auth/demo-login: satu-satunya endpoint auth tanpa batas, padahal tiap panggilan menjalankan bcrypt dan seeding ulang akun demo.
  • 503 untuk kegagalan gateway: error Mayar dan AI sebelumnya dikirim sebagai 502. Cloudflare mengganti respons 502/504 dengan halaman HTML-nya sendiri, jadi aplikasi hanya menampilkan "Bad gateway". 503 diteruskan apa adanya.
  • npm audit fix (tanpa breaking change): menutup advisory critical @capacitor/android dan proxy-addr, serta advisory DoS body-parser.
  • Tes: e2e-local hanya menjalankan spec miliknya (spec offline butuh build production dan punya runner sendiri); smoke fresh-db mengabaikan inventory toko demo.

Catatan untuk reviewer

  • Masih ada advisory high dari @insforge/sdk → zod@3 yang belum punya perbaikan upstream. Backend hanya mengimpor tipe dari SDK itu dan memvalidasi request dengan [email protected] yang sudah ditambal.
  • PR ini terpisah dari chore(insforge): pindah ke project InsForge baru (Kaffe POS) #4 (pindah project InsForge) dan tidak menyentuh file yang sama.
  • PR ini tidak mengubah konfigurasi production. Pindah ke Mayar production, NODE_ENV=production, dan Sentry masih menunggu key dari pemilik akun.

Tes

  • npm run check: lint, typecheck, 454 tes (212 frontend + 242 backend), build web dan backend: lolos
  • test:e2e:local (3/3) dan test:e2e:offline (1/1): lolos
  • smoke:local:mayar: semua 24 cek lolos
  • smoke:local:fresh-db: lolos
  • Runner migrasi di PostgreSQL kosong: bootstrap, lalu 18 migrasi; run kedua tanpa perubahan
  • Header diverifikasi dengan [email protected] (versi yang sama dengan container)
  • demo-login membalas 429 setelah batas tercapai

🤖 Generated with Claude Code

Ronal Sagala and others added 2 commits November 20, 2026 02:56
- Security headers on the live web app: Coolify serves dist/ with `serve`,
  which ignores Netlify's _headers. Add public/serve.json with nosniff,
  frame DENY, referrer/permissions policy, HSTS and the same cache rules.
- Fresh database self-provisions: the migration runner applies the
  foundation SQL (base-schema, production-bootstrap) when public.stores is
  missing, so a new project or disaster-recovery deploy no longer crashes
  on migration 20260430_0002. Copies live in backend/bootstrap (the Docker
  context is backend/ only); a test keeps them identical to database/.
- Rate-limit /api/auth/demo-login: each call bcrypt-hashes and reseeds the
  demo accounts, and it was the only unthrottled auth endpoint.
- npm audit fix (non-breaking): clears the critical @capacitor/android and
  proxy-addr advisories and the body-parser DoS advisory.
- Tests: e2e-local runs only its own spec (the offline spec needs the
  production build and has its own runner); the fresh-db smoke ignores the
  demo store's seeded inventory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e keeps the JSON error

Cloudflare replaces 502/504 origin responses with its own HTML page, so the
app showed a generic Bad gateway instead of the Mayar or AI error message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ronalandroid
ronalandroid merged commit b673c4d into main Nov 19, 2026
2 checks passed
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