Repository navigation
feat(lint): warn when a permission set reads a roll-up summary over child data it cannot read - #31046
Conversation
…a it cannot read Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
📓 Docs Drift CheckThis PR changes 1 package(s): 25 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 3 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 39d564057e55f81f5f6799713909eb06b0645f63 && git checkout 39d564057e55f81f5f6799713909eb06b0645f63
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e1dac19257184aa28115ead12c4ce0918d55b2b4 44f83463eae437ec760d31c6f9a7863f8b2949b3 && git checkout -B drift-repro e1dac19257184aa28115ead12c4ce0918d55b2b4 && git merge --no-ff 44f83463eae437ec760d31c6f9a7863f8b2949b3
node scripts/docs-audit/affected-docs.mjs --json e1dac19257184aa28115ead12c4ce0918d55b2b4
|
|
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc Contract reviewServed-tier: Reviewed 2026-11-06T20:37Z on the net diff Check-runs on this head, as they stand: 61 runs: 17 success, 8 skipped, 0 failure, 36 still in progress. The success runs include Check Changeset, Governed Surface Queue Guard, Lint · ESLint, Lint · PM dispatch-gates, PR-body guards, Spec property liveness, Type Check · source gates, Check Documentation Links and Dogfood Regression Gate. Still in progress: Build Core, Build Docs, Build and E2E UI, Live E2E UI, Test Core 1–8 of 8, Test UI 1–16 of 16, Type Check UI, Type Check · workspace, Type Check · consumer gates, Type Check · debt ledger, and Lint · CI, release and engine gates, docs and code guards, repo and tooling gates, scoped slot lookup and corpus. ① Derived judgmentsPublic surface ( Rule ids: right. Registry entry: right on every field except the reason text.
Docs. The four-doors row is correct: the columns are validate / build / lint / runtime publish, and the row reads ✓ ✓ ✓ —, which is CLI-only. The Where "can read" matches the runtime. These points were checked against
Where "can read" does not match the runtime.
Dev deviation: messages pinned by inline snapshots. Accepted. This is the first ② Semver levelThe
The M1 fix reads keys the spec already declares, so the level stays ③ Boundary flags(1) Runtime publish gate. Answer: A for this PR. B as a separate card, sent to the maintainer.
S4 (should-fix): the shipped (2) Record sharing in the row-scope arm. Answer: no, not in this PR.
(3) Intentional roll-ups warn permanently. Answer: leave it in this PR. Send the decision to a separate card. Do not edit the showcase sets as a reflex.
Implemented-by: VERDICT: FAIL |
…filter fields and the row-security posture "Can read" now folds the capability gate on both sides of the roll-up: an object's requiredPermissions (the list, or the read bucket of the per-operation map) and a field's requiredPermissions against the set's own systemPermissions. A set that cannot see the summary column through it is not reported; a set that cannot read the child object or field through it is, even with View All or Modify All on the child, which do not lift the gate. The child fields summaryOperations.filter tests are judged like the aggregated field, top-level keys only. The View All / Modify All skip of the row-scope note applies only to a private, tenancy-off or auth-managed child, the postures on which the bypass skips row security; on any other child the set's row policies still narrow its reads and are noted. The fix line now states the reach of the remedy: readable: false on a set hides the summary column from every holder of that set, a co-held set with no entry does not restore it, and readable: true in the sets whose holders should keep it does. The registry entry's surfaceReason names the actual reason the rule stays CLI-only. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
…n string The precedent the reason names moves to an adjacent comment; the string names it by the rule that crossed. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibvynRbCtMndW8EHNGc
|
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc Contract reviewServed-tier: Reviewed 2026-11-06T22:32Z on the net diff This record supersedes the FAIL on Check-runs on this head: 69 runs, 59 success, 10 skipped, 0 failure, none in progress. Nine of the ten required contexts are success: Lint & Repo Gates, TypeScript Type Check, Test Core, Build Core, Governed Surface Queue Guard, Type Check UI, Test UI, Build & E2E UI and Live E2E UI. ① Derived judgmentsThe previous must-fix and should-fixes, judged in the tree.
Tested against the new logic, beyond the fixes: held.
New should-fixes.
Non-blocking notes.
② Semver levelThe
③ Boundary flagsThe delta changes none of the three answers. They carry forward from the previous record.
Implemented-by: VERDICT: PASS |
|
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc 席位核对ACCEPT · 2026-11-06T22:33Z · head
Generated by Claude Code |
security#1 · os-tesla · session_01L9qibvynRbCtMndW8EHNGc
Clause-②: yes (widening) —
@objectstack/lintexports one new rule function,validateRollupSourceVisibility, its two rule-id constantsSECURITY_ROLLUP_SOURCE_UNREADABLEandSECURITY_ROLLUP_SOURCE_ROW_SCOPED, and two finding types; nothing that passed before is refused.Metadata-protocol: none
维护者速读
@objectstack/lint新增一条作者期提示规则。权限集能看到父对象上的汇总(roll-up)字段,但读不到子对象、读不到被汇总的子字段、读不到汇总filter用到的子字段,或子对象行被行级策略收窄时,os lint/os validate/os build会提示。「能读」按运行时的三道门判断:对象授权、字段条目、requiredPermissions能力门(View All 不解除能力门)。os lint/os validate失败(仅--strict会把 warning 当错误);不上运行时发布门禁。示例应用实测:showcase 9 条 warning、2 条 info,crm / todo / multi-package 为 0。回滚即还原本 PR,无迁移。packages/lint/src/validate-rollup-source-visibility.ts(三道门与判定顺序);packages/lint/src/authoring-rules.ts新增条目(advisory、只在 CLI 的理由);packages/lint/src/validate-rollup-source-visibility.test.ts。pnpm --filter @objectstack/lint exec vitest run --maxWorkers=2 src/validate-rollup-source-visibility.test.ts,预期 43 个测试全绿。What changes
A
summary(roll-up) field keeps its documented semantics: it is a stored column on the parent, recomputed as the system over the whole child collection after every child write, and on read it follows only the parent field's own field-level security (content/docs/data-modeling/fields.mdx, the roll-up section; the "Why the recompute is system-elevated" docblock inpackages/objectql/src/engine-summaries-and-expansion.ts; ADR-0035 "Server-side rollup"). So a permission set that can see the summary column still reads the roll-up when it cannot read the child data the roll-up aggregates. Nothing told the author that when they configured the set. This adds an author-time rule that does."Can read", as the runtime decides it
The rule folds the three gates the runtime applies, on both sides of the roll-up:
Object grant. The set's own entry for the object, otherwise its
'*'entry. A'*'entry covers anaccess.default: 'private'object only with View All / Modify All (resolveObjectPermission).Field entry.
readable: falsehides the field, unless the set holds View All / Modify All on the object, which votes every field readable. A set with no entry for a field reads it.Capability gate (ADR-0066 D3). The read is refused, or the field hidden, unless the set's
systemPermissionshold every listed capability. It reads:requiredPermissions, as a list or as thereadbucket of the per-operation map (objectReadAdmissionstep 4);requiredPermissions(foldFieldRequiredPermissions).View All and Modify All lift neither.
What is judged, per permission set × summary field
The pair is judged only when the set can see the summary column. That means it reads the parent object and the summary field through all three gates. A set that cannot see the column learns nothing from it and is not reported.
Then, over the child object
summaryOperations.objectnames, in order, with one finding per pair:security-rollup-source-unreadablesummaryOperations.field(readable: false, or the field's capability missing)security-rollup-source-unreadablesummaryOperations.filter, by the same testsecurity-rollup-source-unreadablesecurity-rollup-source-row-scopedNotes on the arms:
countreads no value, so itsfieldis not judged. Itsfilteris judged.Row policies for (iii):
Policies that count:
rowLevelSecurityentries:selectorall, on the child or'*', notenabled: false, with ausing;defaultRowScope.View All / Modify All on the child skips this arm only on the postures where the runtime's read filter skips business row security (
posturePermitsinsecurity-plugin-rls-filter.ts):On any other child the set's policies still narrow its rows and are noted.
Example findings (from the test fixture)
The fix line states how far the remedy reaches. In the field merge only sets that declare an entry vote, so
readable: falseon one set hides the column from every holder of that set. When the set holds View All or Modify All on the parent, the fix line says to remove that bit first, because areadable: falseentry does not hide a field from a set holding either.Registration
AUTHORING_RULESentry:tier: 'advisory',input: 'parsed', all three commands,surfaces: ['cli'].surfaceReasongives the actual reason the rule stays CLI-only: nothing yet measures, per write, what apermissionsave hands this rule. Crossing onpermissionwrites is a separate decision, with the measured crossing ofvalidateRetiredPermissionResidue(lint+protocol: registervalidateRetiredPermissionResidueon the runtime authoring door (Studio / REST/meta/ MCP), advisory level — the population ruling D on #17425 named (from #17425, ruled a) #17936) as the precedent. Crossing onobjectwrites as well would fall under theRUNTIME_OBJECT_ADVISORY_VOLUMEfence.Files
packages/lint/src/validate-rollup-source-visibility.ts(new): the rule, the two ids, the finding types.packages/lint/src/authoring-rules.ts: the registry entry.packages/lint/src/index.ts: exports the function, the two ids and the types.packages/lint/src/rule-explanations.ts: anos explainentry for each id. They cover:packages/lint/src/validate-rollup-source-visibility.test.ts(new): 43 cases.content/docs/data-modeling/fields.mdx: the roll-up section's sentence on the rule and the reach of the remedy.content/docs/deployment/validating-metadata.mdx: the rule's row in the four-doors table, plus the transcript's rule count.content/docs/deployment/cli.mdx,content/docs/getting-started/build-with-claude-code.mdx,content/docs/ui/react-pages.mdx: the CLI transcript's author-time rule count, 63 to 64 (check:docs-transcript-drift)..changeset/rollup-source-visibility-lint.md:@objectstack/lintpatch.Tests
validate-rollup-source-visibility.test.tshas 43 cases. Every positive case runs through the registry runner (runAuthoringRules), so the cases go red when the registration goes.invoice_line.amounthidden warns oninvoice.total, and not on thecountbeside it;lint,validateandbuild, never as an error;PermissionSetSchemaanswers what the raw one does.allowRead: false;'*'read grant beside a private child;{ read }map form, with the count included;update/deletedoes not gate a read.$and/$or,$not, an AST triple, an ASTandgroup;selectpolicy, anallpolicy, a'*'policy, the child'sdefaultRowScope, andpositionsnamed in the message;update, another object, check-only;tenancy.enabled: false,systemFields.tenant: falseandmanagedBy: 'better-auth', for both bits;'*'grant over a public child;os explainentry for each id;surfaceReason.Ablations on 44f8346. Each was a one-shot
node scripts/ablation-replace.mjsover the new test file plusauthoring-rule-wiring.test.ts(69 tests). Each was restored bygit checkout HEAD -- <file>, the restored blob equals HEAD, and the tree was clean afterwards.AUTHORING_RULESentry deleted823eb6d538missingCapabilitiesalways emptyf5a9fc04d6f5a9fc04d6f5a9fc04d6Acceptance notes
os lint --jsonandos validate --json(exit 0 on all four):app-showcase: 9 warnings and 2 notes, the same findings as before this round;app-crm,app-todo,app-multi-package: none.requiredPermissions, so the capability arm adds nothing there.rejected_count,approved_amountand the others onshowcase_expense_report) are already reported through the child-object arm forshowcase_member_default.showcase_member_defaultcannot readshowcase_expense_line: 6 warnings;showcase_client_liaisoncannot readshowcase_task: 2 warnings;showcase_opscannot readshowcase_invoice_line: 1 warning;showcase_contributor'stask_own_rowsnarrowsshowcase_task: 2 notes.sharingModel,readScope). Only a policy's presence is judged, never its predicate.skills/objectstack-data/references/lint-rules.md: that table is a selection, andskills/**is a governed surface.Verification
Everything below ran on 44f8346, the head. The commit before it, ee601bf, is the fix round; 44f8346 only moves a tracker id out of the
surfaceReasonstring into an adjacent comment.pnpm --filter @objectstack/lint test: Test Files 197 passed (197), Tests 8331 passed.pnpm --filter @objectstack/lint typecheck: exit 0 (check:test-typecheck: OK). The public surface is unchanged from the previous head (same exports, same types), so the consumer typecheck from the first round (77 of 77 turbo tasks) still covers it.Type Check · consumer gatesandType Check · workspaceare green on this head.node scripts/pm/dispatch-gates.mjs --commandson 44f8346: 88 commands, each run with stdin from/dev/null, all exit 0, includingcheck:doc-authoring.--ranwith the recorded exit codes: 88 derived, 88 run, 0 NOT-MEASURED, 0 UNRUN.node scripts/pm/check-governed-merges.mjs --branch origin/claude/sec-hardening-r14: NOT governed, 0 of 11 paths, 1228 changed lines (+1224 / −4).!in the title, no(narrowing)arm).Generated by Claude Code