Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/6898-objectgrid-select-fls.md
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
---
'@object-ui/plugin-grid': patch
---

ObjectGrid: field-level security on the server `$select` projection
(objectui#6898) — the FETCH half of the gap objectui#6799 closed on the RENDER
half.

`getSelectFields()` built the projection from the authored `columns` / `fields`
with no FLS gate, so after objectui#6799 hid the column the field name was still
being ASKED for. `perms.checkField(object, field, 'read')` now gates the
projection, on both authored arms and on the predicate-operand harvest.

Measured, because the grade depended on it: ObjectStack's own server enforces
FLS on the RECORD, not on the projection — `plugin-security`'s read middleware
deletes an unreadable key from every returned row, and its `predicate-guard`
says in terms that the projection is deliberately unguarded because the masker
strips the value anyway (pinned over real HTTP by objectstack's
`showcase-fls-read-mask-strip.dogfood.test.ts`, where `?select=name,<denied>`
answers 200 with the key absent). So against ObjectStack this is
defence-in-depth; it becomes load-bearing for any backend that does not strip.

Two limits are deliberate and pinned:

- Only keys the object DECLARES are judged. `checkField` answers `false` for a
field no policy mentions, so judging an undeclared key would strip a host's
derived or joined column out of its own query.
- `id` survives even a policy that denies it, structurally — `ensureId` composes
after the gate — so row navigation cannot break. Readable predicate operands
are untouched, so objectui#3501 does not regress.

The fetch effect now also depends on `perms.isLoaded`: `/me/permissions`
resolves asynchronously, so without it nothing would rebuild the projection
after the policy answered and the gate would never run on the only fetch most
grids make.
97 changes: 95 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -1469,6 +1469,75 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
const names = list.map((f: any) => columnIdentity(f));
return names.includes('id') ? list : ['id', ...list];
};
// [objectui#6898] FIELD-LEVEL SECURITY ON THE PROJECTION — the FETCH
// half of the gap objectui#6799 closed on the RENDER half.
//
// objectui#6799 made `generateColumns()` drop a column naming a
// declared field the principal cannot read. That is what reaches the
// SCREEN. This is what goes on the WIRE: without this gate the same
// field name is still handed to the server in `$select`, so a
// backend that does not enforce FLS on the projection would return
// the value into `data` with no column on screen to reveal it.
//
// ⭐ MEASURED, not assumed (the escalation gate this card was graded
// on). ObjectStack's own server DOES enforce it — but on the RECORD,
// not on the projection. `plugin-security`'s read middleware runs
// `FieldMasker.maskResults`, whose `maskRecord` DELETES an unreadable
// key from every returned row, and `predicate-guard.ts` says in terms
// that the projection is deliberately NOT guarded because "selecting
// a hidden field is harmless because FieldMasker strips it from the
// result". Pinned end-to-end over real HTTP by objectstack's
// `showcase-fls-read-mask-strip.dogfood.test.ts`: an explicit
// `?select=name,<denied>` answers 200 with the denied key ABSENT.
// So against ObjectStack this gate is defence-in-depth (p2), exactly
// as triage graded it — it is NOT load-bearing for that backend, and
// this comment is what stops a future reader from concluding it is.
// It becomes load-bearing for any other backend, which is the same
// argument the objectui#6723 / objectui#6799 rulings accepted: the
// invariant must not rest on every future backend having enforced it.
//
// ⭐ THE DECLARED-KEY LIMIT IS THE SAME ONE, AND THE CARD IS RIGHT
// THAT THE REASONING DOES NOT TRANSFER AUTOMATICALLY — it has to be
// re-derived here, and it lands in the same place. On the render path
// an undeclared key is a legitimate derived / host-joined column. In
// a `$select` an undeclared key is what the host asked the SERVER
// for, so the question is genuinely different. It resolves the same
// way for a reason that is about `checkField`, not about drawing:
// `checkField` answers FALSE for a field the policy has never heard
// of, so judging an undeclared key is not a stricter reading of this
// rule — it is a different, wrong one, and it would strip a host's
// derived or joined column out of its own query. Undeclared ⇒ not
// this gate's business, on both halves.
//
// ⛔ NAVIGATION IS PRESERVED STRUCTURALLY, NOT BY A SPECIAL CASE:
// every call below composes `ensureId(...)` AFTER this gate, so `id`
// is re-added even in the pathological case where a policy marks it
// unreadable. A gate that filtered `id` out last would break row
// click / navigation for everyone — the naive-filter failure the
// card names by name. Keeping the restoration in the composition
// rather than in a branch here means it cannot drift out of one arm.
//
// Keyed on `objectName` (the object actually being FETCHED —
// `dataConfig.object` when a data block names one) rather than the
// render half's `schema.objectName`: the projection is judged against
// whatever object the server is about to read.
const passesProjectionGate = (entry: unknown): boolean => {
// Not loaded ⇒ nothing to ask yet; never filter on an unanswered
// policy. Same deferral as the render half — and the fetch effect
// re-runs on `perms.isLoaded` so the projection is rebuilt the
// moment the answer arrives (without that dep this gate would be
// dead on the first, and usually only, fetch).
if (!perms?.isLoaded || !objectName) return true;
const fieldName = columnIdentity(entry);
// No readable identity ⇒ nothing to ask the policy about.
if (!fieldName) return true;
// Undeclared ⇒ host-joined / derived / platform column ⇒ see above.
// `hasOwnProperty` rather than a truthiness read so an inherited
// name (`constructor`, `toString`) cannot be mistaken for a
// declared field and dropped out of the query.
if (!Object.prototype.hasOwnProperty.call(resolvedSchema?.fields ?? {}, fieldName)) return true;
return perms.checkField(objectName, fieldName, 'read');
};
// Fields the view's PREDICATES read but no column shows
// (objectui#3501). Without them the projection asks the
// server for everything except the field a row action is gated on,
Expand DownExpand Up@@ -1529,16 +1598,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// pinned by `__tests__/gridNonAuthorKeys.test.tsx`.
userActions: (resolvedSchema as any)?.userActions,
})).filter((f) => isProjectableField(f, declared as Record<string, unknown>))
// [objectui#6898] A predicate operand the principal cannot read
// is dropped from the projection too. This costs nothing that
// was working: against ObjectStack the server already DELETES
// that key from every row (measured above), so the operand was
// never arriving and the CEL predicate was already faulting
// `No such key` and failing CLOSED. Dropping it from `$select`
// changes what we ASK for, not what we got. Against a
// non-enforcing backend it converts "the button works, and the
// denied value sits in memory" into "the button hides" — which
// is the correct direction for a predicate gated on a field
// this principal may not read.
.filter((f) => passesProjectionGate(f))
: [];
const withPredicates = (list: any[]): any[] => {
if (predicateFields.length === 0) return list;
const names = new Set(list.map((f: any) => columnIdentity(f)));
const extra = predicateFields.filter((f) => !names.has(f));
return extra.length > 0 ? [...list, ...extra] : list;
};
if (schemaFields) return withPredicates(ensureId(schemaFields as any[]));
if (schemaFields) {
return withPredicates(ensureId((schemaFields as any[]).filter(passesProjectionGate)));
}
if (schemaColumns && Array.isArray(schemaColumns)) {
const fields = schemaColumns
.filter(passesProjectionGate)
.map((c: any) => columnIdentity(c))
.filter((v): v is string => !!v);
return withPredicates(ensureId(fields));
Expand DownExpand Up@@ -1662,7 +1746,16 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
return () => {
cancelled = true;
};
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey]);
// `perms.isLoaded` (objectui#6898): the projection is FLS-gated above, and
// `/me/permissions` resolves asynchronously — on the first render it is still
// `false`, so the gate defers and the first request goes out ungated. Without
// this dep nothing would ever rebuild it and the gate would be dead on the
// only fetch most grids make. The boolean, not `perms` itself: it flips
// false -> true exactly once, so this costs at most one refetch, where the
// context object's identity would re-fetch the grid on every render.
// `PermissionProvider` reports `true` synchronously and the no-provider
// default stays `false` forever, so neither of those pays anything.
}, [objectName, schemaFields, schemaColumns, schemaFilter, schemaSort, headerSort, searchTerm, schemaPagination, schemaPageSize, serverPage, serverPageSize, dataSource, hasInlineData, dataConfig, refreshKey, perms.isLoaded]);

// The same reset, for the path the loader above never runs on (objectui#4501
// clause 2). "All N matching are selected" is a claim about ONE query, so it
Expand Down
Loading
Loading