Skip to content

Commit f84dc19

Browse files
fix(plugin-security)!: a computed field over a field the caller cannot read is hidden from that caller (#34135)
Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — `skills/objectstack-data` (`rules/relationships.md`) teaches a rate as a `formula` over a `summary` and tells an author to mask the summary on a set that must not see it; that instruction is complete as written now, because a formula over the masked summary is withheld with it, so no page needs a new sentence. ## 维护者速读 - 改了什么:字段级安全现在覆盖计算字段的输入——调用者未被完整提供某字段时(权限集 `readable: false`、未满足 `requiredPermissions`、或按 `maskingRule` 打码),读取该字段的 formula / 存储计算字段对其隐藏:本记录直接引用、经 `label()` 之类函数、经另一计算字段;或经引用读取被引用对象声明的字段(调用者读不了该对象、读不了该字段、或只拿到打码值;被引用对象上经其自身引用而被扣下的存储字段亦然,沿链每个对象判一次)。写入载荷点名此类字段一律 403。 - 为什么改:字段级安全应当覆盖一个值由什么算出;此前计算字段不随其输入一起隐藏。 - 风险与回滚:收窄(BREAKING)。受影响者是输入字段被扣下却在读其上计算字段的调用者,包括对能力门控或打码字段的 View All / Modify All 持有者,以及无解码门的 `maskingRule` 下所有非系统调用者。读不出字段名的表达式在有任一其他字段未被完整提供时整体隐藏。公共表单的引擎回显不带任何经引用读取的计算字段。判的是字段,不是行(见变更集)。回滚即 revert 本 PR,无数据迁移。 - 先看:`packages/plugins/plugin-security/src/field-masker.ts`(读集、引用跳读与传递折叠)、`security-plugin-object-inputs.ts`(引用判定:被引用对象可读与完整提供的字段集)、`security-plugin-authz-middleware.ts`(第 2.5 步写入拒绝、查询守卫、第 4 步与公共表单回显)。 - 两分钟验证:`pnpm --filter @objectstack/plugin-security exec vitest run src/formula-reads-hidden-field-masking.test.ts`,预期 67 个用例全绿。 - 需要你做的:无,席位落地。 ## What changes Field-level security now covers what a field's value is computed from. A computed field — a `formula`, computed on read, or a stored field declaring an `expression`, computed on write — is withheld from a caller who is not served whole a field it reads. Each input kind is pinned for a formula and for a stored field, with a control and an ablation: - a field of its own record the caller may not read (a permission set marks it `readable: false`, or the caller fails its `requiredPermissions`) or is served masked (its `maskingRule`, gated or not), whether the expression names it directly, inside a function such as `label()`, or through another computed field; - a field the referenced object declares, on the record the expression reads through one reference, where the caller may not read that object, may not read the field, or is served it masked, directly or through a computed field of the referenced object — including a stored field there that is withheld for what it reads through a reference of its own. A computed field reading through a chain of references is withheld when any field along the chain is withheld from the caller, however long the chain and wherever it comes back to an object it has already passed through: the withheld sets of every object the references reach grow together until none grows, each object resolved once per operation. A field the referenced object does not declare is no field to withhold: the formula reads `null`, as before; - an expression whose reads cannot be named (a computed key, a method or macro on the record, the record handed whole to a function, a dialect other than CEL) is withheld whenever some other field of the object is not served whole to that caller (fail closed); such a field is also withheld for what it reads through a reference, as any computed field is. What is judged is the field, not the row: a computed field is not withheld because the caller may not read the particular record a reference points at (a formula reads `null` there; a stored one keeps the value its writer computed). The readers, each pinned at its own door with a control: `find` / `findOne` and a projection; the `insert` and `update` echoes; a write payload naming such a field (`403 PERMISSION_DENIED`, whatever value it carries); filtering, sorting, grouping and aggregating by a stored computed field (`403`; a `formula` is refused there for every caller already); `getReadableFields`, `getMetadataReadableFields` (and the object schema the metadata plane and `describe_object` serve), `getQueryableFields`, `getWritableFields` and `getRecordFieldAccess` (both halves); the explain `fls` layer; the `$expand` name of a `referenceNameVisible` reference (the floor name where the target's name field is withheld); a delegated read driven through the engine; and the record the engine echoes for a public-form grant, which carries no computed field that reads through a reference, for every submitter (the form submit route itself answers the created id only). One derivation feeds every reader: each object's computed-field reads are taken once, from one parse, into the cached security posture; `foldComputedFieldReads` folds them, transitively, into the field map after the per-field capability fold and the delegator intersection; a computed field reading through a reference is judged by the caller's object admission and query projection of the referenced object (the fields served whole there), that projection folding the referenced object's own references in turn. The read projection stays the exact complement of what the read mask deletes, and the query projection still differs from it by exactly the fields served masked, as `packages/spec/src/contracts/security-service.ts` states; no spec text moves. No change to `packages/spec`, to `packages/lint`, or to the metadata-plane schema scrub code. Files: `field-masker.ts`, `security-plugin.ts`, `security-plugin-object-inputs.ts`, `security-plugin-field-readers.ts`, `security-plugin-authz-middleware.ts`, `explain-engine.ts`, `security-plugin-explain-access.ts`, the rule's test file, the two `describe_object` pins and the second-object ledger row named under Acceptance notes, the docs page `content/docs/permissions/field-level-security.mdx`, one changeset. ## Tests `packages/plugins/plugin-security/src/formula-reads-hidden-field-masking.test.ts`: a real `ObjectQL` over a real SQL driver behind the real `SecurityPlugin`, 67 tests named by the rule. The input-kind × reader matrix: - same record, `readable: false`: formula and stored; `find`, `findOne`, projection, both echoes, the four query positions, both read projections, query, write and record-access projections, explain, delegated read; payload refusal for a matching and a differing value, with control; - same record, a failed `requiredPermissions`, and served masked (gated rule, and a rule with no unmask gate): formula and stored, each with a control (the capability, the unmask capability, a system context); a View All holder is still withheld them; - `label()` and a computed field over a computed field: formula and stored, with control; - through a reference: `readable: false`, a failed `requiredPermissions`, served masked, an object the caller may not read, a formula of the referenced object, and a stored field there that reads through a reference of its own (a chain of two); formula and stored for each, with control; an undeclared field reads `null` for every caller; - fail closed, for a formula and a stored field, with control; - the reference name door, the public-form echo and the delegated read, each with its control; - controls: union of two sets, system context, View All over `readable: false`, the aggregate input gate unchanged; - the read set: every literal spelling, held equal to the platform member reader (`analyzeRelationshipTraversals`), and the shapes it cannot name. ## Acceptance notes - Two existing pins moved with the rule. Each now states a rule-named expectation, and no assertion was loosened. `packages/runtime/src/domains/mcp-object-schema-mask.test.ts` used to hold that `describe_object` still served the member a stored expression over a field the member cannot read, with the expression stripped. Under this rule that field is withheld, so the pin now asserts it is not served, with a control: a caller who reads the input is served it. The stdio twin, `packages/mcp/src/stdio-data-bridge.object-schema-mask.test.ts`, keeps its parity literal with it; its stubbed security answer is set to what the real service now answers. - `packages/core/src/security/second-object-read-exposure.pin.test.ts` classifies the new caller of the reference-target arbiter (`computedHopTargetsOf`, `field-masker.ts`) as not a served read. - No author-time warning names a computed field over a field a set masks; the runtime withholds it either way. ## Verification Readings at head `9d8e0766babadc87e234df4c5073e63853ac5fc0`, under the verify lock. <details><summary>Rule suite, package suites, typecheck and ablations</summary> - `pnpm --filter @objectstack/plugin-security exec vitest run src/formula-reads-hidden-field-masking.test.ts`: Tests 67 passed (67). - `pnpm --filter @objectstack/plugin-security exec vitest run`: Test Files 273 passed (273); Tests 6794 passed | 45 skipped (6839). - Pins: `packages/runtime` `src/domains/mcp-object-schema-mask.test.ts` 75 passed (75); `packages/mcp` `src/stdio-data-bridge.object-schema-mask.test.ts` 37 passed (37); `packages/core` `src/security/second-object-read-exposure.pin.test.ts` 4 passed (4). - Typecheck: `@objectstack/plugin-security` (with the scripts project and `check:test-typecheck`), `@objectstack/core`, `@objectstack/runtime`, `@objectstack/mcp`: each exit 0. - Ablations, one-shot through `scripts/ablation-replace.mjs` (anchor 1 to 0, blob changed; each restored: blob equal to HEAD, `git diff HEAD` empty), each a red run of the 67: - the withheld sets grow once instead of to a fixed point: 3 failed (a chain of two, a chain back to the record read, a chain back to an object along it); - the write preview asks the earlier field verdict alone: 1 failed; - the read projection keeps a withheld computed field: 5 failed (the reference name door among them); - an expression whose reads cannot be named drops the references it names: 2 failed; - the write refusal's sentence asks a map without the reference arm: 1 failed. </details> <details><summary>Derived gates and the dogfood battery</summary> - `dispatch-gates --commands` ∪ `--ran`: 106 derived, 106 run, 0 NOT-MEASURED, 0 UNRUN. `check:docs` and `check:skill-examples` each re-run alone exit 0 after a sweep run that overlapped a `spec` rebuild; `check:type-check-debt` is measured by CI's `Type Check · debt ledger` (success on this head). - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: exit 0, 0 anchors lost. - `node scripts/check-role-word.mjs`: exit 0. - **Dogfood battery** (`pnpm --filter @objectstack/dogfood test`, no shard, no path): Test Files 474 passed | 3 skipped (477), Tests 4006 passed | 42 skipped (4048), no failures. - CI on this head: 68 check-runs, 58 success, 10 skipped, none failing. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_ <!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d01f399 commit f84dc19

14 files changed

Lines changed: 1780 additions & 67 deletions
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
---
4+
5+
fix(plugin-security)!: a computed field over a field the caller cannot read is hidden from that caller
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
Skills-docs: none — `skills/objectstack-data` teaches a rate as a `formula` over a `summary` and tells an author to mask the summary on a set that must not see it; that instruction is now complete as written, because the formula over the masked summary is withheld with it, so no page needs a new sentence.
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped, and no stored row changes: what moves is which computed fields the field-level security read mask and query guard withhold from a caller, so there is nothing for a migration to rewrite and no tombstone. -->
12+
13+
**BREAKING** for a caller who is not served whole a field that a computed field reads. Field-level security now covers what a field's value is computed from: a computed field — a `formula`, computed on read, or a stored field declaring an `expression`, computed on write — is withheld from a caller who is not served whole a field it reads:
14+
15+
- a field of its own record the caller may not read (a permission set marks it `readable: false`, or the caller fails its `requiredPermissions`) or is served masked (its `maskingRule`), whether the expression names it directly, inside a function such as `label()`, or through another computed field;
16+
- a field the referenced object declares, on the record the expression reads through one reference, where the caller may not read that object, may not read the field (`readable: false`, or a failed `requiredPermissions`) or is served it masked, directly or through a computed field of the referenced object — including a stored field there that is withheld for what it reads through a reference of its own. This holds however long the chain, and where it comes back to an object it has already passed through.
17+
18+
What is judged is the field, not the row: a computed field is not withheld because the caller may not read the particular record a reference points at. A formula reads `null` there, as before; a stored computed field keeps the value its writer computed.
19+
20+
Who moves:
21+
22+
- a holder of a permission set that withholds such a field, who read a computed field over it. That includes a View All / Modify All holder over a field whose `requiredPermissions` capability it does not hold, or that it is served masked: the vote lifts a permission set's `readable: false`, not a capability gate or a masking rule;
23+
- every caller but a system context, for a computed field over a field whose `maskingRule` declares no unmask gate (no `requiredPermissions`): that field is served masked to every such caller;
24+
- a delegate acting on behalf of a delegator who is not served such a field whole;
25+
- every public-form submitter: the record the engine echoes for a public-form grant carries no computed field that reads through a reference, whatever the submitter could read there (the form submit route itself answers the created id only);
26+
- a caller with edit on the object whose payload names a computed field it is not served whole, a computed field served masked by its own `maskingRule` included;
27+
- a caller who reads a computed field whose expression reads the record in a way no field name describes (a computed member key, a method or macro on the record, the record handed whole to a function, a dialect other than CEL), while some other field of the object is not served whole to that caller; such a field is also withheld for what it reads through a reference, as any computed field is.
28+
29+
For that caller, after this release, the computed field is withheld exactly as the field it reads is:
30+
31+
- `find` / `findOne`, a projection naming it, and the record an `insert` / `update` echoes back carry no key for it. Before, a computed field over a field of its own record was served with its value; a stored one reading through a reference, with the value its writer computed; a formula reading through a reference, with `null` where the field there was not readable, and computed over the masked value where it was served masked.
32+
- filtering, sorting, grouping or aggregating by a stored computed field over such a field is refused `403 PERMISSION_DENIED`. Before, it was admitted. (A `formula` is refused in those positions for every caller, as before.)
33+
- a payload naming it in an `insert` / `update` is refused `403 PERMISSION_DENIED`, as a field the caller may not edit is, and so is a payload naming a computed field the caller is served masked by its own `maskingRule`; the write admission (`canWriteObject`), the write projection and the record field access give the same answer. Before, a formula named there was dropped and a stored one recomputed, reported as replaced only when the value sent differed from the stored one.
34+
- the `$expand` of a `referenceNameVisible` reference to a record the caller may not read serves that record by id with the floor name when its name field is a computed field withheld from the caller. Before, it served the computed name.
35+
- the read projections (`getReadableFields`, `getMetadataReadableFields`, and with them the export header and the object schema the metadata plane and `describe_object` serve), the query projection (`getQueryableFields`), the write projection (`getWritableFields`) and the record field access (`getRecordFieldAccess`, both halves) leave it out; the explain `fls` layer reports it masked from responses.
36+
37+
A field the referenced object does not declare is no field to withhold: a formula naming one reads `null`, as before — unless the caller may not read the referenced object at all, when every computed field reading through that reference is withheld.
38+
39+
The fix, when the caller should read the computed field: grant the caller's permission set read on every field the computed field reads, and on the object a reference reads through, unmasked — the capability a field's `requiredPermissions` names, which also lifts a `maskingRule` gated by it. A field whose `maskingRule` declares no gate is masked for every caller; to make it readable whole, give the field `requiredPermissions` (the capability then unmasks it) and grant that capability. When the caller should not read the computed field, nothing is owed.
40+
41+
Unchanged: a computed field over fields the caller is served whole is served and listed as before; a system context reads every field and every computed field; a View All / Modify All holder reads a field a permission set marks `readable: false` and the computed fields over it, as before; a caller holding several permission sets reads a computed field when any set grants read on its inputs; the aggregate refusal of a field the caller cannot read is as before.

‎content/docs/permissions/field-level-security.mdx‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,47 @@ request arrived (REST, SDK, raw ObjectQL call).
124124
**On read** — `find` / `findOne` results have non-readable fields
125125
stripped from every record before the response leaves the engine.
126126

127+
**Computed fields follow their inputs** — a computed field (a `formula`,
128+
or a stored field with an `expression`) is withheld from a caller who is
129+
not served whole a field it reads: a field of its own record the caller
130+
may not read (a permission set marks it `readable: false`, or the caller
131+
fails its `requiredPermissions`) or is served masked (its `maskingRule`),
132+
whether the expression names it directly, inside a function such as
133+
`label()`, or through another computed field; or a field the referenced
134+
object declares, on the record the expression reads through one
135+
reference, where the caller may not read that object, may not read the
136+
field, or is served it masked — a stored field there withheld for what it
137+
reads through a reference of its own included, however long the chain
138+
and wherever it comes back to an object it has already passed through.
139+
What is judged is the field, not the row:
140+
a computed field is not withheld because the caller may not read the
141+
particular record a reference points at (a formula reads `null` there; a
142+
stored one keeps the value its writer computed). A withheld computed
143+
field is stripped from records, refused as a filter, sort, group or
144+
aggregate input (a stored one; a `formula` is refused there for every
145+
caller), refused when a write payload names it (as is a computed field
146+
the caller is served masked), served by its floor name
147+
where it is the name of a record shown through `referenceNameVisible`,
148+
and left out of the fields served to that caller, including the object
149+
schema and the writable fields. A computed field whose expression
150+
reads the record in a way no field name describes (a computed key such as
151+
`record[record.k]`, a method or macro on `record`, `record` passed whole
152+
to a function, or a dialect other than CEL) is withheld whenever some other
153+
field of the object is not served whole to that caller, and for what it
154+
reads through a reference as any other computed field is. A `summary`
155+
roll-up is not a computed field in this sense: it does not follow the
156+
fields it aggregates, so mask it on its own where a set must not see it.
157+
The record the engine echoes for a
158+
public-form submission carries no computed field that reads through a
159+
reference. View All and Modify All lift a permission set's `readable:
160+
false`, not a capability gate or a masking rule, so their holders are
161+
withheld a computed field over such a field too. To let a permission
162+
set's holders read a computed field, grant that set read on every field
163+
the expression reads, unmasked: the capability a field's
164+
`requiredPermissions` names also lifts a masking rule it gates, and a
165+
masking rule with no gate masks the field for every caller until the
166+
field declares one.
167+
127168
**On write** — `insert` / `update` requests are checked **before** the
128169
operation reaches the driver. If the payload contains any field the
129170
caller is not permitted to edit, the engine throws

‎packages/core/src/security/second-object-read-exposure.pin.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ const CALLERS: Record<string, Classification> = {
261261
'`beforeRelationTarget` hook (the data door hands it `refuseUnservedRelationTarget`). Pinned by ' +
262262
'`packages/objectql/src/internal-field-evaluation-guard.test.ts` (the refusals assert the driver was never asked)',
263263
},
264+
// Field-level security over a computed field that reads through a reference.
265+
'packages/plugins/plugin-security/src/field-masker.ts': {
266+
kind: 'not-a-served-read',
267+
reason:
268+
"names the object a computed field's reference points at (`computedHopTargetsOf`), only so the security posture " +
269+
"can ask the caller's own read projection of that object which fields it may read there, and WITHHOLD the " +
270+
'computed field when one it reads is not among them; it reads no record and serves nothing of the target — the ' +
271+
"hop itself is the engine's `resolveFormulaRelated` (its row). Pinned by " +
272+
'`packages/plugins/plugin-security/src/formula-reads-hidden-field-masking.test.ts`',
273+
},
264274
// [#29986] The codemod split of engine.ts moved two arbiter callers out of it.
265275
'packages/objectql/src/engine-security-resolvers.ts': {
266276
kind: 'not-a-served-read',

‎packages/mcp/src/stdio-data-bridge.object-schema-mask.test.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ describe('stdio describe_object and the objects resource judge readonly on the D
609609
// The HTTP twin's fixture (`packages/runtime/src/domains/mcp-object-schema-mask.test.ts`,
610610
// "describe_object serves readonly where a write never stands — the real
611611
// engine and security layer"): `marked_up` is a stored expression over
612-
// `hidden_cost`, which the member may not read, so the member's mask deletes
613-
// `marked_up.expression` while the engine still computes the field.
612+
// `hidden_cost`, which the member may not read. Field-level security covers
613+
// what a value is computed from, so the security service withholds
614+
// `marked_up` from the member with `hidden_cost`.
614615
const TICKET = {
615616
name: 'ticket',
616617
label: 'Ticket',
@@ -629,8 +630,8 @@ describe('stdio describe_object and the objects resource judge readonly on the D
629630
};
630631
/**
631632
* The member's answer, field for field: the map the HTTP twin's PARITY pin
632-
* holds for the same declaration and the same mask. `hidden_cost` is not
633-
* served at all; `marked_up` is served, without its expression, as readonly.
633+
* holds for the same declaration and the same mask. Neither `hidden_cost`
634+
* nor `marked_up`, the stored expression over it, is served.
634635
*/
635636
const MEMBER_READONLY = {
636637
title: false,
@@ -641,9 +642,9 @@ describe('stdio describe_object and the objects resource judge readonly on the D
641642
bare_formula: true,
642643
doubled: true,
643644
locked_note: false,
644-
marked_up: true,
645645
};
646-
const READABLE = Object.keys(TICKET.fields).filter((f) => f !== 'hidden_cost');
646+
/** The security service's answer for the member, as the HTTP twin's real one gives it. */
647+
const READABLE = Object.keys(TICKET.fields).filter((f) => f !== 'hidden_cost' && f !== 'marked_up');
647648
const memberSecurity = {
648649
getReadableFields: async () => [...READABLE],
649650
getMetadataReadableFields: async () => [...READABLE],
@@ -696,27 +697,27 @@ describe('stdio describe_object and the objects resource judge readonly on the D
696697
return { text, json: JSON.parse(text) };
697698
}
698699

699-
it('precondition: the member\'s served object carries marked_up WITHOUT its expression', async () => {
700+
it('precondition: the member\'s served object carries neither hidden_cost nor marked_up, the stored expression over it', async () => {
700701
const view = callerObjectView(stdioObjectView({ metadataService: metadataService() }), {
701702
resolvePrincipal: MEMBER,
702703
security: () => memberSecurity,
703704
});
704705
const served = (await view.getObject(TICKET.name)) as any;
705-
expect(served.fields.marked_up, 'the member is served the field').toBeDefined();
706-
expect(served.fields.marked_up.expression, 'the mask deleted the expression').toBeUndefined();
706+
expect(served.fields.marked_up, 'the stored expression over the hidden field is not served').toBeUndefined();
707707
expect(served.fields.hidden_cost, 'the field it names is not served').toBeUndefined();
708+
expect(served.fields.doubled, 'CONTROL: a stored expression over a readable field is served').toBeDefined();
708709
});
709710

710711
for (const [door, describe] of [
711712
['describe_object over stdio', describeOverStdio],
712713
['the objectstack://objects/{name} resource', describeOverResource],
713714
] as const) {
714-
it(`${door}: marked_up is readonly: true, and neither its expression nor hidden_cost is served`, async () => {
715+
it(`${door}: neither marked_up nor hidden_cost is served, and the rest keep their readonly`, async () => {
715716
const { text, json } = await describe();
716717
expect(readonlyOf(json)).toEqual(MEMBER_READONLY);
717718
expect(mentions(text, 'hidden_cost')).toBe(false);
718719
expect(text).not.toContain('record.');
719-
expect(json.fields.find((f: any) => f.name === 'marked_up')).not.toHaveProperty('expression');
720+
expect(json.fields.find((f: any) => f.name === 'marked_up')).toBeUndefined();
720721
});
721722
}
722723

‎packages/plugins/plugin-security/src/explain-engine.ts‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,22 @@ export interface ExplainEngineDeps {
377377
object: string,
378378
delegatorSets: PermissionSet[] | null,
379379
) => Promise<Record<string, FieldMaskingRule>>;
380+
/**
381+
* The computed fields the read mask deletes for what they are computed
382+
* from — a field `mask` withholds or `partialRules` serves masked, read on
383+
* this record, through another computed field or through a reference —
384+
* for the principal `context` names: the enforcement composition
385+
* (`foldComputedFieldReads` over the posture, with
386+
* `resolveHopWithheldFields`), never a re-derivation. Absent → none are
387+
* reported, which under-reports and never widens; the plugin's own wiring
388+
* passes it.
389+
*/
390+
getComputedFieldsWithheld?: (
391+
object: string,
392+
mask: Record<string, { readable?: boolean; editable?: boolean }>,
393+
partialRules: Record<string, FieldMaskingRule>,
394+
context: any,
395+
) => Promise<Set<string>>;
380396
/**
381397
* Configured additive baseline set NAMES (default `['member_default']`), for
382398
* attribution.
@@ -3254,10 +3270,19 @@ async function explainObjectPass(deps: ExplainEngineDeps, input: ExplainInput, a
32543270
// — including the capability-gated case, where the mask says `readable:
32553271
// false` precisely because the unmask gate is what the rule softens.
32563272
const partialRules = await deps.getPartialMaskRules(sets, object, delegatorSets);
3257-
const partial = Object.keys(partialRules);
3258-
const hidden = Object.entries(mask)
3259-
.filter(([f, p]) => p?.readable === false && !(f in partialRules))
3260-
.map(([f]) => f);
3273+
// Field-level security covers what a value is computed from: a computed
3274+
// field the read mask deletes for what it reads is reported hidden, whole,
3275+
// whatever masking rule of its own it carries — as step 4 deletes it.
3276+
const computedWithheld = deps.getComputedFieldsWithheld
3277+
? await deps.getComputedFieldsWithheld(object, mask, partialRules, context)
3278+
: new Set<string>();
3279+
const partial = Object.keys(partialRules).filter((f) => !computedWithheld.has(f));
3280+
const hidden = [
3281+
...Object.entries(mask)
3282+
.filter(([f, p]) => p?.readable === false && !(f in partialRules) && !computedWithheld.has(f))
3283+
.map(([f]) => f),
3284+
...computedWithheld,
3285+
];
32613286
const listFields = (fields: string[], label: (f: string) => string): string =>
32623287
`[${fields.slice(0, 25).map(label).join(', ')}${fields.length > 25 ? ', …' : ''}]`;
32633288
const maskNarrows = hidden.length > 0 || partial.length > 0;

0 commit comments

Comments
 (0)