Repository navigation
fix(security): FLS-gate $expand at seven remaining call sites (#7429) - #8089
Conversation
ObjectKanban, ObjectTree, ObjectView (non-grid record-fetch effect), ObjectMap, ObjectGallery, ObjectTimeline, and metadata-admin PagePreview's record-binding fetch all called buildExpandFields with no column list and no permission gate on its output, so each asked the server to resolve every declared relation on the object by default, denied ones included. Applies the PR #7229 / PR #7428 gate shape unchanged: filter buildExpandFields' output through perms.checkField when the permission policy has loaded, pass it through unfiltered otherwise. usePermissions() is hoisted above each affected effect so the binding exists before the effect's dependency array is evaluated during render. Adds @object-ui/permissions to dependencies for plugin-kanban, plugin-tree, plugin-map, plugin-timeline, and plugin-view (five packages, not the four the card named -- plugin-view was missing from its own count). One failing test per site, six pins each, on the model of packages/plugin-grid/src/__tests__/expandFls-7215.test.tsx. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
|
Eager-closure measurement, promised in the PR body — the build finished once load eased: Passes. The reasoning in the PR body held: the four lazily-loaded plugins (
No split needed — one PR stands. Generated by Claude Code |
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
…7429) packages/plugin-view/src/__tests__/ObjectView.expandFls-7429.test.tsx's only `React.` reference sits inside the vi.mock('@object-ui/react', ...) factory, where a locally-imported `const React = await import('react')` shadows the module-scope import -- so the top-level import was never read, tripping object-ui/no-unused-imports (error severity) and failing @object-ui/plugin-view's lint job. Removed the unused import rather than the local shadow, per the minimal fix. Also adds a one-line comment in ObjectMap.tsx noting that the gate's `objectName` and the separately-fetched `objectSchema` agree only because the gate sits inside the `dataProvider === 'object'` branch, not by construction -- a non-blocking nicety from contract review. pnpm lint (full monorepo, 47/47 packages) confirms 0 errors everywhere, including plugin-view (0 errors, 313 warnings, down from 1 error/314). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
|
Fixed and pushed (
PR left as draft, no ready-flip, no enqueue, no auto-merge. Labels unchanged (still carries Generated by Claude Code |
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
Landing — lint fix verified in CI, contract review satisfied, standing down on one red that is not this PR'sBy the dispatching seat ( The blocking defect is fixed, and CI confirms itCommit CI: 32 of 32 check runs enumerated (returned count equals Contract review — PASS on everything except the line now fixedDirection: narrows only, and under either reading of ⭐ All seven object-name arguments verified correct — the check that mattered most, because a wrong one fails closed and no red test would reveal it. The two sites using a different expression (
⛔ Standing down on
|
Fixes #7429
What
FLS-gates
$expandat the sevenbuildExpandFieldscall sites the cardrecorded as still ungated:
ObjectKanban,ObjectTree,ObjectView(thenon-grid record-fetch effect),
ObjectMap,ObjectGallery,ObjectTimeline,and the metadata-admin
PagePreview's record-binding fetch.ObjectDataTableis untouched — it builds its own whitelist via
computeLookupExpandand nevercalls
buildExpandFields.The gate is the shape PR #7229 settled and PR #7428 applied unchanged at four
more sites, copied verbatim, not re-derived:
It sits on
buildExpandFields's OUTPUT. Every one of the seven calls passesno column list (confirmed independently by triage's re-count, comment
5548624240: all seven pass exactly one argument, against a second argument on
both already-gated calls), so input-gating is not merely unsound here, it is
unreachable — the call passes
undefined. Gating the output also makes the"
checkFieldanswers false for an undeclared key" trap structurallyunreachable: the helper returns only the object's declared reference-bearing
fields, so every name judged is declared by construction. An unanswered
permission policy (
!perms?.isLoaded) filters nothing, andpermsis inevery affected effect's dependency list.
usePermissions()is read once near the top of each component (never insidethe fetch effect itself) — an effect's dependency array is evaluated during
render, so the binding has to exist before the effect that lists it, the same
structural note PR #7229 / PR #7428 recorded.
@object-ui/permissionsis added todependenciesforplugin-kanban,plugin-tree,plugin-map,plugin-timeline, andplugin-view. That isfive packages, not the "three of these four" the card's own prose named —
measured directly against each package's
package.json,plugin-viewwasmissing from the card's count.
plugin-listandapp-shellalready declareit.
check:phantom-depspasses clean.PagePreview— the one site with a different principalCard and triage both flagged this as "a reason to look, not a claim." Measured:
this component calls the browser's own
fetchwithcredentials: 'include'rather than
DataSource.find, so the request runs under whichever session isalready loading the Studio preview — the SAME session
usePermissions()reports on (
/me/permissions). Gating on it is judging the request thisbrowser is actually about to make, on its own credentials, regardless of who
later opens the published page.
/studio/*mounts insideMePermissionsProvider(
apps/console/src/AppContent.tsx), so the hook is live on this route, not ano-provider default.
Why one PR, not the 4+2+1 split
PR #7428 measured the four lazily-loaded plugins' chunks (
⚠️ it was not measured with an actual
plugin-kanban,plugin-tree,plugin-map,plugin-timeline) as absent from the eagerclosure entirely (0 bytes).
plugin-listandapp-shellalready declare@object-ui/permissionsand already callusePermissions()elsewhere inalready-shipped code (
ListView.tsx;RecordDetailView.tsx/ObjectView.tsxin app-shell), so this change adds no NEW dependency edge to either package's
eager closure — only a few bytes of call-site code reusing an already-bundled
module. On that reasoning the combined diff should clear the eager-closure
budget with room to spare, but
apps/consolebuild at the time this PR was opened — the container wasunder heavy concurrent load (4+ sibling dev agents, load average 25-90 on 4
cores) for most of the session. A build was kicked off once load eased; its
result will follow as a comment.
check:eager-closure/performance-budgetalso run in CI regardless, and the split falls back into play if it does not
clear.
Line numbers moved again
Every call site's line number has moved since the card was written (
bf244f400)and again since triage's re-count (
a472b07). Verified againstorigin/maintoday, ahead of writing each test:
ObjectKanban.tsxObjectTree.tsxObjectView.tsxObjectMap.tsxObjectGallery.tsxObjectTimeline.tsxPagePreview.tsxTests
One failing test per site, on the model of
packages/plugin-grid/src/__tests__/expandFls-7215.test.tsxand the fivefiles PR #7428 added — six pins per site (denies a lookup, keeps a live
readable lookup, denies a
master_detailroot, asserts the exact readableset, empties to
[]when everything is denied, and defers — filters nothing —while
/me/permissionshas not answered):packages/plugin-kanban/src/__tests__/ObjectKanban.expandFls-7429.test.tsxpackages/plugin-tree/src/ObjectTree.expandFls-7429.test.tsxpackages/plugin-view/src/__tests__/ObjectView.expandFls-7429.test.tsxpackages/plugin-map/src/ObjectMap.expandFls-7429.test.tsxpackages/plugin-list/src/__tests__/ObjectGallery.expandFls-7429.test.tsxpackages/plugin-timeline/src/ObjectTimeline.expandFls-7429.test.tsxpackages/app-shell/src/views/metadata-admin/previews/PagePreview.expandFls-7429.test.tsxEvery site was proven red before its fix landed — four written red-then-green
in sequence (
ObjectKanban,ObjectTree,ObjectMap,ObjectGallery); theother three (
ObjectTimeline,ObjectView,PagePreview) were verified byreverse-verification after the fact — the gate reverted to the pre-fix
one-liner, the four denial/set pins went red while the two deferral/live-control
pins stayed green, then the gate restored and re-verified green.
Full per-package suites, all green after the fix:
@object-ui/plugin-kanban@object-ui/plugin-tree@object-ui/plugin-map@object-ui/plugin-timeline@object-ui/plugin-view@object-ui/plugin-listapp-shellmetadata-admin previews232 files / 2,300 tests total.
type-check(tsc --noEmit && tsc -p tsconfig.test.json) is also green for all seven affected packages, afterbuilding the dependency closure (
pnpm exec turbo run build --filter=@object-ui/<pkg>...per package) since this worktree started withno
dist/anywhere — several of these packages' publishedtypesfieldpoints at
dist/index.d.tsand the roottsconfig.json'spathsmap coversonly
@object-ui/types/@object-ui/core/ a few others, so a cleanworktree's
tsccannot resolve@object-ui/react/@object-ui/components/@object-ui/permissionsetc. until the closure is built once.check:phantom-depsandcheck:published-tsconfig-excludeboth pass clean;check:control-bytespasses clean on the full tree.Deviations from the dispatch order (measured, not assumed)
yes(a laterdomain:uiPM ruling, superseding thisround's initial
no): this PR changes accept/reject behaviour on sevenruntime sites. It stays draft and is not enqueued on the merge queue by
this seat;
needs:contract-reviewis applied.plugin-viewneeds@object-ui/permissionstoo — the card's dependencycount named only four packages ("three of these four"); measured against
package.json,plugin-viewhad it in no field either.as low-risk, a build was kicked off separately and its result follows as a
comment.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YBWFb5YgMU5dw8p2VKj16S
Generated by Claude Code