Skip to content

Commit 4138ce8

Browse files
fix(plugin-security): a View All / Modify All set reads every field of its object, so an app field mask no longer hides fields from admins (#29387)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9A6kAUSDc7TXDVUJeUigpMx)_ Part of #29106. This is the runtime half. The ADR-0066 D2 ⑧ note is the card's second PR, governed Tier H, and it opens from this branch once this one merges. Clause-②: no Metadata-protocol: none Ruling-ref: 6573563853 ## 维护者速读 - 改了什么:在某对象上持「查看全部」(`viewAllRecords`)的权限集,在字段合并时对该对象每个字段投「可读」;持「修改全部」(`modifyAllRecords`)的投「可读+可编辑」。判断谁是超级用户只用一个函数,行级和字段级共用。 - 为什么改:应用权限集遮掉平台对象字段时,同时持有该集的平台管理员也被遮住(列表少列、按该字段排序 403、Setup 页面显示为空)。按裁决 6573563853 选 A。 - 风险与回滚:只放宽持「查看全部 / 修改全部」者的字段可见性;全仓没有已发布的权限集同时声明这两个位和 `readable: false`(已在卡上贴查证结果)。回滚 = revert 本 PR。 - 先看:`packages/core/src/security/effective-object-permissions.ts`(`holdsSuperuserBypass`、`superuserFieldVote`)→ `packages/plugins/plugin-security/src/permission-evaluator.ts`(`getFieldPermissions`、`superuserBypassSets`)→ `packages/qa/dogfood/test/fls-superuser-vote.dogfood.test.ts`。 - 两分钟验证:`pnpm --filter @objectstack/dogfood exec vitest run test/fls-superuser-vote.dogfood.test.ts`,预期 11 条全绿:管理员看到全部字段并能按 `code` 排序,普通成员仍被遮、排序 403。 - 需要你做的:无,席位落地。 ## What changes - **The super-user vote.** `getFieldPermissions` (per object) and `buildEffectiveFieldPermissions` (the row-blind `/auth/me/permissions` merge) apply `superuserFieldVote` after the declared-entry votes. A set holding `viewAllRecords` on the object votes `readable: true` on every field of it. A set holding `modifyAllRecords` votes `readable: true` and `editable: true`. View All never grants an edit. The vote touches only fields the merge already holds an entry for, because an absent field is already unrestricted. - **One predicate.** `holdsSuperuserBypass(set, object, bit)` is new in `@objectstack/core`. `PermissionEvaluator.superuserBypassSets` now reads each set through it, and so does `superuserFieldVote`. The row bypass and the field vote therefore name the same sets: the set's own entry for the object if it has one, otherwise its `'*'` wildcard. The private posture never changed that answer, since it withholds only a wildcard that carries neither bit. The new pin `the private posture never changes the super-user answer` holds it. - **Every reader agrees.** The list projection, record read, sort/filter gate, field-level write gate, `/auth/me/permissions` and `POST /security/explain` all read one of those two merges. - **Unchanged.** Union without deny is otherwise unchanged: a caller who holds no super-user set on the object is still masked. A field's `requiredPermissions` capability gate still applies after the merge. - **Docs.** Two published pages described what the runtime no longer does: - `content/docs/permissions/permissions-matrix.mdx` §3: the Sales Manager column, whose set holds View All on `contact` and Modify All on `opportunity`, plus one sentence on why. - `content/docs/permissions/field-level-security.mdx`: the union paragraph now names View All / Modify All. - Changeset `.changeset/29106-superuser-field-vote.md`: `patch` for `@objectstack/plugin-security` and `@objectstack/core`. ## Tests - `packages/plugins/plugin-security/src/fls-superuser-vote.test.ts` (new, 25 cases). It covers the card's repro against the shipped `admin_full_access`, order independence, the member control, the plain-read control, view-only-never-edits, modify reads and edits, a wildcard shadowed by an explicit entry, a vote held on another object, and undeclared fields staying absent. It also pins one predicate (field votes equal the `superuserBypassSets` answers, and the private posture never changes them) and parity between the row-blind and per-object merges. - `packages/core/src/security/effective-object-permissions.test.ts`: two cases, one for the row-blind vote and one for `holdsSuperuserBypass`. - `packages/qa/dogfood/test/fls-superuser-vote.dogfood.test.ts` (new, 11 cases, real showcase boot). The card's repro on `sys_business_unit`: an admin holding `admin_full_access` plus an app set with `readable: false` on `code`, `kind`, `manager_user_id` and `active`. Each door is checked as an admin case and a member control case: `/auth/me/permissions`, list, record read, sort and filter, and explain. - **Forced test edit 1 of 2:** `packages/plugins/plugin-security/src/explain-principal-person.test.ts`. Its `qa_pp_directory_masked` fixture held `viewAllRecords` on `sys_user` and `readable: false` on `sys_user.email`. Under the ruling that set reads its own masked field, so 4 cases went red. The fixture keeps its intent (every user row, email withheld) by reaching the rows through a `select` row policy instead of View All. All 16 cases are green, and the "armed" cases measure the read door itself. - **Forced test edit 2 of 2 (FAIL round 1):** `packages/services/service-automation/src/resume-decider-identity.integration.test.ts`. Its `deal_manager` fixture held `viewAllRecords` + `modifyAllRecords` on `deal` beside `'deal.restricted_note': { editable: false }`. Under the ruling the lock is out-voted by the set's own Modify All, so the decider's write landed and `a post-decision node the decider may not perform is refused loudly` went red in CI (Test Core 8/8). The manager now reaches every deal through `readScope: 'org'` / `writeScope: 'org'` instead of the super-user bits. Every assertion is unchanged. The GUARD case still shows the manager's write rests on the manager's own grants. 21/21 green. ## Acceptance notes - The precondition grep is posted on the card (issuecomment-6576959092). It found 0 declared sets that hold View All / Modify All beside a `readable: false` / `editable: false` entry on the same object, across the default sets, the showcase, the hotcrm fixture, skills and docs code blocks. The one docs near-hit (the permissions matrix) is fixed here at seat 2's request. - FAIL round 1, repo-wide fixture sweep (packages, examples, showcase and app metadata, tests included) for a set declaring `viewAllRecords` / `modifyAllRecords` beside `readable: false` / `editable: false` on the same object. Shipped and app metadata: 0 hits. Tests: the two forced edits above, plus `packages/qa/dogfood/test/admin-ledger-decision-metadata.dogfood.test.ts`. That file's `ald_withhold_set` / `ald_withhold_only_set` pair View All on `sys_user` with `email` withheld, so the `withheld` class no longer applies to those readers. Its assertions are about which ledger rows are served (none about the subject, through every door), not about the field, and it stays green. Noted here, not edited. - Every package with a field-permission test fixture beside a security boot was run on the new head: objectql (4 files), rest (4), runtime (1), cli (1), and service-automation in full (260 files / 3338 tests). All green. - The `/auth/me/permissions` merge lives in `@objectstack/core` (`buildEffectiveFieldPermissions`), not in `current-user-endpoints.ts`, so the diff touches `packages/core` and leaves `plugin-hono-server` unchanged. Seat 2 accepted this file-surface change. ## Verification Head `252a02f4` (FAIL round 1: one test-fixture commit on top of `718ba1b2`; origin/main `47718699` merged in). The gates and the full dogfood battery below ran on `718ba1b2`; the round-1 commit changes one service-automation test file only. <details><summary>Red first on main (5780fa4 + tests only)</summary> - plugin-security `fls-superuser-vote.test.ts`: 7 failed / 18 passed. Every admin vote case failed (`expected { readable: false, editable: false } to deeply equal { readable: true, editable: true }`). Controls and parity were green. - dogfood `fls-superuser-vote.dogfood.test.ts` (first layout): 6 failed / 2 passed. The admin sort was refused with the card's own message: `403 … references field(s) not readable by the caller: code`. Explain reported `4 field(s) masked from responses: [code, kind, manager_user_id, active]` for the admin. The member's `/auth/me/permissions` control was green. </details> <details><summary>Green after the fix</summary> - plugin-security `fls-superuser-vote.test.ts` 25/25 · core `effective-object-permissions.test.ts` 43/43 · dogfood `fls-superuser-vote.dogfood.test.ts` 11/11. - Package suites before the main merge: core 129 files passed; plugin-security 240 files / 5241 tests, with the 4 red cases named above fixed by the forced edit and that file rerun 16/16; plugin-hono-server 38 files / 472 tests passed. Typecheck (`tsc` + `check:test-typecheck`) passed for core, plugin-security and plugin-hono-server after a DTS build. - `eslint --no-inline-config` over `packages/core/src`, `packages/plugins/plugin-security/src` and the new dogfood file: exit 0. </details> <details><summary>Ablation of the new vote</summary> `superuserFieldVote` was made to return `null` first, through `scripts/ablation-replace.mjs`. Marker `ABLATION_29106_NO_SUPERUSER_VOTE`; `ablation-dist-preflight` showed it in `packages/core/dist/index.js` and `index.cjs`. - plugin-security unit: 6 failed / 19 passed. Admin vote, view-only, modify and three predicate rows went red; controls stayed green. - dogfood: 5 failed / 6 passed. Red: admin `/auth/me/permissions`, list, record read, sort+filter, explain. Green: premise and all 5 member controls. - core: 1 failed / 42 passed (the row-blind vote case). - Restore: blob back to HEAD `09e5a75c`, core rebuilt, `ablation-dist-preflight --absent` exit 0, `git status --porcelain` clean. </details> <details><summary>Gates and full dogfood (718ba1b)</summary> - `node scripts/pm/dispatch-gates.mjs --commands` on `718ba1b2`: 94 derived families, all run. 93 exit 0 on the first pass. `check-plugin-teardown-shape.mjs --self-test` exited 3 because its positive control commit was missing in the shallow clone; after `git fetch origin 621a487…` it exits 0 (48 cases). `--ran` reconciliation: 94 derived, 94 run, 0 NOT-MEASURED, 0 UNRUN. - Full dogfood battery on `718ba1b2` after a full `turbo run build --filter=./packages/** --filter=./examples/**` (10m41s under the lock): `pnpm --filter @objectstack/dogfood test` → VERDICT command-exit 0 · Test Files 394 passed / 3 skipped (397) · Tests 3254 passed / 28 skipped (3282) · no failures. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmSgjH5Vi4jT3KVJpvt <!-- signed: domain:server#2 · os-steve · session_01ADHkmSgjH5Vi4jT3KVJpvt --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f95d0db commit 4138ce8

11 files changed

Lines changed: 598 additions & 17 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/plugin-security': patch
3+
'@objectstack/core': patch
4+
---
5+
6+
fix(plugin-security): a permission set holding View All / Modify All on an object reads and edits every field of it, so an app's field mask no longer hides fields from platform admins
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
An app permission set could not withhold a platform object's fields from its own members without withholding them from platform admins too. Field permissions merge most-permissively, but only sets that declare a field entry voted. `admin_full_access` grants every object through its `'*'` super-user bits and declares no field entries, so it cast no vote, and an app set's `readable: false` hid the field from any admin who also held the app set. Lists dropped the columns, sorting or filtering on them was refused 403, and Setup screens rendered them empty.
12+
13+
Now, per ADR-0066 D2 ⑧ as amended (ruling of record 6573563853), a set that holds the super-user bypass on an object votes on every field of that object in the field merge:
14+
15+
- **`viewAllRecords` votes `readable: true`.** It never grants an edit.
16+
- **`modifyAllRecords` votes `readable: true` and `editable: true`.**
17+
- **Who counts as holding it is the row-level answer.** It is the same rule `PermissionEvaluator.superuserBypassSets` applies: the set's own entry for the object if it has one, otherwise its `'*'` wildcard. The field merge and the row bypass now read it through one function, `holdsSuperuserBypass` (`@objectstack/core`).
18+
- **Every reader agrees.** That covers list projection, record read, the sort and filter gate, the field-level write gate, `GET /auth/me/permissions` (`fields`) and `POST /security/explain`.
19+
- **Union without deny is otherwise unchanged.** A caller who holds the app set and no super-user set on the object is still masked. A field's `requiredPermissions` capability gate still applies to everyone.
20+
21+
**What to check after upgrading.** A permission set that holds `viewAllRecords` or `modifyAllRecords` on an object and also declares `readable: false` (or `editable: false`) on that object's fields no longer hides those fields from its own holders. To keep a field from someone, grant them the object without View All / Modify All and withhold the field there.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ only constrain fields they explicitly enumerate, and field grants union
157157
most-permissively across a user's sets (one set's `readable: true`
158158
out-votes another set's `false`). Until a subtractive muting layer lands
159159
(ADR-0066 ⑧), a `{ readable: false }` rule masks the field only as long
160-
as **no other set the user holds** declares it `readable: true` — so
160+
as **no other set the user holds** declares it `readable: true` or holds
161+
View All (`viewAllRecords`, reads every field of the object) or Modify All
162+
(`modifyAllRecords`, reads and edits every field) on that object — so
161163
protect sensitive fields by granting them only in the sets that need
162164
them, and treat a sensitive field on a broadly-granted object as a
163165
review smell — see the

‎content/docs/permissions/permissions-matrix.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ Field-level security controls visibility and editability of individual fields pe
139139
| `account.name` | Visible, Editable | Visible, Editable | Visible, Editable | Visible | Visible |
140140
| `account.revenue` | Visible, Editable | Visible, Editable | Visible | Hidden | Hidden |
141141
| `contact.email` | Visible, Editable | Visible, Editable | Visible, Editable | Visible | Visible |
142-
| `contact.ssn` | Visible, Editable | Hidden | Hidden | Hidden | Hidden |
142+
| `contact.ssn` | Visible, Editable | Visible | Hidden | Hidden | Hidden |
143143
| `opportunity.amount` | Visible, Editable | Visible, Editable | Visible, Editable | Visible | Visible |
144-
| `opportunity.margin` | Visible, Editable | Visible | Hidden | Hidden | Hidden |
144+
| `opportunity.margin` | Visible, Editable | Visible, Editable | Hidden | Hidden | Hidden |
145+
146+
**View All / Modify All reach every field.** The Sales Manager column follows from section 2: `sales_manager_access` holds `viewAllRecords` on `contact` and `modifyAllRecords` on `opportunity`, and a set holding View All on an object reads every field of it, while Modify All also edits every field (ADR-0066 D2 ⑧ as amended). Field rules in other sets cannot hide `contact.ssn` from that manager. To keep a field from someone, grant them the object without View All / Modify All and withhold the field there.
145147

146148
### FLS States
147149

‎packages/core/src/security/effective-object-permissions.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
buildEffectiveFieldPermissions,
2020
buildEffectiveObjectPermissions,
2121
fieldPermissionVote,
22+
holdsSuperuserBypass,
2223
registryObjectPackageDisabled,
2324
} from './effective-object-permissions.js';
2425

@@ -573,6 +574,39 @@ describe('buildEffectiveFieldPermissions (#25866)', () => {
573574
expect(widened).toEqual({ 'deal.amount': { readable: true, editable: true } });
574575
});
575576

577+
// [ADR-0066 ⑧, ruling of record 6573563853] A set holding the super-user
578+
// bypass on an object votes on every field of it: `viewAllRecords` reads,
579+
// `modifyAllRecords` reads and edits — the same sets `superuserBypassSets`
580+
// (`@objectstack/plugin-security`) names, through `holdsSuperuserBypass`.
581+
it('a super-user set votes on every declared field of its object; a plain set does not', () => {
582+
const mask = { fields: { 'deal.amount': { readable: false, editable: false }, 'lead.score': { readable: false, editable: false } } };
583+
expect(buildEffectiveFieldPermissions([{ objects: { '*': { modifyAllRecords: true } } }, mask])).toEqual({
584+
'deal.amount': { readable: true, editable: true },
585+
'lead.score': { readable: true, editable: true },
586+
});
587+
expect(buildEffectiveFieldPermissions([{ objects: { deal: { viewAllRecords: true } } }, mask])).toEqual({
588+
'deal.amount': { readable: true, editable: false },
589+
'lead.score': { readable: false, editable: false },
590+
});
591+
// An explicit entry shadows the same set's wildcard, as at row level.
592+
expect(buildEffectiveFieldPermissions([{ objects: { '*': { viewAllRecords: true }, deal: { allowRead: true } } }, mask]))
593+
.toEqual({ 'deal.amount': { readable: false, editable: false }, 'lead.score': { readable: true, editable: false } });
594+
// Control: no bypass bit, no vote — union without deny is unchanged.
595+
expect(buildEffectiveFieldPermissions([{ objects: { deal: { allowRead: true, allowEdit: true } } }, mask])).toEqual({
596+
'deal.amount': { readable: false, editable: false },
597+
'lead.score': { readable: false, editable: false },
598+
});
599+
});
600+
601+
it('holdsSuperuserBypass: explicit entry first, then the wildcard; modify implies view, view never implies modify', () => {
602+
expect(holdsSuperuserBypass({ objects: { '*': { viewAllRecords: true } } }, 'deal', 'view')).toBe(true);
603+
expect(holdsSuperuserBypass({ objects: { '*': { viewAllRecords: true } } }, 'deal', 'modify')).toBe(false);
604+
expect(holdsSuperuserBypass({ objects: { deal: { modifyAllRecords: true } } }, 'deal', 'view')).toBe(true);
605+
expect(holdsSuperuserBypass({ objects: { '*': { modifyAllRecords: true }, deal: {} } }, 'deal', 'modify')).toBe(false);
606+
expect(holdsSuperuserBypass({ objects: null }, 'deal', 'view')).toBe(false);
607+
expect(holdsSuperuserBypass(null, 'deal', 'view')).toBe(false);
608+
});
609+
576610
it('aliases nothing: every entry is a fresh object', () => {
577611
const entry = { readable: true, editable: true };
578612
const map = buildEffectiveFieldPermissions([{ fields: { 'deal.amount': entry } }]);

‎packages/core/src/security/effective-object-permissions.ts‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,9 +741,72 @@ export function fieldPermissionVote(
741741
return { readable: entry.readable === true, editable: verdict === 'matched' && entry.editable === true };
742742
}
743743

744+
/**
745+
* [ADR-0066 D2 / ①] Does `set` hold the super-user ("View/Modify All Data")
746+
* bypass on `objectName`? The ONE reading of that question:
747+
* `PermissionEvaluator.superuserBypassSets` (`@objectstack/plugin-security`,
748+
* the row-level bypass every RLS, sharing and explain consumer folds through)
749+
* asks it per set, and so does the field merge's super-user vote below, so the
750+
* two can never disagree about who is a super-user on an object.
751+
*
752+
* The set's own entry for the object answers when it has one; otherwise its
753+
* `'*'` wildcard does (`resolveObjectPermission` in the evaluator: lookup, not
754+
* merge). The private posture never changes the answer, because it withholds
755+
* only a wildcard that carries NEITHER bit.
756+
*
757+
* - `view` — `viewAllRecords` OR `modifyAllRecords` (Modify All implies View All);
758+
* - `modify` — `modifyAllRecords` only: View All never widens a write.
759+
*/
760+
export function holdsSuperuserBypass(
761+
set: { objects?: Record<string, unknown> | null } | null | undefined,
762+
objectName: string,
763+
bit: 'view' | 'modify',
764+
): boolean {
765+
const objects = set?.objects;
766+
if (!objects || typeof objects !== 'object') return false;
767+
const op = (objects[objectName] || objects['*']) as
768+
| { viewAllRecords?: unknown; modifyAllRecords?: unknown }
769+
| null
770+
| undefined;
771+
if (!op || typeof op !== 'object') return false;
772+
return bit === 'modify' ? Boolean(op.modifyAllRecords) : Boolean(op.viewAllRecords || op.modifyAllRecords);
773+
}
774+
775+
/**
776+
* [ADR-0066 D2 ⑧ as amended — ruling of record 6573563853, letter A] The
777+
* super-user vote in the field merge: when any of `sets` holds the bypass on
778+
* `objectName` ({@link holdsSuperuserBypass}), it votes on EVERY field of that
779+
* object — `viewAllRecords` votes `readable: true`, `modifyAllRecords` votes
780+
* `readable: true` and `editable: true`. `null` when no set holds it.
781+
*
782+
* A set that grants the object through its super-user bits but names no field
783+
* used to cast no vote at all, so another set's `readable: false` hid the
784+
* field from a platform admin who also held that set. Union without deny is
785+
* otherwise unchanged: a caller who holds no super-user set on the object is
786+
* narrowed by a declared mask as before. Applied to the fields the merge
787+
* already holds an entry for; an absent field is unrestricted anyway.
788+
*
789+
* Both merges apply it after their declared-entry votes —
790+
* `PermissionEvaluator.getFieldPermissions` per object and
791+
* {@link buildEffectiveFieldPermissions} for every object.
792+
*/
793+
export function superuserFieldVote(
794+
sets: ReadonlyArray<{ objects?: Record<string, unknown> | null } | null | undefined>,
795+
objectName: string,
796+
): { readable: true; editable: boolean } | null {
797+
let read = false;
798+
for (const ps of sets) {
799+
if (holdsSuperuserBypass(ps, objectName, 'modify')) return { readable: true, editable: true };
800+
if (!read && holdsSuperuserBypass(ps, objectName, 'view')) read = true;
801+
}
802+
return read ? { readable: true, editable: false } : null;
803+
}
804+
744805
/** A resolved permission set, as far as the field merge reads it. */
745806
export interface EffectiveFieldPermissionsInputSet {
746807
fields?: Record<string, unknown> | null;
808+
/** Read only for the super-user vote ({@link superuserFieldVote}). */
809+
objects?: Record<string, unknown> | null;
747810
}
748811

749812
/**
@@ -756,6 +819,9 @@ export interface EffectiveFieldPermissionsInputSet {
756819
* this map never advertises an edit the write gate refuses, and may hide one it
757820
* admits on the rows the condition does not name.
758821
*
822+
* A set holding the super-user bypass on an object then votes on every field
823+
* of it ({@link superuserFieldVote}, ruling of record 6573563853).
824+
*
759825
* Every entry is a FRESH object, as {@link buildEffectiveObjectPermissions}'s are.
760826
*/
761827
export function buildEffectiveFieldPermissions(
@@ -774,5 +840,18 @@ export function buildEffectiveFieldPermissions(
774840
fields[key] = acc;
775841
}
776842
}
843+
// [Ruling of record 6573563853] The super-user vote, per object the map
844+
// names — the same function `getFieldPermissions` applies per object.
845+
const votes = new Map<string, ReturnType<typeof superuserFieldVote>>();
846+
for (const [key, acc] of Object.entries(fields)) {
847+
const dot = key.indexOf('.');
848+
if (dot <= 0) continue;
849+
const objectName = key.slice(0, dot);
850+
if (!votes.has(objectName)) votes.set(objectName, superuserFieldVote(sets, objectName));
851+
const vote = votes.get(objectName);
852+
if (!vote) continue;
853+
acc.readable = true;
854+
if (vote.editable) acc.editable = true;
855+
}
777856
return fields;
778857
}

‎packages/core/src/security/index.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ export {
320320
// field-permission entry's vote under its row condition (`when`).
321321
buildEffectiveFieldPermissions,
322322
fieldPermissionVote,
323+
// [ADR-0066 ⑧, ruling of record 6573563853] The one super-user predicate
324+
// (row bypass and field vote alike) and the field merge's super-user vote.
325+
holdsSuperuserBypass,
326+
superuserFieldVote,
323327
type FieldConditionVerdict,
324328
type FieldPermissionEntryLike,
325329
type EffectiveFieldPermissionsInputSet,

‎packages/plugins/plugin-security/src/explain-principal-person.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,18 @@ const DIRECTORY_SET = PermissionSetSchema.parse({
5050
objects: { sys_user: { allowRead: true, viewAllRecords: true }, [BOARD]: { allowRead: true } },
5151
systemPermissions: ['manage_users'],
5252
});
53-
/** The same directory with the email column withheld by field-level security. */
53+
/**
54+
* The same directory with the email column withheld by field-level security.
55+
* Every user row is reached by a row policy rather than `viewAllRecords`: a
56+
* set holding View All on an object votes `readable: true` on every field of
57+
* it (ADR-0066 D2 ⑧ as amended, ruling of record 6573563853), so its own mask
58+
* could not withhold the email.
59+
*/
5460
const MASKED_DIRECTORY_SET = PermissionSetSchema.parse({
5561
name: 'qa_pp_directory_masked',
56-
objects: { sys_user: { allowRead: true, viewAllRecords: true }, [BOARD]: { allowRead: true } },
62+
objects: { sys_user: { allowRead: true }, [BOARD]: { allowRead: true } },
5763
fields: { 'sys_user.email': { readable: false, editable: false } },
64+
rowLevelSecurity: [{ name: 'qa_pp_directory_rows', object: 'sys_user', operation: 'select', using: "id != ''" }],
5865
systemPermissions: ['manage_users'],
5966
});
6067
/** `manage_users` and nothing else: it may explain a user, and its read door returns it no user row. */

0 commit comments

Comments
 (0)