Repository navigation
feat(lint): warn when a permission set's own View All / Modify All makes its field mask inert - #29724
Conversation
Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
…makes inert security-superuser-field-mask-inert: a permission set holding the super-user bypass on an object votes on every field of it, so its own readable: false (View All or Modify All) or edit lock (Modify All) binds none of its holders. The bypass is read through a verbatim copy of core's holdsSuperuserBypass. Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a46d56122a219de8317ea7781446b921902c9832 && git checkout a46d56122a219de8317ea7781446b921902c9832
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c779611eb1db77a53e5e4c58b015cef93512792f 07327a14678c408dfea64df24bba145819ecd134 && git checkout -B drift-repro c779611eb1db77a53e5e4c58b015cef93512792f && git merge --no-ff 07327a14678c408dfea64df24bba145819ecd134
node scripts/docs-audit/affected-docs.mjs --json c779611eb1db77a53e5e4c58b015cef93512792f
|
Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbYxYhTvMoYjkUw8XvV Co-authored-by: Claude <noreply@anthropic.com>
|
domain:server#3 · os-warren · session_01JQwxbYyp6wSRcywGFK2L4A Contract reviewServed-tier: Face: declaration only ( ① Derived judgments
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
domain:server#3 · os-warren · session_01JQwxbYyp6wSRcywGFK2L4A 维护者速读
席位核对ACCEPT ·
|
Requested by Warren · project thread
Fixes #29544
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
@objectstack/lint新增一条 warning 规则security-superuser-field-mask-inert。权限集在某对象上持有「查看全部」或「修改全部」,同一集合又对该对象的字段写了readable: false(或在「修改全部」下的编辑锁)时,提示这个遮罩对持有人不生效,并给出改法。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 (
superuserFieldVotein@objectstack/core). So the same set'sreadable: falseon that object hides the field from none of its holders, and under Modify All its edit lock (editable: false, oreditableomitted, 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 fromvalidateSecurityPosture's permission-set loop. That function is the existingvalidateSecurityPostureentry inAUTHORING_RULES, so the warning runs onos lint,os validate,os buildand the runtime publish gate for apermissionwrite (measured on the builtruntime.js:runRuntimeAuthoringRules({ type: 'permission', … })returns it underadvisories,errorsempty).viewAllRecordsbesidereadable: false→ finding.modifyAllRecordsbesidereadable: falseor an edit lock → finding; one finding per entry, naming both when both are inert.viewAllRecordsbeside an edit lock → no finding (View All never widens a write, so the lock binds).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 withreadScope/writeScopeor a row-level policy, or delete the entry if the bypass is meant.The bypass reading.
@objectstack/lintdepends on@objectstack/specalone, so it cannot import core.holdsSuperuserBypassis copied verbatim intovalidate-security-posture.ts(theobjects[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.tsimports 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 usableobjects). The seat ruled this route (claim amendment 6593310531).The entry's bits are read as parsing writes them: an omitted
readableistrue, an omittededitableisfalse. A raw set and its parse give the same answer (pinned).Files (6, +402 / -1):
packages/lint/src/validate-security-posture.ts: the id, theholdsSuperuserBypasscopy, the arm, a header table row.packages/lint/src/rule-explanations.ts: the id'sos explainentry.packages/lint/src/index.ts: exports the id andholdsSuperuserBypass.packages/lint/src/validate-security-posture.test.ts: a new top-leveldescribe(8 cases), plus the file's meta-guards: the id inRULE_IDS, a reachability-corpus fixture, push-site count 19 → 20, read surfacesset/op/mask, andinertBitsunder 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
holdsSuperuserBypassexport 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 inadmin-ledger-decision-metadata.dogfood.test.tsare 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, newdescribe"a field mask its own set's View All / Modify All makes inert". Each case is a set parsed byPermissionSetSchemaunless it says otherwise:restricted_noteedit lock) → one warning.emailread mask) → one warning.ald_withhold_setandald_withhold_only_seteach fire once onsys_user.email; theeditable: falsegrants beside View All andald_unmask_setfire nothing.readable: false→ warning; View All + edit lock → nothing.'*'Modify All with no entry for the object → warning;'*'Modify All plus an explicit entry without the bit → nothing (lookup, not merge).{ readable: true }under Modify All → warning, and equal to the parsed set's answer.explainRuledefined 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 anchorconst op = (objects[objectName] || objects['*']) aswas replaced with the wildcard-first lookup (anchor 1 → 0, blobdf680307→37845e72).pnpm --filter @objectstack/lint build, thennode 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 HEADdf680307,git diff HEADempty. After a rebuild, the preflight--absentcheck exited 0 (marker absent from all 20 built files, tree clean), and the parity test passed 3/3.Acceptance notes
dist/over loaded modules:examples/app-crm2 sets → 0;examples/app-todo,examples/app-multi-package0 sets; the showcase (examples/app-showcase/src/security/permission-sets.ts) 9 sets, 2 with field entries → 0; the platform baseline (plugin-security'sdefault-permission-sets.ts) 9 sets, 6 with field entries → 0.fls-superuser-vote*,explain-engine), on different objects (delete-reference-cleanup-system-identity), or on a'*'entry without the bits (security-plugin.test.ts).withheldandwildcardreaders are not actually withheldemail: their own set's View All onsys_userunbinds 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.when-conditioned edit lock under Modify All is reported like any other lock, because the merge applies the super-user vote under everywhenverdict (plugin-security's explain report already calls such an entry superseded). The spec refusesreadable: falsebesidewhen, so no conditioned read mask exists to judge.Verification
Package suites and typecheck
All on head
c20d3a56(after the secondorigin/mainmerge, which auto-merged a sibling rule's lines inindex.tsandrule-explanations.ts), afterpnpm --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 --noEmitandcheck: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/clitypecheck: narrowed, and declared here. Its fulltscneeds the 63-package build closure, so it is left toTypeScript Type Check. Locally, the new file alone compiled underpackages/cli/tsconfig.test.json's options (a scratch tsconfig extending it,filesset to the one test,--listFiles): exit 0, the file in the program, bothcore/dist/index.d.tsandlint/dist/index.d.tsresolved.test:repois not run locally (CI'sTest Core): the diff touches norepo-project test.Derived gates and lint
On head
c20d3a56,node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 58 commands from the 6-path change set (the same 58 as on the first head). All 58 recordedexit 0, and--ranreconciled 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-testneeded an unshallow clone (git fetch --unshallow origin main, then 48 cases pass), andcheck:dual-build-cjs-loadsneeded builtdist/. 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-authoringandcheck:issue-citations, all exit 0.Human Minimum
packages/specholds no runtime logic. (No spec hunk.)pnpm lintpasses.main, one pull request.packages/spectouched: n/a.content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code