Repository navigation
Commit 51a12c0
feat(lint): warn when a permission set's own View All / Modify All makes its field mask inert (#29724)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8W3xWg9UzvjKRfew8ju8Fz6)_
Fixes #29544
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:`@objectstack/lint` 新增一条 warning 规则
`security-superuser-field-mask-inert`。权限集在某对象上持有「查看全部」或「修改全部」,同一集合又对该对象的字段写了
`readable: false`(或在「修改全部」下的编辑锁)时,提示这个遮罩对持有人不生效,并给出改法。
- 为什么改:按 #29106 的裁决 A,超级用户位对该对象的每个字段都投 readable/editable
票,同集合的遮罩成了摆设;作者以为字段藏住了,其实没有,仓里已有两个测试夹具因此被修过。
- 风险与回滚:只是 warning,任何入口都不拒收(运行时发布门禁实测记为
advisory)。示例、showcase、平台默认权限集普查均为 0 条。回滚即还原本 PR,无迁移。
- 先看:`packages/lint/src/validate-security-posture.ts` 中新规则段(紧挨 Modify
All 删除段之前)与 `holdsSuperuserBypass`
副本;`packages/cli/test/superuser-bypass-mirror-parity.test.ts`。
- 两分钟验证:`pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2
src/validate-security-posture.test.ts -t inert`,预期 8 个测试全绿。
- 需要你做的:无,席位落地
## What changes
After ruling A on #29106 (ruling of record 6573563853), a permission set
that holds View All or Modify All on an object votes on every field of
that object in both field merges (`superuserFieldVote` in
`@objectstack/core`). So the same set's `readable: false` on that object
hides the field from none of its holders, and under Modify All its edit
lock (`editable: false`, or `editable` omitted, which parses to false)
holds none of them back. The pair is legal, so nothing warned the
author.
New rule id `security-superuser-field-mask-inert`, severity **warning**,
pushed from `validateSecurityPosture`'s permission-set loop. That
function is the existing `validateSecurityPosture` entry in
`AUTHORING_RULES`, so the warning runs on `os lint`, `os validate`, `os
build` and the runtime publish gate for a `permission` write (measured
on the built `runtime.js`: `runRuntimeAuthoringRules({ type:
'permission', … })` returns it under `advisories`, `errors` empty).
- `viewAllRecords` beside `readable: false` → finding.
- `modifyAllRecords` beside `readable: false` or an edit lock → finding;
one finding per entry, naming both when both are inert.
- `viewAllRecords` beside an edit lock → no finding (View All never
widens a write, so the lock binds).
- One set at a time: another set's bypass also unmasks a holder of both
sets, but no author wrote an inert entry there.
Example message: `viewAllRecords on objects.sys_user votes on every
field of "sys_user", so readable: false on 'sys_user.email' binds none
of this set's holders`. Hint: remove the bit and reach the rows with
`readScope` / `writeScope` or a row-level policy, or delete the entry if
the bypass is meant.
**The bypass reading.** `@objectstack/lint` depends on
`@objectstack/spec` alone, so it cannot import core.
`holdsSuperuserBypass` is copied verbatim into
`validate-security-posture.ts` (the `objects[name] || objects['*']`
lookup, `Boolean(...)` bits, Modify All implies View All) and exported
from the lint barrel under the same name.
`packages/cli/test/superuser-bypass-mirror-parity.test.ts` imports
core's function and lint's copy and asserts they answer alike over a
410-case matrix (own entry × wildcard entry, each absent / null / empty
/ view / modify / both / false / truthy and falsy non-booleans, × object
× bit, plus sets with no usable `objects`). The seat ruled this route
(claim amendment 6593310531).
The entry's bits are read as parsing writes them: an omitted `readable`
is `true`, an omitted `editable` is `false`. A raw set and its parse
give the same answer (pinned).
Files (6, +402 / -1):
- `packages/lint/src/validate-security-posture.ts`: the id, the
`holdsSuperuserBypass` copy, the arm, a header table row.
- `packages/lint/src/rule-explanations.ts`: the id's `os explain` entry.
- `packages/lint/src/index.ts`: exports the id and
`holdsSuperuserBypass`.
- `packages/lint/src/validate-security-posture.test.ts`: a new top-level
`describe` (8 cases), plus the file's meta-guards: the id in `RULE_IDS`,
a reachability-corpus fixture, push-site count 19 → 20, read surfaces
`set` / `op` / `mask`, and `inertBits` under plumbing.
- `packages/cli/test/superuser-bypass-mirror-parity.test.ts`: the parity
pin (new file).
- `.changeset/29544-superuser-field-mask-inert.md`: patch for
`@objectstack/lint`.
New public names: the rule id and the `holdsSuperuserBypass` export from
`@objectstack/lint` (same name as core's on purpose: it is the same
function).
## Why
The two repo fixtures the card names
(`resume-decider-identity.integration.test.ts`,
`explain-principal-person.test.ts`) went inert silently and were
repaired by #29387. The composed sets in
`admin-ledger-decision-metadata.dogfood.test.ts` are built from shared
consts, so a grep for the pair does not find them. Reading the
normalized set does.
## Tests
`validate-security-posture.test.ts`, new `describe` "a field mask its
own set's View All / Modify All makes inert". Each case is a set parsed
by `PermissionSetSchema` unless it says otherwise:
1. The resume-decider fixture before its repair (Modify All +
`restricted_note` edit lock) → one warning.
2. The explain-principal-person fixture before its repair (View All +
`email` read mask) → one warning.
3. The admin-ledger dogfood's composed sets, spelled from shared consts
as that file does: `ald_withhold_set` and `ald_withhold_only_set` each
fire once on `sys_user.email`; the `editable: false` grants beside View
All and `ald_unmask_set` fire nothing.
4. Modify All + `readable: false` → warning; View All + edit lock →
nothing.
5. Wildcard: `'*'` Modify All with no entry for the object → warning;
`'*'` Modify All plus an explicit entry without the bit → nothing
(lookup, not merge).
6. Unparsed `{ readable: true }` under Modify All → warning, and equal
to the parsed set's answer.
7. Controls: the two fixtures as repaired (row policy + mask; org
read/write depth + lock), and a bypass in one set beside a mask in
another → nothing.
8. One-line message (≤ 200 chars) and hint, naming the bit and the
entry; `explainRule` defined for the id.
Red first, on `61adbe57` (tests plus the id constant, no arm): 7 failed,
1 passed (the control case).
Parity: `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2 test/superuser-bypass-mirror-parity.test.ts`: 3/3.
Ablation of the parity pin (rule committed first; `node
scripts/ablation-replace.mjs`, run under a restore trap): in lint's
copy, the anchor `const op = (objects[objectName] || objects['*']) as`
was replaced with the wildcard-first lookup (anchor 1 → 0, blob
`df680307` → `37845e72`). `pnpm --filter @objectstack/lint build`, then
`node scripts/ablation-dist-preflight.mjs @objectstack/lint
'objects["*"] || objects[objectName]' --source-marker=…`: marker in 4
built files, tree reading passed, exit 0. Parity test: 2 failed, 1
passed, with 60 diverging cases listed. Restored: blob equals HEAD
`df680307`, `git diff HEAD` empty. After a rebuild, the preflight
`--absent` check exited 0 (marker absent from all 20 built files, tree
clean), and the parity test passed 3/3.
## Acceptance notes
- Census, run with the rule on built `dist/` over loaded modules:
`examples/app-crm` 2 sets → 0; `examples/app-todo`,
`examples/app-multi-package` 0 sets; the showcase
(`examples/app-showcase/src/security/permission-sets.ts`) 9 sets, 2 with
field entries → 0; the platform baseline (`plugin-security`'s
`default-permission-sets.ts`) 9 sets, 6 with field entries → 0.
- Test fixtures can't be loaded outside vitest, so they were read by
hand, not run. 24 files carry both a bypass bit and a field entry. Only
the admin-ledger dogfood's two composed sets would fire (case 3). The
two repaired fixtures are clean. The rest put the bit and the mask in
different sets (`fls-superuser-vote*`, `explain-engine`), on different
objects (`delete-reference-cleanup-system-identity`), or on a `'*'`
entry without the bits (`security-plugin.test.ts`).
- Noted, not filed: by the same ruling, the admin-ledger dogfood's
`withheld` and `wildcard` readers are not actually withheld `email`:
their own set's View All on `sys_user` unbinds the mask. That file's
header calls the View All "a row-scope grant, not a field one". The file
still passes, because it asserts that no reader is served a subject row
at all (deployment-level rows), so no assertion depends on the mask. It
is not edited here, since the census does not force it. Carrier: none;
the seat decides.
- A `when`-conditioned edit lock under Modify All is reported like any
other lock, because the merge applies the super-user vote under every
`when` verdict (plugin-security's explain report already calls such an
entry superseded). The spec refuses `readable: false` beside `when`, so
no conditioned read mask exists to judge.
## Verification
<details><summary>Package suites and typecheck</summary>
All on head `c20d3a56` (after the second `origin/main` merge, which
auto-merged a sibling rule's lines in `index.ts` and
`rule-explanations.ts`), after `pnpm --filter '@objectstack/core...'
--filter '@objectstack/lint...' build`:
- `pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2`: Test
Files 192 passed (192); Tests 7942 passed (7942).
- `pnpm --filter @objectstack/lint typecheck`: exit 0 (`tsc --noEmit`
and `check:test-typecheck: OK`, debt unchanged at 2 files / 6 errors).
- `pnpm --filter @objectstack/cli exec vitest run --project unit
--maxWorkers=2 test/superuser-bypass-mirror-parity.test.ts`: 3/3.
- `packages/cli` typecheck: narrowed, and declared here. Its full `tsc`
needs the 63-package build closure, so it is left to `TypeScript Type
Check`. Locally, the new file alone compiled under
`packages/cli/tsconfig.test.json`'s options (a scratch tsconfig
extending it, `files` set to the one test, `--listFiles`): exit 0, the
file in the program, both `core/dist/index.d.ts` and
`lint/dist/index.d.ts` resolved.
- `test:repo` is not run locally (CI's `Test Core`): the diff touches no
`repo`-project test.
</details>
<details><summary>Derived gates and lint</summary>
On head `c20d3a56`, `node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack` derived 58 commands from the 6-path
change set (the same 58 as on the first head). All 58 recorded `exit 0`,
and `--ran` reconciled them: "58 derived, 58 run, 0 NOT-MEASURED, 0
UNRUN". `pnpm lint`: exit 0 (outside the derivation).
On the first head, two had exited 3 (prerequisite not met):
`check-plugin-teardown-shape.mjs --self-test` needed an unshallow clone
(`git fetch --unshallow origin main`, then 48 cases pass), and
`check:dual-build-cjs-loads` needed built `dist/`. On the final head it
reports 115 require entry points across 70 packages load.
Among them: `check:cross-package-test-inputs` (31 packages read outside
themselves, all declared), `check:test-source-alias`,
`check:undeclared-dep-imports`, `check:doc-authoring` and
`check:issue-citations`, all exit 0.
</details>
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(No spec hunk.)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV)_
<!-- signed: domain:server#3 · os-warren ·
session_01JQwxbYyp6wSRcywGFK2L4A -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent c9c6828 commit 51a12c0
6 files changed
Lines changed: 402 additions & 1 deletion
File tree
- .changeset
- packages
- cli/test
- lint/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
889 | 889 | | |
890 | 890 | | |
891 | 891 | | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
892 | 916 | | |
893 | 917 | | |
894 | 918 | | |
| |||
5563 | 5587 | | |
5564 | 5588 | | |
5565 | 5589 | | |
| 5590 | + | |
5566 | 5591 | | |
5567 | 5592 | | |
5568 | 5593 | | |
| |||
0 commit comments