Skip to content

fix: pre-release review blocking batch (P0 form-encoded mutations + 4 P1s) - #245

Merged
wangrh0909 merged 2 commits into
masterfrom
fix/review-blocking-p0-p1
Sep 30, 2026
Merged

wangrh0909 merged 2 commits into
masterfrom
fix/review-blocking-p0-p1

Conversation

@voidvec

@voidvec voidvec commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

Pre-release blocking batch from the comprehensive v1.3.2..master review (five-track adversarial review ahead of the v1.4.0 release): the single P0 and all four P1s. P2 ride-alongs follow in a second PR; leftover P2s will be registered as tracking issues.

P0 — six self-service mutations sent form-encoded bodies to JSON-only endpoints

The user SPA's axios instance defaults to x-www-form-urlencoded (axios URL-encodes plain objects under that content type), and six calls posted plain objects to handlers that hard-require getJsonObject() — every headline self-service mutation 400'd against the real backend: create org, invite member, accept invitation, nominate successor, create application, profile PATCH. The mock-based e2e suite structurally cannot catch this (Playwright's postDataJSON parses both shapes — the exact PR #140 trap recorded in frontend-contract.md).

Fix: JSON.stringify(body) + explicit application/json header (the established convention; the same diff's rotate-secret call already did it). Regression guard: the org/application create specs now assert request Content-Type and the parsed JSON body (forced-password-change.spec.ts precedent).

P1s (backend)

  1. Audit attribution — the org/open-platform mutation audit rows (consent approve/reject/withdraw, succession nominate/accept/auto-effect, ownership transfer, application create/rotate/transfer/delete) recorded actor=anonymous: the four file-local audit helpers passed an empty actorId. logFromRequest now falls back to the auth filter's userId request attribute when actorId is empty (explicit-actor callers unaffected).
  2. V036 org dimension lands — AuditEvent.orgId + AuditLogger writes audit_logs.org_id; all org-scoped audit sites pass the numeric org id (13 sites in OrgMemberService incl. the create-org callback chain, transfer-ownership, SuccessionGuard auto-effect, org-owned application ops via the owner row).
  3. Invitation tokens hashed at rest (V009 password-reset pattern) — the organization_invitations.token column held redeemable plaintext for up to 72h (grants membership up to role=admin); now stores SHA-256 hex; accept looks up by hash; raw token exists only in the creating frame (mail body + one-time response). Deviation from the review suggestion (rename column to token_hash): a rename needs a migration + ORM regen against a live DB, while hashing into the existing column delivers the identical security property with zero schema churn — cosmetic rename registered as an optional follow-up. Pending dev rows with plaintext become unredeemable (table unreleased; no production data).
  4. Cache invalidation ordering — ApplicationService::update() invalidated the Redis client cache BEFORE the DB write; a concurrent read could re-cache the stale row for a full TTL (removed redirect URIs / grant types kept being accepted). Now invalidates in the update success callback / after the scope write, matching insertApplication's Quota/rate-limit TOCTOU on open-platform creation paths #219 commit-callback ordering and rotateSecret.

Also: the 14 bg-white uses in the three new account pages → bg-surface (semantic token; fixes white inputs in dark mode).

Verification

  • fulla-server + fulla-tests Release build green (MSVC).
  • 17 targeted tests all pass: org create/invite/accept round-trip (exercises the hashed lookup), succession family ×4, consent/consent-request family ×6, org-context gate/chain ×2, open-platform app flow + profile patch, admin owner transfer, route manifest + OpenAPI fingerprint baselines.
  • Frontend: npm run build, vitest 37/37, Playwright 145 passed / 2 skipped (incl. the two new Content-Type assertions), check-ui-sync in sync.
  • Five local gates green. WERROR covered by CI's three platform builds.
  • api-diff baseline force-ratified per policy: source-compatible trailing default argument on DrogonAuditSink::logFromRequest (documented precedent; every existing caller compiles unchanged).

Review-finding mapping

Review finding Severity Resolution
D-1 six form-encoded mutations P0 fixed + e2e guard
E-F1 audit rows anonymous + org_id never written P1 fixed (fallback actor + org dimension)
B-1 invitation token plaintext P1 fixed (hash-at-rest)
C-1/E-F4 cache invalidation before write P1 fixed (post-commit ordering)
D-2 bg-white ×14 P1 fixed (bg-surface)

Out of scope here (second PR / tracking issues): slug 404 folding, transaction guards, consent-request error-vs-no-row, config completeness, rule-file backfill, frontend micro-fixes, transfer-ownership yaml codes.

The axios instance defaults to form-urlencoded; six calls posted plain
objects to handlers that hard-require getJsonObject() — create org,
invite, accept invitation, nominate successor, create application and
profile PATCH all 400'd against the real backend. The mock-based e2e
suite cannot catch this (postDataJSON parses either shape), so the same
spec now asserts request Content-Type + parsed JSON body on the org and
application create flows (forced-password-change precedent).

Also replaces the 14 bg-white uses in the three new account pages with
bg-surface (semantic token; fixes white inputs in dark mode — v1.3.2
baseline had zero bg-white).
…est, cache ordering (P1s)

Pre-release review P1 batch:

- Audit actor attribution: logFromRequest now falls back to the auth
  filter's userId attribute when actorId is empty — the org/open-platform
  mutation audit rows (consent decisions, succession, ownership transfer,
  secret rotation, application ops) previously recorded actor=anonymous.
  Callers passing an explicit actor are unaffected.
- V036 org dimension lands: AuditEvent gains orgId; AuditLogger writes
  audit_logs.org_id; every org-scoped audit site (13 in OrgMemberService,
  transfer-ownership, succession auto-effect, org-owned application
  create/rotate/transfer/delete) passes the numeric org id.
- Invitation tokens are now stored hashed (SHA-256 hex, V009
  password-reset pattern) instead of plaintext: a DB dump can no longer
  redeem org invitations (they grant membership up to role=admin). The
  raw token exists only in the creating request frame (mail body +
  one-time response); accept looks up by hash. Pending dev rows written
  before this change hold plaintext and are unredeemable (table is
  unreleased; no production data exists). Deliberate deviation from the
  review's token_hash-column suggestion: renaming the column would
  require a migration + ORM regen (drogon_ctl needs a live DB) while
  storing the hash in the existing column delivers the full security
  fix with zero schema churn; a cosmetic rename is registered as an
  optional follow-up.
- ApplicationService::update() now invalidates the client cache AFTER
  the write (success callback / post-scope-write), matching
  insertApplication's #219 commit-callback ordering and rotateSecret —
  the pre-commit DEL could let a concurrent read re-cache the stale row
  for a full TTL (removed redirect URIs / grant types kept working).

api-diff baseline force-ratified per policy (source-compatible trailing
default argument on DrogonAuditSink::logFromRequest — the documented
precedent; every existing caller compiles unchanged, build verified).

Verified: fulla-server/fulla-tests Release build; 17 targeted org/
succession/consent/open-platform/baseline tests all pass (incl. the
create-invite-accept round-trip on the hashed lookup); five local gates
green.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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.

2 participants