سامانه صدور فاکتور و حسابداری
docs(finora): record two confirmed real JWT inventory posting authorization bypass paths
davoodmehraban89 committed
Nov 23, 2026 at 19:44 UTC
cca5e61283198b5afc4f81b68d1984ae98bd568a
1 file changed
+8
PROJECT_STATE.md
+8
@@ -887,3 +887,11 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
887
- **New audit finding, test fidelity correction**: real product `js/phase5-enterprise.js::p5SaveCount` persists `systemQty`, `physicalQty`, `difference`, while PR244's disposable direct posted `inventoryCounts` JSON used `expectedQty`, `actualQty`, `diff` (from prior test fixture). RLS status bypass and HTTP201 persistence are real regardless, but this is not canonical count payload fidelity. Tighten the QA count fixture to the actual client schema; preserve exact owner JWT readback and original direct create-only test.
888
- **Distinct unverified follow-on hypothesis**: `records_update` in `20260930031853_organization_membership_rbac_foundation.sql` requires `inventory:edit` but no approval of JSON `status`, while `finora_guard_phase5_posted_records` only blocks mutation if OLD was `posted`; client can plausibly create a draft then PATCH to `posted` without `inventory:approve`. This must be verified through real Auth-issued JWT/PostgREST with a separate non-owner member possessing only `inventory:create,inventory:edit` company A1 scope (no approve). Distinct from the existing create-only JWT and read-only JWT in PR243. Grant a third fixture seat via **disposable A license `max_users=3`** while retaining real license trigger. For each `stockMovements` and `inventoryCounts`, create true `draft` first, verify owner readback, PATCH same row status to `posted`, independently readback with real owner JWT. Distinguish `FINORA_PHASE5_POSTED_UPDATE_WITHOUT_APPROVE_EXPECTED_RED` (both successful persisted) from proper denial `FINORA_PHASE5_POSTED_UPDATE_APPROVAL_PASS` (both denied and still draft); mixed or unknown outcomes fail closed. Keep the original direct INSERT expected-RED/approval-PASS markers intact. No weakening/x-failing legitimate assertions.
889
- **Scope:** existing PR244 QA script, narrowly scoped existing WP2 workflow step already covers script (no new step), append-only canonical docs; do NOT change product JS, SQL, migrations, RLS/Auth/grants, history, Production, main, release, or Codex-main exclusive financial implementation. After implementation, run exact-head WP2/Quality/WP1/Security and independently verify log/SHAs; if fixture fails, fix only evidence-justified fixture. Notify Issue245 of actionable dual-path contract. Product progress remains A90/B50/C20/D55/E53/F10 despite added proof.
890
+
891
+
892
+### 2026-11-23 — FIN-QA-245-CANONICAL-COUNT-AND-UPDATE / actual real-JWT proof, product still P0 RED
893
+- **Executed QA code SHA** `e0d57689ebe4cb6d68926b536964b3ca30b75a61`, [WP2 #45213314699](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314699) **COMPLETED SUCCESS on disposable local Supabase** with three real Auth-issued JWT users (owner, creator-only non-owner, read/create/edit non-owner). Local A license `max_users=3` only to preserve actual seat trigger for 3 genuine identities, not Production. Org/company scope A1 and no inventory:approve for either non-owner JWT.
894
+- **Insertion proof unchanged but source-fidelity strengthened:** `FINORA_PHASE5_POSTED_INSERT_WITHOUT_APPROVE_EXPECTED_RED` confirmed create-only A1 member directly inserted `status='posted'` in `stockMovements` and `inventoryCounts` through PostgREST, each **HTTP 201**, exact owner-JWT readback. Count data now uses the **real client** `systemQty/physicalQty/difference` fields from `js/phase5-enterprise.js::p5SaveCount`; earlier `expectedQty/actualQty/diff` QA fixture was noncanonical, and the earlier green is not misrepresented as validating client schema.
895
+- **New, independently observed P0 via authenticated UPDATE:** `FINORA_PHASE5_POSTED_UPDATE_WITHOUT_APPROVE_EXPECTED_RED` confirmed A1-scoped member with `inventory:read/create/edit` and NO `inventory:approve` successfully inserted true draft stock/count rows then directly PATCHed both to POSTED; **HTTP204 for both**, with independent owner JWT readback verifying exact posted payloads. `FINORA_PHASE5_POSTED_UPDATE_JWT_EVIDENCE` logs both `posted_without_approval`. This supersedes the preceding *hypothesis* with execution. Any naive INSERT-only policy repair is incomplete: `records_update` checks edit, and existing Phase5 trigger locks only OLD posted. Existing actual posted-UPDATE/DELETE immutable guard still independently PASS.
896
+- **Owner handoff**: [Issue245 implementation contract comment](https://github.com/davoodmehraban89/Factor-easy/issues/245#issuecomment-7106764847) maps `js/phase5-enterprise.js` Save→posted, `js/sync.js` generic sync, `records_insert`/`records_update` RLS and Phase5 posted guard; [Issue245 real-JWT dual path evidence](https://github.com/davoodmehraban89/Factor-easy/issues/245#issuecomment-7106797951) requires both INSERT and draft→posted UPDATE denial and positive independent authorized finalize. `finora_sync_records` SECURITY INVOKER is an additional channel to verify, not a claim it was directly tested in this slice. Codex-main retains sole financial/inventory/RLS implementation and code review. Issue229 sale/purchase unauthorized post remained expected PRODUCT RED in same WP2, not fixed.
897
+- **Actual QA scope:** only existing `scripts/wp2-phase5-posted-insert-approval-jwt-e2e.mjs` modified; workflow still has one existing step/path filter. No app JS, SQL/migrations, RLS/Auth/grants, Production, posted history, protected main merge/release/deploy. This note plus `docs/EXECUTION_STATUS.md` creates new docs-inclusive SHA; exact final-head four workflows required. On tested CODE SHA Security [#45213314209](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314209) SUCCESS; Quality [#45213314753](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314753) and WP1 [#45213314488](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45213314488) still in progress at this entry. Six-stage progress unchanged A90/B50/C20/D55/E53/F10; this is evidence, not a product repair.