سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 17:00 UTC
docs(phase1): record validated 4-pass live permission checks and stale PR #58 hazard
davoodmehraban89 committed
Oct 13, 2026 at 13:04 UTC
a62ca110dad7051e3fcac405f0a19a033404df90
1 file changed
+6
PROJECT_STATE.md
+6
@@ -164,6 +164,12 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
164
- **Initial independently executed read-only catalog findings:** public tables **18/18 RLS**, private tables **3/10 RLS**, **zero anon/authenticated SELECT grants to all 10 private tables**; SECURITY DEFINER routines: public **27** (of which **21 authenticated EXECUTE**, **0 anon EXECUTE**, **27 configured search_path**); private **66** (of which **43 authenticated EXECUTE**, **0 anon EXECUTE**, **66 configured search_path**). Authenticated has USAGE on private schema, whereas anon does not; this requires reviewing actual API exposure and callable routine guards, **not** assuming no possible access or an exploitable vulnerability. The 21 public authenticated-callable warnings are review inputs. Six sampled public admin-license mutators explicitly call `public.is_admin()`; sampled organization invitation/workflow functions use `auth.uid()` and capability checks, but this is **source review, not authenticated adversarial execution proof**.
165
- **This isolated slice:** deliver an executable **read-only permissions/assertion SQL audit** and a Phase 1 evidence memo with repeat procedure, expected invariants, unresolved negative tests and risk priority. Verify against live metadata with SELECT only, plus repo presence/readback; no DB or service changes, no test identities. Record exact output, SHA and outcome after the fact. This is a **Phase 1 verification slice**, not Phase 1 acceptance; additional two-user revocation, adversarial grants, backup/restore, advisor reviews and sign-off remain OPEN. Rollback revert docs/test-file PR.
166
167
+### 2026-10-13 Phase 1 permissions audit — LIVE SQL 4 PASS / 2 REVIEW / NO DATABASE MUTATION / PR CI PENDING
168
+- **Executable deliverables on isolated branch:** `supabase/tests/phase1_permissions_readonly.sql` (catalog-only SELECT audit) and `docs/FINORA_PHASE1_SECURITY_READONLY_AUDIT_2026-10-13.md` (repeat procedure, 21-function risk roster, historic migration discrepancy). SQL was **fetched back from GitHub** and executed read-only via production Supabase metadata access. Exact results: `PUBLIC_ALL_RLS` PASS **18/18**, `PRIVATE_NO_CLIENT_DIRECT_READ` PASS **0 of 10 exposed**, `PUBLIC_DEFINER_NO_ANON_EXEC` PASS **0 of 27**, `DEFINER_EXPLICIT_SEARCH_PATH` PASS **93/93**; `PUBLIC_AUTHENTICATED_DEFINER_REVIEW` REVIEW **21**, `PRIVATE_RLS_COVERAGE_REVIEW` REVIEW **3/10**. **4 PASS / 2 REVIEW / 0 FAIL**. The 21 live advisor warnings match exactly the 21 `public` authenticated-callable SECURITY DEFINER routines.
169
+- **Concrete regression hazard from independent production function review:** stale open PR #58 `20261007163500_phone_identity_profile.sql` defines `public.handle_new_user` with `organization_members` inserted **before** `licenses`. Current live function, after Oct-12 safeguard, deliberately inserts `licenses` **before** `organization_members` so the seat guard can evaluate capacity. **Do not reapply the stale old function or merge PR #58 as-is.** Mismatched old archive filename `20261007163500` vs live migration ledger `20261007165208` remains unresolved; exact executed SQL-body parity NOT VERIFIED.
170
+- **Source review of all 21 public authenticated-callable SECURITY DEFINER routines** completed using `pg_get_functiondef`, grouped into six admin license mutators (explicit `is_admin`), two read predicates, seven office, five organizational/invitation, one own-profile RPC. Static guard presence does **not** prove correct tenant isolation or absence of privilege escalation. Authenticated two-user revocation/adversarial parameter checks, private RPC exposure, leaked-password protection, backup/restore and migration parity remain OPEN and require appropriate approval/test identities.
171
+- **Boundaries:** Owner-directed deferral of F0-01 slowness persists; F0-01/Phase 0 OPEN. Phase 1 audit slice metadata verification PASS only; **Phase 1 owner acceptance NOT CLAIMED**. No JS runtime, production SQL DDL/DML, Auth/RLS/grant change, new identities, financial records, subscription payments or secrets touched. PR Quality/Security and any post-merge exact-SHA gates **PENDING at this checkpoint**; do not claim release until verified. Rollback revert documentation+read-only SQL check.
172
+
173
## Current change ledger
174
| 2026-10-07 | Owner requested accounting/product usability refinement from live screenshots: automatic non-user-entered floating-detail codes, contextual in-product guides (especially accounting/chart/dimensions), remove duplicate product internal tax ID and use product code as internal item ID, strengthen in-control product/person search, introduce hierarchical product group/subgroup coding with deterministic 6-digit product codes, and keep sale/purchase commercial-document workspace layout stable while only semantic fields change. | **IMPLEMENTED / LOCAL VERIFICATION PASSED / CI PENDING** | Baseline main = `7e58c75f7d754f378d94ca3f356c1ae580aa7ee3`. Automatic dimension type/value codes, contextual guides, product-code-as-internal-ID, normalized multi-token search, and additive six-digit product coding implemented. Existing historical codes preserved. Commercial sale/purchase workspaces now share a stable `صدور سند تجاری` header/actions layout; duplicate purchase sidebar injection removed; the public selector is the single document-type selector and the legacy internal invoice-kind control is hidden. Local syntax/static/commerce/UX/accounting phases 2–6/Golden checks passed; protected-branch CI remains pending. |
175