This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(core): DataScopeManager reads scope-rule fields as own members and refuses coercing comparisons - #8048
Merged
Conversation
…comparisons
`DataScopeManager.applyFilters` had two fail-opens on a row-level permission
boundary, both measured against the previous source.
A rule naming a prototype member evaluated against the prototype chain rather
than the record, so `{ field: 'constructor', operator: 'ne' }` returned the
entire dataset. The field read now has three cases: a refused name denies, an
own member is read, and a name that is not own but still resolves on the
record's prototype chain denies rather than collapsing into "absent" — which is
what keeps the change a narrowing and what closes the class rather than three
spellings of it.
The ordered operators compared without a type guard, so `{ field: 'age',
operator: 'gte', value: 0 }` admitted `null`, `'10'`, `true`, `false`, `''` and
`[]` by coercion. Both sides must now be the same comparable kind — both
numbers, both strings, or both Dates — which refuses every coercion without
denying the ISO date strings, string ranges and Date objects that order
correctly here today. `contains` likewise requires its rule value to be a
string instead of calling `String()` on it.
Measured over a 2772-case differential matrix: 352 verdicts narrowed, zero
widened, and zero change to the genuinely-absent-field family.
Operator spelling is deliberately untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QnpvbdoRisQdRAczkLwnf5
Contributor
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7751
Brings
DataScopeManagerup to one hardening standard with its siblingevaluateConditionin@object-ui/permissions, and pins the standard as a table both evaluators are run against, so a third divergence turns a test red instead of waiting for the next contract review.Both gaps re-measured against head source, not taken on the card's word
Probed on
origin/mainat8d40c18before any edit:{ field: 'constructor', operator: 'ne', value: 'x' }[1, 2, 3]and on object rows{ field: 'age', operator: 'gte', value: 0 }null,'10'true,false,'',[]Two things the card did not name, both measured the same way:
toString,valueOf,hasOwnProperty,isPrototypeOfare not among the three refused spellings, and each one admits every row onne/ninexactly asconstructordid.containscoerces too —String(filterValue)made{ operator: 'contains', value: 1 }match the record value'10'. Same defect class, same function, so it is fixed here and called out rather than left for a third card.The card's three open questions, answered by measurement
1. Is the sibling's shape the target? No — adopt its property, not its lines. Two measurements say so.
The sibling refuses three names and reads the rest with
hasOwnProperty.hasOwnPropertycollapses inherited into absent, and absent ADMITS on a negative operator, so the sibling itself still returnstruefor{ field: 'toString', operator: 'neq' }on every record, andtruefor aneqrule against a value the record inherits. Copying it would have closed three spellings, left the class open, and widened one case. Filed as #8044 with the table.The sibling also requires
typeof === 'number'on both sides of every ordered comparison. Measured, that predicate denies every row for{ field: 'created', operator: 'gte', value: '2023-01-01' }— ISO date strings, plain string ranges andDateobjects all order correctly on this evaluator today, and none of those comparisons coerces anything. What each evaluator's callers depend on differs too:evaluateConditionis not exported from@object-ui/permissions(itsindex.tsexportsevaluatePermissiononly) and has no caller outside its own test, so its extra strictness costs it nothing;DataScopeManageris on@object-ui/core's public entry viaexport * from './data-scope/index.js', so the same predicate would be a public, silent, fail-closed break.So the property adopted is no coercion, and no value that is not the record's own data. Where that makes this evaluator stricter than the sibling (inherited members) and where it leaves it broader (same-kind non-numeric ordering), both are asserted in the pin with the reason, not left to be rediscovered.
2. Does fixing gap 2 change any currently-admitted row for a legitimate rule? Yes, and the changeset names each shape in its own paragraph. A numeric rule over a dataset where numbers arrive as strings (JSON, CSV import, unparsed form field) stops matching those records. A rule reading a field that records inherit from a shared prototype stops matching. A
containsrule written with a non-string value stops matching.3. Operator spelling. Untouched.
ne/ninhere,neq/not_inthere, and the sibling'sis_null/is_not_nullwhich this evaluator does not implement, are all exactly as they were — that is #7750's question. The conformance table addresses each evaluator through an explicit spelling map so that it takes no position on which vocabulary is right.Stop-condition: cleared by measurement, zero widenings
The dispatch's stop-condition was that any input refused today and accepted after flips the Clause-② reading. Measured rather than argued: a differential matrix of 2772 cases — 17 value kinds on both sides of 9 operators, plus prototype member names, genuinely absent fields, inherited members, and null-prototype records — run against the source before and after.
Broken down: 295 ordered comparisons that only succeeded by coercion, 45 prototype member names, 12 inherited members. Zero change to the genuinely-absent-field family, which is the regression this shape is most likely to cause — "this row has no
status" keeps every verdict it has always had. Both gaps are narrowings;Clause-②: nostands.The pin
packages/core/src/data-scope/__tests__/DataScopeManager.hardening.test.ts, 41 assertions in four blocks. The last one is the anti-divergence mechanism: one shared table of hardening cases run against both evaluators, each addressed in its own spelling. It also asserts the two known gaps in the sibling (#8044) and the one deliberate divergence, each written as an assertion rather than a comment, so closing #8044 turns this red and points its implementer at where the standard is recorded.evaluateConditionis not on the sibling package's public entry, so the pin reaches it by relative path — the same shape as the two existing cross-package test imports onmain(activityItemType-6730.test.ts,degradeSetTwin-5880.test.ts). No bare specifier, so no dependency edge and no phantom import.Verification
Every exit code captured before any pipe.
vitest run packages/core/Test Files 120 passed (120)·Tests 2559 passed (2559), exit 0vitest run packages/core/src/data-scope/ packages/permissions/Test Files 12 passed (12)·Tests 189 passed (189), exit 0pnpm --filter @object-ui/core run type-checkpnpm --filter '@object-ui/core^...' buildcheck:control-bytesOK (scanned 6457 tracked text file(s)), exit 0check:phantom-depsEvery in-scope import is declared by the package that publishes it., exit 0check:self-importNo package names itself inside its own src/., exit 0check:unreferenced-sourcesEvery shipped source file in every covered package is reachable., exit 0check:published-tsconfig-excludeall 34 enforced package(s) carry the directory form., exit 0check-type-check-coverage.mjs42/42 packages compile their tests, exit 0check-changeset-presence.mjs1 source file(s) of 1 released package(s) changed, and this change declares 1 changeset(s), exit 0The pin is proved to be readable by the type program rather than assumed:
tsc -p packages/core/tsconfig.test.json --listFilesreads 669 files and both the pin and the sibling evaluator are among them.Lint. Both the narrowed run and the full union, on the final commit
187e014.eslinton the two changed files: exit 0, 0 errors; 8 warnings onDataScopeManager.ts, all@typescript-eslint/no-explicit-any, against 7 on the same file at8d40c18— the one added warning isreadField(row: any, …), matching the annotation the function it replaces already carried. The pin file: 0 errors, 0 warnings.eslint . --no-inline-config --format json: population 4359 files, read from eslint's own config rather than assumed; 93 errors and 12168 warnings repo-wide, none of them in this diff's two files, which report 0 errors each in that same run.eslint.config.jssets noparserOptions.projectand noprojectService, so linting is not type-aware and this diff cannot move the verdict of any file it does not touch.DataScopeManager.ts(it reported ano-unused-varswarning forPROTOTYPE_FIELD_NAMES, which only exists while the field guard is ablated). That reading was discarded and both runs above were re-taken against the clean committed tree.Not run locally, declared:
check:readme-exports,check:dist-completeness --allandcheck:node-esm-loadall require a fullpnpm build(they reportrun pnpm build firstagainst an unbuilt tree). This diff adds and removes no exported symbol —readField,isOrderedPair,isDateandPROTOTYPE_FIELD_NAMESare module-private — and touches no README, so its input to those gates is unchanged.Ablation — the pin is proved able to fail
Two legs, each mutating the committed implementation on disk, each proving the mutation landed by grep count and by
git hash-objectdiffering from theHEADblob, each restored withgit checkout HEAD -- pathunder anEXIT INT TERMtrap and verified byte-identical afterwards.row[field]Tests 16 failed, 25 passed, exit 1isOrderedPairremoved from the four ordered armsTests 13 failed, 28 passed, exit 1Restored blob
f9763a2matches theHEADblob in both legs;git statusclean. The pin imports the module by relative path, so it resolves fromsrcand no staledistcan flatter either leg.Declared deviations
DataScopeManager.hardening.test.ts, rather than an addition to the existingDataScopeManager.test.ts, so the standard has a named home. That existing file is unchanged and still passes.containsfolded in as a bounded in-place fix: same defect class as gap 2 (an unwritten coercion in a comparison arm), same function, same file, same gate family, no new verification surface.evaluateCondition's prototype-name guard closes three spellings, not the class —{ field: 'toString', operator: 'neq' }still admits every record #8044 could not use REST —GET /search/issuesis not a repo-scoped path and returns 403 through the proxy (a repo-scoped read probe returned 200 with a live 15000/hour credential in the same container). One targeted MCPsearch_issuescall was used instead; it returned 6 results, none of them this gap.Generated by Claude Code
Generated by Claude Code