Skip to content

Commit 880f168

Browse files
committed
test(plugin-security): the View All controls of the computed-field masking suite follow the own field-mask rule
A set's own readable: false row binds that set's holders over the same set's View All (ADR-0066 D2 note of 2026-11-15). The two View All controls booted View All on the set that declares the row, so they pinned the earlier reading. - View All on the set that hides the field: the field and the computed fields over it stay withheld (new pin, ablated against the rule). - View All held through another set: still reads the hidden field and the formulas over it, and is still withheld a computed field over a capability-gated or masked field (the two controls, kept via that route). Claude-Session: https://claude.ai/code/session_01FEkQ5nNrLRm8ssuwWcBVcw Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fb36b6b commit 880f168

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

‎packages/plugins/plugin-security/src/formula-reads-hidden-field-masking.test.ts‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ interface BootOptions {
9292
secondFields?: FieldEntries;
9393
/** Capabilities the caller's permission set grants. */
9494
capabilities?: string[];
95-
/** The object grant's View All (reads every field of the object). */
95+
/**
96+
* The object grant's View All. It reads every field of the object the set's
97+
* own rows do not declare `readable: false` (ADR-0066 D2 ⑧).
98+
*/
9699
viewAllRecords?: boolean;
100+
/** View All on the object in the second set, held only by {@link TWO_SETS}. */
101+
secondViewAll?: boolean;
97102
/**
98103
* Boot the identity objects and a delegator user holding {@link DELEGATOR_SET}
99104
* with these field entries, so an on-behalf-of read resolves its delegator
@@ -321,7 +326,7 @@ async function boot(opts: BootOptions = {}): Promise<Rig> {
321326
});
322327
const second = PermissionSetSchema.parse({
323328
name: SECOND,
324-
objects: { [OBJ]: { allowRead: true }, [REGION]: { allowRead: true } },
329+
objects: { [OBJ]: { allowRead: true, ...(opts.secondViewAll ? { viewAllRecords: true } : {}) }, [REGION]: { allowRead: true } },
325330
...(opts.secondFields ? { fields: opts.secondFields } : {}),
326331
});
327332
const delegatorSet = PermissionSetSchema.parse({
@@ -952,14 +957,21 @@ describe('controls: what the rule leaves unchanged', () => {
952957
});
953958
});
954959

955-
it('a View All holder reads the hidden field and the formulas over it', async () => {
956-
const { engine } = await boot({ fields: HIDE_OPEN_CASES, viewAllRecords: true });
957-
expect(await findA1(engine)).toMatchObject({ open_cases: 6, load: 0.5, load_pct: 50, open_cases_stored: 6 });
960+
it("a holder of another set's View All reads the hidden field and the formulas over it", async () => {
961+
const { engine } = await boot({ fields: HIDE_OPEN_CASES, secondViewAll: true });
962+
expect(await findA1(engine, TWO_SETS)).toMatchObject({ open_cases: 6, load: 0.5, load_pct: 50, open_cases_stored: 6 });
958963
});
959964

960-
it('a View All holder is still withheld a computed field over a capability-gated or masked field (the vote lifts readable: false only)', async () => {
965+
it("View All on the set that hides the field does not read it: the field and the computed fields over it stay withheld", async () => {
961966
const { engine } = await boot({ fields: HIDE_OPEN_CASES, viewAllRecords: true });
962967
const one = await findA1(engine);
968+
expect(one).toMatchObject({ capacity: 12 });
969+
for (const f of ['open_cases', 'load', 'load_pct', 'open_cases_stored', 'load_stored']) expect(one, f).not.toHaveProperty(f);
970+
});
971+
972+
it("a holder of another set's View All is still withheld a computed field over a capability-gated or masked field (the vote lifts readable: false only)", async () => {
973+
const { engine } = await boot({ fields: HIDE_OPEN_CASES, secondViewAll: true });
974+
const one = await findA1(engine, TWO_SETS);
963975
expect(one).toMatchObject({ open_cases: 6, load: 0.5, phone: '138****5678' });
964976
for (const f of ['gated', 'gated_double', 'gated_stored', 'phone_copy', 'phone_stored']) expect(one, f).not.toHaveProperty(f);
965977
});

0 commit comments

Comments
 (0)