سامانه صدور فاکتور و حسابداری

docs(finora): require real JWT positive control before labeling sync RPC posted denial secure

davoodmehraban89 committed Nov 23, 2026 at 22:13 UTC 504dc80b144ee87c9f626c8f2d8444f37308d63d
1 file changed +6
PROJECT_STATE.md
+6
@@ -901,3 +901,9 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
901 - User continues the scoped Finora QA/integration task. Protected main remains `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`; Draft PR244 final prior exact SHA `c9696556496d4d7aad066a3049808155516513ee` had all four GitHub gates Quality/WP1/WP2/Security SUCCESS. **That green WP2 is confirmed PRODUCT P0 RED** for two direct PostgREST paths: unauthorized initial posted INSERT (HTTP201/201) and unauthorized draft→posted PATCH (HTTP204/204) for both inventory source collections. Issue245 (stock/count) and Issue229 (sale/purchase approval) remain open. No Codex-main product repair or protected-main merge verified.
902 - **Distinct untested bypass surface**: `js/sync.js::runSync` calls public `finora_sync_records` (3-arg SQL SECURITY INVOKER). `20260930031853_organization_membership_rbac_foundation.sql` uses `INSERT ... ON CONFLICT DO UPDATE` into `records`, RLS checks `create/edit` but has no independent `inventory:approve` status gate. Static analysis implies the same risk for initial posted upsert and draft→posted upsert, but this RPC path **must not be claimed reproduced until actual JWT execution**. Prove with real Auth-issued creator-only non-owner company A1 JWT and read/create/edit non-owner A1 JWT already present in existing local WP2 QA script, using `/rest/v1/rpc/finora_sync_records` and independent owner JWT exact readback for BOTH `stockMovements`/`inventoryCounts`.
903 - **Allowed scope**: extend ONLY existing `scripts/wp2-phase5-posted-insert-approval-jwt-e2e.mjs`; retain previous direct REST INSERT/PATCH markers and fixture fidelity, one existing WP2 workflow step, existing real license/permissions and fail-closed checks. New independent markers `FINORA_PHASE5_SYNC_RPC_POSTED_INSERT_WITHOUT_APPROVE_EXPECTED_RED`, `FINORA_PHASE5_SYNC_RPC_POSTED_UPDATE_WITHOUT_APPROVE_EXPECTED_RED`, with corresponding `*_APPROVAL_PASS` only when server denies BOTH collections without side effects; partial states or mismatched readback fail. Never use service-role to attempt unauthorized posting. On successful QA, append post-evidence to this document and `docs/EXECUTION_STATUS.md`, update PR244/Issue245 comments, verify exact final-head four gates. Codex-main exclusively owns app JS, migrations/RLS/Auth/grants and integration/merge/release; no production, historic financial records or protected main edits. No product-progress inflation: A90/B50/C20/D55/E53/F10.
904 +
905 +
906 +### 2026-11-23 — FIN-QA-245-SYNC-RPC-POSITIVE-CONTROL / QA correction before further testing
907 +- First actual sync-RPC QA code SHA `f9255e2153b10b3dcf272e2478f0086bc94c6382`, [WP2 #45240907560](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45240907560) **COMPLETED SUCCESS with expected PRODUCT RED** for authenticated generic sync draft→posted: non-owner company A1 `inventory:read/create/edit` without `inventory:approve` directly upserted both stockMovements/inventoryCounts from draft to POSTED, RPC HTTP204/204, independent real owner JWT readback exact persisted state. Existing direct PostgREST INSERT201/201 and draft→posted PATCH204/204 P0 RED remain.
908 +- **Important potential false-positive correction:** the same run returned RPC HTTP403/403 for *posted create* by a separate `inventory:create`-only actor with no persisted rows. It emitted `FINORA_PHASE5_SYNC_RPC_POSTED_INSERT_APPROVAL_PASS`, BUT that marker is not yet a proven status-specific approval enforcement: SQL `finora_sync_records` uses `INSERT ... ON CONFLICT DO UPDATE`, which may be blocked for any create-only actor because of UPDATE RLS, even for a legitimate draft. Thus do **NOT** claim the RPC insert approval boundary is repaired or safe until a **positive-control draft create via the same real creator-only JWT, same RPC, same collections** is proved. If generic sync denies both lawful drafts, report a distinct known-product-R​ED/capability failure (not permission security PASS) with safe error code only and no secrets, and retain the confirmed separate UPDATE P0. Preserve all prior RED/PASS assertions and fail closed on partial or third states.
909 +- Scope remains a narrow existing QA test script plus append-only canonical docs/Issue245 handoff, no product SQL/RLS/JS/Auth changes or protected main/Production writes. Commit/retest on exact SHA. Phase A90/B50/C20/D55/E53/F10 unchanged.