Repository navigation
admin: sensitive-field classes (financial, credentials, user content) + #23279 review follow-ups - #23330
Conversation
#23279 review follow-ups Generalize the financial field wall into a classification table (lib/sensitive-fields.ts): one redactor, one table, one wall test that sweeps every scoped GET per class. Credentials never reach the browser; private user content needs users:read. Follow-ups to #23279 Codex review findings that still apply at HEAD: - app reads strip MCP integration credentials (credentials class) - Chat Lab question sampling needs users:read; content:read keeps curated questions only - CSAT stats gated content:read; free-text comments wall-gated users:read - agent add_member proposals and direct invites share the per-email lock; membership re-checked inside the filing transaction; a pending proposal refuses a duplicate direct invite - the next filing persists stale proposals' expiry (system actor) - org edit dialog sends no billing field without finance:write - Apps page and classic dashboard hide finance/content-scoped cards - auth/invalid-id-token answers 401, not 500
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
A member with finance:write but not finance:read sees the subscription redacted; the edit form sent the blank Stripe field and PATCH cleared the subscription. The form now hides the field and the route refuses billing changes without both scopes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 874d1cf0ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // CSAT free-text feedback rows | ||
| "comment", |
There was a problem hiding this comment.
Hide CSAT rows when their comment text is redacted
For a built-in Viewer, who has content:read but not users:read, this removes comment from each CSAT row while leaving the comments array nonempty because summarizeCsatRatings filters the rows before authResult.json applies redaction. The CSAT page checks only stats.comments.length and maps every remaining row, so viewers see up to 50 blank “Latest comments” cards with UID and platform metadata instead of the “No comments yet” state. Omit these rows or gate that section when users:read is absent rather than redacting only the leaf field.
Useful? React with 👍 / 👎.
| // Billing is a finance action (finance:write on the server). Without it the | ||
| // Stripe field is neither shown nor sent, so an ordinary metadata edit never | ||
| // reads as an attempt to change billing. | ||
| const canBill = access ? can("finance:write") : false; |
There was a problem hiding this comment.
Do not send a redacted billing value as an update
When a partner editor has finance:write but not finance:read—a valid combination through scope overrides—canBill is true even though the organization response redacts subscription. Opening the edit dialog therefore initializes stripe_payment_id to "", and saving any unrelated metadata sends that empty value; the PATCH handler interprets it as an explicit request to set subscription to null, silently clearing existing billing. Require read access before treating the loaded field as editable, or send the field only after the user explicitly changes it.
AGENTS.md reference: web/admin/AGENTS.md:L6-L6
Useful? React with 👍 / 👎.
Design note
#23279 guarded routes with scopes and money fields with a financial redactor. This PR generalizes the field wall into a classification table: one redactor, one table, one generic wall test. Scope checks stay the authority for routes; the table is the authority for fields that ride along inside documents a route legitimately reads.
lib/financial-fields.ts→lib/sensitive-fields.ts:SENSITIVE_FIELD_CLASSESmaps each class of sensitive data to the scope that unlocks it and the field names (plus prefixes) it covers.AdminIdentity.jsonapplies the one deep redactor to every scoped response with the caller's effective scopes.scope: nullis never returned to the browser by any caller — owners included — unless a route explicitly opts in per response viakeep(with a comment and a wall test; no route does today). Credentials are that class.token(TV share links serve tokens by design),email(partner/employee emails are business contacts, not end-user data),text(release notes and announcements share it; Chat Lab sampling is gated at the route instead).lib/__tests__/sensitive-wall.test.ts(renamed fromfinancial-wall.test.ts) sweeps every scoped GET handler three ways — a deputy deniedfinance:read(no financial field), a deputy deniedusers:read(no user-content field), and an owner (no credential field) — with every document seeded with the whole table. Adding a field or a class later is one line in the table; the sweep then covers it everywhere.web/admin/docs/data-contracts.md.Classification table
financialstripe_,payout)finance:readcredentialsapi_key,client_secret,code_verifier,mcp_oauth_tokens,access_token,refresh_token,webhook_secret,private_key,secret,passworduser-contentcomment(CSAT free text),transcript,memories,your_questions,all_users_questions(Chat Lab sampling)users:read#23279 Codex review findings at HEAD
Fixed here (10):
apps:readcredentialsclass in the wall; whole-plugins_dataresponses loseclient_secret/mcp_oauth_tokens/… for everyonesensitive-wall.test.ts: credentials sweep + "strips integration credentials from app reads"content:readusers:read(no user-message reads otherwise); content-only callers get curated questions; the wall also strips the sampling arrayssensitive-wall.test.ts: two chat-lab tests (incl. the no-curated fallback path, wheretextis too generic for the wall)analytics:readwithout content accesscontent:read(matches the page); free-textcommentwall-gated onusers:readroute-scopes.test.ts(content:read policy) +sensitive-wall.test.tsCSAT testpendingforever (pending queries grow without bound)docs/team-access.mdalready promisedagent-team.test.ts: "persists the expiry of stale proposals on the next filing"add_memberproposals not serializedinvite-<digest>); membership re-checked inside the filing transaction; a live pending add-person proposal refuses a duplicate direct invite (409) until decidedagent-team.test.ts: overlap test (exactly one lands) + pending-invite teststripe_payment_id: '', 403-ing every metadata edit for partner editorsfinance:write; the PATCH response's billing fields are wall-strippedorganizations-edit.test.tsxDashboardStatsfetches/renders the two subscription cards only withfinance:readdashboard-stats.test.tsxcontent:readclassic-dashboard-finance.test.tsxauth/invalid-id-tokenanswered 500BAD_TOKEN_CODES→ 401auth.test.tsfinance:readholders bypassed the copy step entirely, and only GETs were swept)Already fixed at HEAD in #23279 (citing the tests that pin them): atomic proposal limits (
agent-team.test.ts"holds the per-agent cap under a burst of overlapping proposals"), per-target dedup across kinds ("refuses a pending proposal of another kind for the same target"), live proposals behind a long history ("keeps an older pending proposal listed…"), stale proposals displayed as expired on pure reads ("shows stale proposals as expired…"), system-actor expiry attribution (same tests), invite-email failures surfaced on approval ("tells the approver when an approved add-person invite email fails…"), partial-failure surfacing on the Team page (proposalsError/auditErrorrendered), Grafana embed + wall series finance-gated (route-scopes.test.ts), finance widgets hidden on the classic fallback (classic-dashboard-finance.test.tsx), write controls gated by write scopes (admin-access.test.tspageWriteScope), access refresh on focus/60s (hooks/useAdminAccess.ts).Obsolete: the invite-cleanup Auth-deletion race — deletion was removed from
addMember; provisioning is never rolled back ("never deletes an Auth account a concurrent invite adopted").Test evidence
npm run checkinweb/admin(lint + typecheck + 1041 tests) andmake preflightpass. Each new test was proven to fail with its fix reverted toorigin/main(or with the class removed from the table):auth/invalid-id-tokenclassificationauth.test.ts"answers an invalid token with 401, not 500"sensitive-wall.test.ts"serves no sampled chat-lab questions without users:read even when none are curated"route-scopes.test.ts"forbids a member who has every scope except content:read"user-contentclasscredentialsclassagent-team.test.tstestsorganizations-edit.test.tsxdashboard-stats.test.tsxclassic-dashboard-finance.test.tsxUI-Evidence: none -- the UI changes only hide widgets/fields callers lack the scope for; each is pinned by DOM-level component tests above
🤖 Generated with Claude Code