diff --git a/.changeset/36055-view-all-stops-voting-on-fields.md b/.changeset/36055-view-all-stops-voting-on-fields.md new file mode 100644 index 00000000000..10b971faaf2 --- /dev/null +++ b/.changeset/36055-view-all-stops-voting-on-fields.md @@ -0,0 +1,44 @@ +--- +'@objectstack/core': major +'@objectstack/plugin-security': major +'@objectstack/lint': major +'@objectstack/spec': major +'@objectstack/metadata-core': minor +'@objectstack/scenarios': patch +'@objectstack/cli': patch +'@objectstack/service-automation': patch +--- + +feat(security)!: View All and Modify All stop opening fields; `viewAllFields` is the one "every field" bit + +**BREAKING** (19.0.0): View All (`viewAllRecords`) and Modify All (`modifyAllRecords`) widen records only. They no longer cast a field vote, so a field that a permission set hides (`readable: false`) or locks (`editable: false`) stays hidden or locked for their holders. Reading every field of an object is `viewAllFields: true` on that object's entry; it votes read, never edit. + +Clause-②: yes (narrowing) +Metadata-protocol: semantic + + + +FROM → TO: + +- `objects.: { viewAllRecords: true }` read every field of the object another set hides → it reads none of them. TO keep that read: `{ viewAllRecords: true, viewAllFields: true }`. +- `objects.: { modifyAllRecords: true }` read and edited every field, the set's own rows included → it reads and edits only what the field rows allow. TO keep the read: `{ modifyAllRecords: true, viewAllFields: true }`, except a field the set's own `readable: false` row hides: that row now hides the field from the set's holders even with the bit, so delete it where they should still read the field. The edit is not restored by any bit, for a field another set locks or a field the set's own field row names without `editable: true` (an omitted `editable` is `false`): grant it with an explicit `editable: true` row in the set that should edit it. +- The same holds on a `'*'` entry. + +**Check your permission sets in one step.** A permission set is affected when one of its `objects` entries, the `'*'` entry included, has `viewAllRecords: true` or `modifyAllRecords: true` and does not have `viewAllFields: true`. For each such entry, add `viewAllFields: true` to it if the set should still read every field of that object. Beside View All that is all the read needs: with the bit, the set reads what View All read before. Beside Modify All it is not: the set's own `readable: false` rows now bind (before, Modify All overrode them), so a field such a row hides stays hidden from the set's holders until you delete the row. For the edit, Modify All no longer grants one: where its holders must still edit a field another set locks, or a field the set's own field row names without `editable: true`, add an explicit `editable: true` row in the set that should edit it. + +- Sets in your source: `os migrate meta --from 18 --write` adds `viewAllFields: true` beside every such bit (ADR-0087 conversion `permission-view-all-fields-beside-record-bypass`). +- Sets saved in a running deployment (Studio-saved, stored in `sys_metadata`): they are **not** rewritten on upgrade, and from 19 they are read with the new meaning. Studio's permission matrix has no control for `viewAllFields` today (it keeps the key when it saves a set that already carries it), so add it to the set's entry through the metadata API. No command lists the affected stored sets yet; a review list is follow-up #37375. + +The protocol-19 upgrade guide carries the same check as the semantic entry `permission-view-all-modify-all-cast-no-field-vote`. + +The error direction is safe: an unconverted set sees **fewer** fields after the upgrade, never more. No field that was hidden opens. A set whose object has no field row in any set changes nothing at all, because a field no set names already follows the object grant. + +Also in this change: + +- The built-in admin sets (`admin_full_access`, `organization_admin`) already carry `viewAllFields: true` on their `'*'` entry, so they still read every field. They no longer edit a field that another set they hold locks. +- Explain no longer reports a row-conditioned field lock as "superseded by the Modify All Data field vote": the lock binds per row for every caller. +- `@objectstack/lint`: the warning `security-superuser-field-mask-inert` is retired, since a set's own field rows now bind beside its own View All or Modify All. `security-cross-set-field-reopen` now reports only a field one set hides that another set's `viewAllFields` re-opens. `security-controlled-by-parent-master-reference-hidden` and the roll-up source-visibility rules now judge a mask beside Modify All like any other mask. +- `@objectstack/spec` and `@objectstack/metadata-core`: the conversion is a default flip, retired from the load path from day one. Only `os migrate meta --from 18` replays it: the authoring funnel skips it (it is retired from the load path), and the artifact-ingestion door (`DEFAULT_FLIPS_NOT_REPLAYED_HERE`) and every stored-row read (`applyConversionsToStoredItem`, `os migrate meta --stored` included) refuse it by id, so an artifact or stored set is read with the 19 meaning and never handed a field read its author did not write. +- `@objectstack/core`: `superuserFieldVote` is replaced by `viewAllFieldsReadVote(sets, object, field)`, which answers whether a set's `viewAllFields` reads the field. `holdsSuperuserBypass` is unchanged and answers the record bypass only. +- `@objectstack/scenarios`: the persona-grant scoring no longer treats Modify All as overriding a field lock. +- `@objectstack/cli` and `@objectstack/service-automation`: test comments only, restated for the 19 meaning. diff --git a/content/docs/permissions/authorization.mdx b/content/docs/permissions/authorization.mdx index 63f6de390e2..f200b63214e 100644 --- a/content/docs/permissions/authorization.mdx +++ b/content/docs/permissions/authorization.mdx @@ -153,27 +153,23 @@ implementation detail: **FLS posture (ADR-0066 ⑧):** runtime field security is block-list-shaped — an **undeclared** field is visible by default, and field grants union (one -set's `readable: true` out-votes another's `false`). A set that holds View All -(`viewAllRecords`) on an object also votes `readable: true` on every field of -that object, and a set that holds Modify All (`modifyAllRecords`) votes -`readable: true` and `editable: true`; View All never grants an edit. So +set's `readable: true` out-votes another's `false`). View All +(`viewAllRecords`) and Modify All (`modifyAllRecords`) widen records only and +cast no field vote. A set that carries `viewAllFields` on an object votes +`readable: true` on every field of that object, and never an edit vote. So another set's `readable: false` never hides a field from a caller who also -holds a View All or Modify All set on its object; a field's -`requiredPermissions` capability gate still applies to every caller. One -exception: a View All set casts no read vote on a field its **own** +holds a `viewAllFields` set on its object; a field's `requiredPermissions` +capability gate still applies to every caller. One exception: a +`viewAllFields` set casts no read vote on a field its **own** `readable: false` entry hides, so that entry binds the set's holders, unless another set they hold casts a read vote on the field (its own `readable: true` -entry, or View All or Modify All on the object); a co-held set that says -nothing about the field does not restore it. A Modify All set still votes on -every field, its own entries included. Otherwise union without deny is -unchanged. A set that carries `viewAllFields` on the object casts the same -read vote as View All, under the same own-entry exception, and never an edit -vote. From v19 View All and Modify All stop voting on fields: where a set -should read every field, grant +entry, or `viewAllFields` on the object); a co-held set that says nothing about +the field does not restore it. Otherwise union without deny is unchanged. Up +to v18 View All and Modify All also voted on fields; where a set should read +every field, grant [`viewAllFields`](/docs/permissions/field-level-security#viewallfields-a-set-that-reads-every-field). Until the muting layer lands, protect sensitive fields by granting them only -in the sets that need them, grant the object without Modify All to a set that -must withhold a field from its own holders, and treat "sensitive field on a +in the sets that need them, and treat "sensitive field on a public object" as a review smell. diff --git a/content/docs/permissions/field-level-security.mdx b/content/docs/permissions/field-level-security.mdx index be86458f622..2d8eea51216 100644 --- a/content/docs/permissions/field-level-security.mdx +++ b/content/docs/permissions/field-level-security.mdx @@ -18,12 +18,14 @@ of them: | **Fields** | `fields` rows, `viewAllFields`, and a field's own `requiredPermissions` | Which fields of those records the caller reads and edits. | -**From v19, View All and Modify All stop opening fields.** Until then a set -that holds `viewAllRecords` on an object also reads every field of it, and a -set that holds `modifyAllRecords` reads and edits every field (the exact votes -are under [Server-side enforcement](#server-side-enforcement-of-declared-rules)). -Do not build on that: where a set should read every field, grant -[`viewAllFields`](#viewallfields-a-set-that-reads-every-field). +**View All and Modify All do not open fields (v19).** A set that holds +`viewAllRecords` or `modifyAllRecords` on an object reaches every record of +it and casts no field vote: a field another set hides stays hidden, and the +set's own `fields` rows still hide or lock their fields. Where a set should +read every field, grant +[`viewAllFields`](#viewallfields-a-set-that-reads-every-field). Up to v18 the +two bits also read (and Modify All also edited) every field; +`os migrate meta --from 18` adds `viewAllFields: true` beside them in source. ## Choosing by sensitivity @@ -242,8 +244,8 @@ roll-up is not a computed field in this sense: it does not follow the fields it aggregates, so mask it on its own where a set must not see it. The record the engine echoes for a public-form submission carries no computed field that reads through a -reference. View All, Modify All and `viewAllFields` lift a permission set's -`readable: false`, not a capability gate or a masking rule, so their holders +reference. `viewAllFields` lifts a permission set's +`readable: false`, not a capability gate or a masking rule, so its holders are withheld a computed field over such a field too. To let a permission set's holders read a computed field, grant that set read on every field the expression reads, unmasked: the capability a field's @@ -284,16 +286,9 @@ only constrain fields they explicitly enumerate, and field grants union most-permissively across a user's sets (one set's `readable: true` out-votes another set's `false`). Until a subtractive muting layer lands (ADR-0066 ⑧), a `{ readable: false }` rule masks the field only as long -as **no other set the user holds** declares it `readable: true`, carries -`viewAllFields` on that object, or holds -View All (`viewAllRecords`, reads every field of the object) or Modify All -(`modifyAllRecords`, reads and edits every field) on that object, and -the set that declares it does not itself hold Modify All on that object: -the set's own View All or `viewAllFields` leaves its `readable: false` -binding, while its -own Modify All still reads and edits every field of the object, its own -rows included (`security-superuser-field-mask-inert` warns on such a row), -until v19, when View All and Modify All stop voting on fields — so +as **no other set the user holds** declares it `readable: true` or carries +`viewAllFields` on that object (View All and Modify All cast no field vote) +— so gate a high-sensitivity field with `requiredPermissions` ([Choosing by sensitivity](#choosing-by-sensitivity)), grant a position-dependent field only in the sets that need diff --git a/content/docs/permissions/permissions-matrix.mdx b/content/docs/permissions/permissions-matrix.mdx index eb59d5ca2a8..53d045935d9 100644 --- a/content/docs/permissions/permissions-matrix.mdx +++ b/content/docs/permissions/permissions-matrix.mdx @@ -159,7 +159,7 @@ Field-level security controls visibility and editability of individual fields pe | `opportunity.amount` | Visible, Editable | Visible, Editable | Visible, Editable | Visible | Visible | | `opportunity.margin` | Visible, Editable | Visible, Editable | Hidden | Hidden | Hidden | -**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 that its own field rules do not hide, while Modify All reads and 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, withhold it in a set that grants the object without Modify All, and give them no other set that reads the field. From v19 these two bits stop reaching fields: a set that should read every field carries `viewAllFields`, and a high-sensitivity field is gated by `requiredPermissions` on the field itself ([Field-level security](/docs/permissions/field-level-security#choosing-by-sensitivity)). +**View All / Modify All widen records, not fields.** Each column is one set held alone: `sales_manager_access` names none of these fields, so each follows its object grant. View All (`viewAllRecords`) and Modify All (`modifyAllRecords`) reach every record of the object and cast no field vote (ADR-0066 D2 ⑧, v19), so a manager who also holds `sales_rep_access` does not read `contact.ssn` or `opportunity.margin` through them: the rep set's `readable: false` row is the only vote on those fields. A set that must read every field whatever other sets say carries `viewAllFields: true` on the object; it votes read, never edit. A high-sensitivity field is gated by `requiredPermissions` on the field itself ([Field-level security](/docs/permissions/field-level-security#choosing-by-sensitivity)). ### FLS States diff --git a/content/docs/references/api/auth.mdx b/content/docs/references/api/auth.mdx index 9cc2c5addee..29026aab2ab 100644 --- a/content/docs/references/api/auth.mdx +++ b/content/docs/references/api/auth.mdx @@ -113,8 +113,8 @@ const result = AuthProvider.parse(data); | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -178,8 +178,8 @@ This schema accepts one of the following structures: | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 2b8e0086e22..59f1548505e 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1323,8 +1323,8 @@ This schema accepts one of the following structures: | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -1797,8 +1797,8 @@ One changed key path of the pending draft, and the last write that changed it. | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -1809,7 +1809,7 @@ One changed key path of the pending draft, and the last write that changed it. | :--- | :--- | :--- | :--- | | **readable** | `boolean` | optional (default: `true`) | Field read access | | **editable** | `boolean` | optional (default: `false`) | Field edit access | -| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | +| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing. A set carrying `viewAllFields` on the object (its own entry for the object, otherwise its `'*'` wildcard) votes `readable: true` on every field, on every row, and never an edit, so a row-conditioned lock binds its holders; `viewAllRecords` and `modifyAllRecords` cast no field vote. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | | **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. | diff --git a/content/docs/references/security/permission.mdx b/content/docs/references/security/permission.mdx index 9fafc51a6ac..8d952f70267 100644 --- a/content/docs/references/security/permission.mdx +++ b/content/docs/references/security/permission.mdx @@ -54,8 +54,8 @@ const result = AdminScopeSchema.parse(data); | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -72,7 +72,7 @@ const result = AdminScopeSchema.parse(data); | :--- | :--- | :--- | :--- | | **readable** | `boolean` | optional (default: `true`) | Field read access | | **editable** | `boolean` | optional (default: `false`) | Field edit access | -| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | +| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing. A set carrying `viewAllFields` on the object (its own entry for the object, otherwise its `'*'` wildcard) votes `readable: true` on every field, on every row, and never an edit, so a row-conditioned lock binds its holders; `viewAllRecords` and `modifyAllRecords` cast no field vote. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | | **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. | @@ -107,8 +107,8 @@ const result = AdminScopeSchema.parse(data); | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -157,8 +157,8 @@ const result = AdminScopeSchema.parse(data); | **allowPurge** | `never` | optional | [REMOVED] `objects..allowPurge` was removed in @objectstack/spec 17 (ADR-0049): the `purge` ObjectQL operation it claimed to gate did not exist then, so granting the bit delivered nothing (a compliance/GDPR erase the author believed was permission-locked was not). Delete the key. The operation now exists with the recycle bin (ADR-0148), and its grant is spelled `manageRecycleBin` (purge an entry, empty an object's entries, and the permanent delete). Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **allowRestoreOwnDeleted** | `boolean` | optional | Recycle bin: restore the entries of this object the caller deleted. Bounded by read; implied by manageRecycleBin and modifyAllRecords, not by allowDelete. | | **manageRecycleBin** | `boolean` | optional | Recycle bin administration on this object: restore any entry, not only your own, and purge (the permanent delete, purging one entry, emptying the object's entries). Bounded by read; implied by modifyAllRecords. | -| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing) | -| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. | +| **viewAllRecords** | `boolean` | optional (default: `false`) | View All Data (Bypass Sharing): reads every record of the object. Casts no field vote: a field another permission set hides stays hidden; reading every field is viewAllFields. | +| **modifyAllRecords** | `boolean` | optional (default: `false`) | Modify All Data (Bypass Sharing) — bypasses sharing rules and ownership on the objects record sharing enforces on; on an object with NO owner field sharing abstains, so the platform created_by write floor still applies. Includes delete: an omitted allowDelete parses to true, and an explicit allowDelete: false beside it is refused. Casts no field vote: field rows (this set's and others') still hide or lock their fields; reading every field is viewAllFields. | | **viewAllFields** | `boolean` | optional | View All Fields: a read vote on every field of this object, including fields added later. Casts no edit vote: edits come from the default or from explicit editable: true field rows. A field row of the same set beats it, so an own readable: false row keeps the field hidden for this set. Grants no object access and widens no record. Allowed on the '*' entry. | | **readScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Read depth: own\|unit\|unit_and_below\|org | | **writeScope** | `Enum<'own' \| 'own_and_reports' \| 'unit' \| 'unit_and_below' \| 'org'>` | optional | [ADR-0057 D1] Write depth: own\|unit\|unit_and_below\|org | @@ -169,7 +169,7 @@ const result = AdminScopeSchema.parse(data); | :--- | :--- | :--- | :--- | | **readable** | `boolean` | optional (default: `true`) | Field read access | | **editable** | `boolean` | optional (default: `false`) | Field edit access | -| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing, unless it holds the super-user bypass on the object (its own entry for the object, otherwise its `'*'` wildcard). Such a set votes on every field of the object, on every row, whatever `when` says: `viewAllRecords` votes `readable: true`, and `modifyAllRecords` votes `readable: true` and `editable: true`, so a row-conditioned lock never binds a Modify All holder. View All never grants an edit. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | +| **when** | `string` | optional | Row condition narrowing where this entry votes, authored in canonical CEL like `rowLevelSecurity[].using` (a field of this object compared with a literal or a `current_user.*` value using `==`, `!=`, `<`, `<=`, `>`, `>=` or `in`, combined with `&&` / `\|\|`; e.g. status in ["approved", "signing", "active"]). Absent, the entry votes on every row. Present, the entry votes as declared on the rows the condition matches and is ABSENT on every other row, so the most-permissive merge across the caller's sets is unchanged: a set that locks a field only from a stage onward does not lock the rows before it, and a co-held set that says nothing about the field still lifts nothing. A set carrying `viewAllFields` on the object (its own entry for the object, otherwise its `'*'` wildcard) votes `readable: true` on every field, on every row, and never an edit, so a row-conditioned lock binds its holders; `viewAllRecords` and `modifyAllRecords` cast no field vote. Otherwise union without deny is unchanged. The write gate judges the condition on the stored row BEFORE an update (so a lock on `status in [...]` holds on an approved row even when the write changes `status`) and on the incoming row of an insert, as the caller sent it. It reaches the EDIT vote only — reads are judged row-blind — so `readable: false` beside a `when` is refused at parse time: keep `readable: true` (the default) on a row-conditioned entry. Where no row can be judged (a predicate update with no row address, a stored row the caller cannot read, a condition that does not resolve for the request) the entry is judged as its lock: it contributes no edit grant on that write. Validated like an RLS predicate at authoring and publish time: the fields it names must exist on the entry's object and it may not reach across a relation; a condition that cannot be lowered is refused there, never dropped at runtime. Readers that hold no row (`/auth/me/permissions`, the object-wide field projections, the write preview on an update) report a row-conditioned entry as its lock, so a client never advertises an edit the gate refuses. The record-scoped field projection (`GET /data/{object}/{id}/field-access`, the answer a record's edit form reads) holds the row: it judges the condition on the stored row exactly as the write gate does on an update of that row, so a lock that applies only from a stage onward disables the field only on the rows it names. | | **rollupSourceUnreadableReason** | `string` | optional | Authoring-time acknowledgement, read only by `os lint` (the runtime does not read it): why holders of this set are meant to read this roll-up `summary` column although the set cannot read the child object, the aggregated child field or a child field the roll-up's `filter` tests (e.g. 'Service staff read account totals but not invoice rows'). Declared on the set's entry for the summary column, it turns that set's `security-rollup-source-unreadable` warning for the column into an `info` note quoting the reason, so `os lint --strict` passes; every other finding is unchanged. The runtime does not read the key, but the entry that carries it is an ordinary declaring entry: it votes `readable: true` in the field merge (only declaring sets vote, and the most permissive vote wins), so on a set that had no entry for the column, adding one to carry the reason restores the column for holders whose other sets mask it. A blank reason is refused, and so is a reason beside `readable: false`, an entry that declares no read to acknowledge. | ### Nested Shape: `PermissionSet.rowLevelSecurity[number]` diff --git a/examples/app-showcase/access-matrix.json b/examples/app-showcase/access-matrix.json index 6d948776253..89dc7a4ae0b 100644 --- a/examples/app-showcase/access-matrix.json +++ b/examples/app-showcase/access-matrix.json @@ -10,6 +10,7 @@ "delete": false, "viewAllRecords": true, "modifyAllRecords": false, + "viewAllFields": true, "sharingModel": "private" }, { @@ -21,6 +22,7 @@ "delete": false, "viewAllRecords": true, "modifyAllRecords": false, + "viewAllFields": true, "sharingModel": "public_read_write" }, { @@ -32,6 +34,7 @@ "delete": false, "viewAllRecords": true, "modifyAllRecords": false, + "viewAllFields": true, "sharingModel": "controlled_by_parent" }, { @@ -43,6 +46,7 @@ "delete": false, "viewAllRecords": true, "modifyAllRecords": false, + "viewAllFields": true, "sharingModel": "private" }, { @@ -429,6 +433,7 @@ "delete": true, "viewAllRecords": false, "modifyAllRecords": true, + "viewAllFields": true, "sharingModel": "public_read" }, { diff --git a/examples/app-showcase/src/docs/showcase_tour_security.md b/examples/app-showcase/src/docs/showcase_tour_security.md index b37ba702407..91a4854e141 100644 --- a/examples/app-showcase/src/docs/showcase_tour_security.md +++ b/examples/app-showcase/src/docs/showcase_tour_security.md @@ -38,7 +38,8 @@ The other sets each demonstrate one axis: - `showcase_executive` — org-wide read via `readScope: 'org'` (depth, not a bypass). - `showcase_auditor` — **View-All** (`viewAllRecords`): reads every private - record, holds no write bit. High-privilege: suggested for the `everyone` + record, holds no write bit. **View All Fields** (`viewAllFields`) beside it + reads every field of those objects: View All widens records only. High-privilege: suggested for the `everyone` anchor (`isDefault: true`) it would fail the publish linter, and no door binds a set to `everyone` or `guest` by hand. - `showcase_ops` — **system permissions** (`setup.access` opens the Setup diff --git a/examples/app-showcase/src/security/permission-sets.ts b/examples/app-showcase/src/security/permission-sets.ts index 7a8ba07adec..a3566ae5864 100644 --- a/examples/app-showcase/src/security/permission-sets.ts +++ b/examples/app-showcase/src/security/permission-sets.ts @@ -183,7 +183,10 @@ export const ExecutivePermissionSet = definePermissionSet({ /** * Compliance read-only: `viewAllRecords` bypasses OWD/sharing/depth on the * named objects — the auditor sees every private note, inquiry, and invoice, - * but holds no write bit anywhere. High-privilege by definition: suggested + * but holds no write bit anywhere. `viewAllFields` is the field half: View + * All widens records only, so without it a field another set hides stays + * hidden from the auditor too (the protocol 19 field-axis split; written by + * `os migrate meta --from 18`, which keeps the reads this set had). High-privilege by definition: suggested * for the `everyone` anchor (`isDefault: true`) it would fail the publish * lint's anchor rule, and no door binds a set to `everyone` or `guest` by hand. */ @@ -191,10 +194,10 @@ export const AuditorPermissionSet = definePermissionSet({ name: 'showcase_auditor', label: 'Showcase Auditor', objects: { - showcase_private_note: { allowRead: true, viewAllRecords: true }, - showcase_inquiry: { allowRead: true, viewAllRecords: true }, - showcase_invoice: { allowRead: true, viewAllRecords: true }, - showcase_invoice_line: { allowRead: true, viewAllRecords: true }, + showcase_private_note: { allowRead: true, viewAllRecords: true, viewAllFields: true }, + showcase_inquiry: { allowRead: true, viewAllRecords: true, viewAllFields: true }, + showcase_invoice: { allowRead: true, viewAllRecords: true, viewAllFields: true }, + showcase_invoice_line: { allowRead: true, viewAllRecords: true, viewAllFields: true }, }, }); @@ -221,7 +224,7 @@ export const OpsPermissionSet = definePermissionSet({ name: 'showcase_ops', label: 'Showcase Operations', objects: { - showcase_announcement: { allowRead: true, allowCreate: true, allowEdit: true, modifyAllRecords: true }, + showcase_announcement: { allowRead: true, allowCreate: true, allowEdit: true, modifyAllRecords: true, viewAllFields: true }, showcase_inquiry: { allowRead: true, allowEdit: true, readScope: 'org', writeScope: 'org' }, showcase_invoice: { allowRead: true }, // Shared reference data — the org geometry and the tagging tree every diff --git a/packages/cli/test/superuser-bypass-mirror-parity.test.ts b/packages/cli/test/superuser-bypass-mirror-parity.test.ts index 539fc1ef955..0051ebefba5 100644 --- a/packages/cli/test/superuser-bypass-mirror-parity.test.ts +++ b/packages/cli/test/superuser-bypass-mirror-parity.test.ts @@ -6,13 +6,14 @@ * * `holdsSuperuserBypass` (`@objectstack/core`, `security/effective-object-permissions.ts`) * is the ONE reading of "does this set hold View All / Modify All on this - * object": the row bypass and both field merges ask it (ADR-0066 D2, ruling - * of record 6573563853 letter A). `@objectstack/lint` depends on - * `@objectstack/spec` alone, so its `security-superuser-field-mask-inert` - * rule reads the bypass through a verbatim COPY exported under the same name. - * A copy is a second reading the day the two drift, and a drifted lint either - * warns about a mask the runtime enforces or stays silent about one it - * ignores. This package depends on both, so the parity is pinned here: a + * object": the row bypass asks it (ADR-0066 D2, ruling of record 6573563853 + * letter A; since v19, #36055, the field merges no longer do: View All and + * Modify All cast no field vote). `@objectstack/lint` depends on + * `@objectstack/spec` alone, so its roll-up source-visibility rule reads the + * record bypass through a verbatim COPY exported under the same name. A copy + * is a second reading the day the two drift, and a drifted lint either warns + * about a child row the runtime lets the caller reach or stays silent about + * one it hides. This package depends on both, so the parity is pinned here: a * change to either function reds this file until the other follows. * * The matrix is the cartesian product of what the lookup reads: the set's own diff --git a/packages/core/src/security/effective-object-permissions.test.ts b/packages/core/src/security/effective-object-permissions.test.ts index 4d79b28a5cf..3e830e59be6 100644 --- a/packages/core/src/security/effective-object-permissions.test.ts +++ b/packages/core/src/security/effective-object-permissions.test.ts @@ -885,24 +885,30 @@ describe('buildEffectiveFieldPermissions (#25866)', () => { expect(widened).toEqual({ 'deal.amount': { readable: true, editable: true } }); }); - // [ADR-0066 ⑧, ruling of record 6573563853] A set holding the super-user - // bypass on an object votes on every field of it: `viewAllRecords` reads, - // `modifyAllRecords` reads and edits — the same sets `superuserBypassSets` - // (`@objectstack/plugin-security`) names, through `holdsSuperuserBypass`. - it('a super-user set votes on every declared field of its object; a plain set does not', () => { + // [ADR-0066 ⑧, v19, #36055] `viewAllFields` is the only "every field" + // vote: it reads every declared field of its object, never edits. View All + // and Modify All widen records only and cast no field vote. + it('a viewAllFields set votes read on every declared field of its object; a super-user or plain set does not', () => { const mask = { fields: { 'deal.amount': { readable: false, editable: false }, 'lead.score': { readable: false, editable: false } } }; - expect(buildEffectiveFieldPermissions([{ objects: { '*': { modifyAllRecords: true } } }, mask])).toEqual({ - 'deal.amount': { readable: true, editable: true }, - 'lead.score': { readable: true, editable: true }, + expect(buildEffectiveFieldPermissions([{ objects: { '*': { viewAllFields: true } } }, mask])).toEqual({ + 'deal.amount': { readable: true, editable: false }, + 'lead.score': { readable: true, editable: false }, }); - expect(buildEffectiveFieldPermissions([{ objects: { deal: { viewAllRecords: true } } }, mask])).toEqual({ + expect(buildEffectiveFieldPermissions([{ objects: { deal: { viewAllFields: true } } }, mask])).toEqual({ 'deal.amount': { readable: true, editable: false }, 'lead.score': { readable: false, editable: false }, }); // An explicit entry shadows the same set's wildcard, as at row level. - expect(buildEffectiveFieldPermissions([{ objects: { '*': { viewAllRecords: true }, deal: { allowRead: true } } }, mask])) + expect(buildEffectiveFieldPermissions([{ objects: { '*': { viewAllFields: true }, deal: { allowRead: true } } }, mask])) .toEqual({ 'deal.amount': { readable: false, editable: false }, 'lead.score': { readable: true, editable: false } }); - // Control: no bypass bit, no vote — union without deny is unchanged. + // View All and Modify All cast no field vote, by name or by the wildcard. + for (const objects of [{ '*': { modifyAllRecords: true } }, { deal: { viewAllRecords: true, modifyAllRecords: true } }]) { + expect(buildEffectiveFieldPermissions([{ objects }, mask])).toEqual({ + 'deal.amount': { readable: false, editable: false }, + 'lead.score': { readable: false, editable: false }, + }); + } + // Control: no bit, no vote — union without deny is unchanged. expect(buildEffectiveFieldPermissions([{ objects: { deal: { allowRead: true, allowEdit: true } } }, mask])).toEqual({ 'deal.amount': { readable: false, editable: false }, 'lead.score': { readable: false, editable: false }, diff --git a/packages/core/src/security/effective-object-permissions.ts b/packages/core/src/security/effective-object-permissions.ts index a105b3c534b..b4c72981bb8 100644 --- a/packages/core/src/security/effective-object-permissions.ts +++ b/packages/core/src/security/effective-object-permissions.ts @@ -998,8 +998,10 @@ export function fieldPermissionVote( * bypass on `objectName`? The ONE reading of that question: * `PermissionEvaluator.superuserBypassSets` (`@objectstack/plugin-security`, * the row-level bypass every RLS, sharing and explain consumer folds through) - * asks it per set, and so does the field merge's super-user vote below, so the - * two can never disagree about who is a super-user on an object. + * asks it per set, so every row-level reader agrees about who is a super-user + * on an object. Since the field-axis split (ruling of record 6912661484, step + * 3) the answer reaches no field: the field merge's one "all fields" vote is + * `viewAllFields` ({@link viewAllFieldsReadVote}). * * The set's own entry for the object answers when it has one; otherwise its * `'*'` wildcard does (`resolveObjectPermission` in the evaluator: lookup, not @@ -1025,59 +1027,45 @@ export function holdsSuperuserBypass( } /** - * [ADR-0066 D2 ⑧ as amended — ruling of record 6573563853, letter A] The - * super-user vote in the field merge: when any of `sets` holds the bypass on - * `objectName` ({@link holdsSuperuserBypass}), it votes on EVERY field of that - * object — `viewAllRecords` votes `readable: true`, `modifyAllRecords` votes - * `readable: true` and `editable: true`. `null` when no set holds it. + * [ADR-0066 D2 ⑧; the field-axis split, ruling of record 6912661484, letter + * A, step 3] The one "all fields" vote in the field merge: does any of + * `sets` cast a READ vote on `.` through `viewAllFields`? * - * A set that grants the object through its super-user bits but names no field - * used to cast no vote at all, so another set's `readable: false` hid the - * field from a platform admin who also held that set. Union without deny is - * otherwise unchanged: a caller who holds no super-user set on the object is - * narrowed by a declared mask as before. Applied to the fields the merge - * already holds an entry for; an absent field is unrestricted anyway. + * A set that carries `viewAllFields` on the object ({@link holdsViewAllFields}) + * votes `readable: true` on every field of it, including fields added later, + * except a field its OWN row declares `readable: false`: inside one set, + * specific beats general ({@link declaresOwnReadMask}). It never votes an edit + * (ruled read-only): edits come from the default (a field no set names follows + * the object grant) or from an explicit `editable: true` row. * - * [ADR-0066 D2 ⑧ note of 2026-11-15] With `fieldName`, the vote is the one cast - * on that field: a set that holds View All on the object WITHOUT Modify All - * casts no read vote on a field its OWN row declares `readable: false` - * ({@link declaresOwnReadMask}), so a set can grant View All on an object and - * still hide a field of it from its holders. Every other vote stands: - * another set's View All or Modify All still reads the field (the admin case - * above), and a set holding Modify All votes on every field as before, its - * own rows included. View All never granted an edit, so an edit lock beside - * it binds as it always did. Without `fieldName` the answer is the object-wide - * one, for a reader that asks only whether an edit vote exists. - * - * [Field-axis split, ruling of record 6912661484, letter A] A set that - * carries `viewAllFields` on the object ({@link holdsViewAllFields}) casts the - * same READ vote as View All, under the same own-row rule: inside one set, - * specific beats general, so its own `readable: false` row on the field means - * it casts no read vote there. It never casts an edit vote (ruled read-only). - * On a set that also holds View All or Modify All it duplicates the vote - * those bits already cast, so the built-in admin sets that carry it answer - * exactly as before. + * `viewAllRecords` and `modifyAllRecords` cast NO field vote. They widen which + * records the caller reaches ({@link holdsSuperuserBypass}) and nothing else, + * so one set's View All or Modify All no longer re-opens a field another set + * hides. Until protocol 19 they voted on every field of the object (ruling of + * record 6573563853, the ADR-0066 D2 ⑧ notes of 2026-11-02 and 2026-11-15); + * the ADR-0087 conversion `permission-view-all-fields-beside-record-bypass` + * writes `viewAllFields: true` beside them in a source that predates the + * switch, which keeps every read that vote cast. * * Both merges apply it per field after their declared-entry votes — * `PermissionEvaluator.getFieldPermissions` per object and - * {@link buildEffectiveFieldPermissions} for every object. + * {@link buildEffectiveFieldPermissions} for every object — to the fields the + * merge already holds an entry for; a field no set names is unrestricted + * anyway. */ -export function superuserFieldVote( +export function viewAllFieldsReadVote( sets: ReadonlyArray< { objects?: Record | null; fields?: Record | null } | null | undefined >, objectName: string, - fieldName?: string, -): { readable: true; editable: boolean } | null { - let read = false; + fieldName: string, +): boolean { for (const ps of sets) { - if (holdsSuperuserBypass(ps, objectName, 'modify')) return { readable: true, editable: true }; - if (read) continue; - if (!holdsSuperuserBypass(ps, objectName, 'view') && !holdsViewAllFields(ps, objectName)) continue; - if (fieldName !== undefined && declaresOwnReadMask(ps, objectName, fieldName)) continue; - read = true; + if (!holdsViewAllFields(ps, objectName)) continue; + if (declaresOwnReadMask(ps, objectName, fieldName)) continue; + return true; } - return read ? { readable: true, editable: false } : null; + return false; } /** @@ -1085,15 +1073,14 @@ export function superuserFieldVote( * letter A] Does `set` carry `viewAllFields` on `objectName`? The set's own * entry for the object answers when it has one, otherwise its `'*'` wildcard * does: the same lookup {@link holdsSuperuserBypass} takes, so a set's - * explicit entry for an object is its whole answer for that object on both - * bits, and the bit on the built-in admin wildcards duplicates exactly the - * vote their super-user bits already cast. + * explicit entry for an object is its whole answer for that object on every + * object-wide bit. * * A FIELD-axis question only. It is deliberately NOT a disjunct of * {@link holdsSuperuserBypass}: that predicate is the row-level bypass every * RLS, sharing and explain consumer folds through, and `viewAllFields` * widens no record (nor any admin posture, ADR-0095 D3, nor the private-posture - * wildcard rule, ADR-0066 D2). Its one reader is {@link superuserFieldVote}, + * wildcard rule, ADR-0066 D2). Its one reader is {@link viewAllFieldsReadVote}, * where it casts a read vote and never an edit vote (ruled read-only). */ function holdsViewAllFields( @@ -1127,7 +1114,7 @@ function declaresOwnReadMask( /** A resolved permission set, as far as the field merge reads it. */ export interface EffectiveFieldPermissionsInputSet { fields?: Record | null; - /** Read only for the super-user and `viewAllFields` vote ({@link superuserFieldVote}). */ + /** Read only for the `viewAllFields` vote ({@link viewAllFieldsReadVote}). */ objects?: Record | null; } @@ -1141,12 +1128,10 @@ export interface EffectiveFieldPermissionsInputSet { * this map never advertises an edit the write gate refuses, and may hide one it * admits on the rows the condition does not name. * - * A set holding the super-user bypass on an object then votes on every field - * of it ({@link superuserFieldVote}, ruling of record 6573563853), except - * that a View All set casts no read vote on a field its own row declares - * `readable: false` (ADR-0066 D2 ⑧ note of 2026-11-15). A set carrying - * `viewAllFields` on the object casts that same read vote, under the same - * own-row rule, and never an edit vote (ruling of record 6912661484). + * A set carrying `viewAllFields` on an object then casts a read vote on every + * field of it the map names, except a field its own row declares + * `readable: false`, and never an edit vote ({@link viewAllFieldsReadVote}, + * ruling of record 6912661484). View All and Modify All cast no field vote. * * Every entry is a FRESH object, as {@link buildEffectiveObjectPermissions}'s are. */ @@ -1166,16 +1151,13 @@ export function buildEffectiveFieldPermissions( fields[key] = acc; } } - // [Ruling of record 6573563853; ADR-0066 D2 ⑧ note of 2026-11-15] The - // super-user vote, per field the map names — the same function - // `getFieldPermissions` applies per field of its object. + // [Ruling of record 6912661484] The `viewAllFields` read vote, per field the + // map names — the same function `getFieldPermissions` applies per field of + // its object. for (const [key, acc] of Object.entries(fields)) { const dot = key.indexOf('.'); if (dot <= 0) continue; - const vote = superuserFieldVote(sets, key.slice(0, dot), key.slice(dot + 1)); - if (!vote) continue; - acc.readable = true; - if (vote.editable) acc.editable = true; + if (viewAllFieldsReadVote(sets, key.slice(0, dot), key.slice(dot + 1))) acc.readable = true; } return fields; } diff --git a/packages/core/src/security/index.ts b/packages/core/src/security/index.ts index aa9840cb8fc..2ded64d5c8c 100644 --- a/packages/core/src/security/index.ts +++ b/packages/core/src/security/index.ts @@ -433,10 +433,11 @@ export { // field-permission entry's vote under its row condition (`when`). buildEffectiveFieldPermissions, fieldPermissionVote, - // [ADR-0066 ⑧, ruling of record 6573563853] The one super-user predicate - // (row bypass and field vote alike) and the field merge's super-user vote. + // [ADR-0066 ⑧] The one super-user predicate (the row bypass), and the field + // merge's one "all fields" vote, `viewAllFields` (the field-axis split, + // ruling of record 6912661484: View All / Modify All cast no field vote). holdsSuperuserBypass, - superuserFieldVote, + viewAllFieldsReadVote, type FieldConditionVerdict, type FieldPermissionEntryLike, type EffectiveFieldPermissionsInputSet, diff --git a/packages/core/src/security/superuser-field-vote-33828.test.ts b/packages/core/src/security/superuser-field-vote-33828.test.ts index c05f3e41072..bfe8448fcf3 100644 --- a/packages/core/src/security/superuser-field-vote-33828.test.ts +++ b/packages/core/src/security/superuser-field-vote-33828.test.ts @@ -1,15 +1,14 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * [ADR-0066 D2 ⑧ note of 2026-11-15] A set's own explicit `readable: false` - * row is that set's vote on the field: its own View All casts no read vote - * there. Another set's bypass still votes (the admin case of ruling of record - * 6573563853), and a Modify All set still votes on every field, its own rows - * included. + * [ADR-0066 D2 ⑧, v19, #36055] View All and Modify All widen records only and + * cast no field vote. `viewAllFields` is the one "every field" channel: a read + * vote, never an edit vote, and a set's own explicit `readable: false` row + * beats its own bit (the own-row rule of the 2026-11-15 note, #33828). * * Pinned on the row-blind merge (`buildEffectiveFieldPermissions`, the `fields` * slot of `/auth/me/permissions`) and on the one function both field merges - * ask, `superuserFieldVote`. The evaluator's merge is pinned beside it in + * ask, `viewAllFieldsReadVote`. The evaluator's merge is pinned beside it in * plugin-security's `fls-own-field-mask-33828.test.ts`. */ @@ -17,121 +16,86 @@ import { describe, it, expect } from 'vitest'; import { buildEffectiveFieldPermissions, buildEffectiveObjectPermissions, - superuserFieldVote, + viewAllFieldsReadVote, } from './effective-object-permissions.js'; -describe('a set\'s own readable: false row and that set\'s own super-user vote', () => { - const viewAll = ( - fields: Record, - objects: Record = { deal: { allowRead: true, viewAllRecords: true } }, - ) => ({ objects, fields }); - const mask = { 'deal.amount': { readable: false, editable: false } }; - - it('View All beside the set\'s own readable: false row: the row binds, by the object entry and by the wildcard', () => { - expect(buildEffectiveFieldPermissions([viewAll(mask)])).toEqual({ 'deal.amount': { readable: false, editable: false } }); - expect(buildEffectiveFieldPermissions([viewAll(mask, { '*': { viewAllRecords: true } })])).toEqual({ - 'deal.amount': { readable: false, editable: false }, - }); - // Two holders of the pair, each masking the field itself: nobody votes it readable. - expect(buildEffectiveFieldPermissions([viewAll(mask), viewAll(mask)])).toEqual({ - 'deal.amount': { readable: false, editable: false }, - }); - }); +describe('[v19, #36055] View All and Modify All cast no field vote', () => { + const hider = { objects: { deal: { allowRead: true } }, fields: { 'deal.amount': { readable: false, editable: false } } }; + const lock = { objects: { deal: { allowRead: true, allowEdit: true } }, fields: { 'deal.amount': { readable: true, editable: false } } }; - it('the same set\'s View All still votes on the fields it does not mask itself', () => { - // `deal.stage` is masked by ANOTHER set; this set's View All reads it as before. - expect(buildEffectiveFieldPermissions([ - viewAll(mask), - { objects: { deal: { allowRead: true } }, fields: { 'deal.stage': { readable: false, editable: false } } }, - ])).toEqual({ - 'deal.amount': { readable: false, editable: false }, - 'deal.stage': { readable: true, editable: false }, - }); + it('an unconverted set with View All alone no longer reads a field another set hides', () => { + for (const objects of [{ deal: { allowRead: true, viewAllRecords: true } }, { '*': { allowRead: true, viewAllRecords: true } }]) { + expect(buildEffectiveFieldPermissions([{ objects }, hider])).toEqual({ 'deal.amount': { readable: false, editable: false } }); + expect(viewAllFieldsReadVote([{ objects }], 'deal', 'amount')).toBe(false); + } }); - it('reverse pin: another set\'s View All or Modify All on the object still reads the masked field', () => { - expect(buildEffectiveFieldPermissions([viewAll(mask), { objects: { deal: { viewAllRecords: true } } }])).toEqual({ - 'deal.amount': { readable: true, editable: false }, - }); - expect(buildEffectiveFieldPermissions([viewAll(mask), { objects: { '*': { viewAllRecords: true } } }])).toEqual({ - 'deal.amount': { readable: true, editable: false }, - }); - expect(buildEffectiveFieldPermissions([viewAll(mask), { objects: { deal: { modifyAllRecords: true } } }])).toEqual({ - 'deal.amount': { readable: true, editable: true }, - }); - // Another set's declared `readable: true` still out-votes the mask: union without deny. - expect(buildEffectiveFieldPermissions([viewAll(mask), { fields: { 'deal.amount': { readable: true, editable: false } } }])) - .toEqual({ 'deal.amount': { readable: true, editable: false } }); + it('Modify All opens neither the read nor the edit of a field another set hides or locks', () => { + const modifyAll = { objects: { deal: { allowRead: true, allowEdit: true, modifyAllRecords: true } } }; + expect(buildEffectiveFieldPermissions([modifyAll, hider])).toEqual({ 'deal.amount': { readable: false, editable: false } }); + expect(buildEffectiveFieldPermissions([modifyAll, lock])).toEqual({ 'deal.amount': { readable: true, editable: false } }); + expect(viewAllFieldsReadVote([modifyAll], 'deal', 'amount')).toBe(false); }); - it('Modify All is unchanged: it votes on every field, the set\'s own rows included', () => { - const modifyAll = { deal: { allowRead: true, allowEdit: true, modifyAllRecords: true } }; - expect(buildEffectiveFieldPermissions([{ objects: modifyAll, fields: mask }])).toEqual({ - 'deal.amount': { readable: true, editable: true }, - }); - expect(buildEffectiveFieldPermissions([{ objects: modifyAll, fields: { 'deal.amount': { readable: true, editable: false } } }])) - .toEqual({ 'deal.amount': { readable: true, editable: true } }); - // Both bits on one entry: the Modify All vote is the one that counts. - expect(buildEffectiveFieldPermissions([ - { objects: { deal: { viewAllRecords: true, modifyAllRecords: true } }, fields: mask }, - ])).toEqual({ 'deal.amount': { readable: true, editable: true } }); + it('a set\'s own rows bind beside its own View All or Modify All', () => { + for (const bits of [{ viewAllRecords: true }, { modifyAllRecords: true }]) { + const own = { objects: { deal: { allowRead: true, allowEdit: true, ...bits } }, fields: hider.fields }; + expect(buildEffectiveFieldPermissions([own])).toEqual({ 'deal.amount': { readable: false, editable: false } }); + const ownLock = { objects: { deal: { allowRead: true, allowEdit: true, ...bits } }, fields: lock.fields }; + expect(buildEffectiveFieldPermissions([ownLock])).toEqual({ 'deal.amount': { readable: true, editable: false } }); + } }); - it('an edit lock beside View All binds as it always did, and only an explicit false is a mask', () => { - expect(buildEffectiveFieldPermissions([viewAll({ 'deal.amount': { readable: true, editable: false } })])).toEqual({ - 'deal.amount': { readable: true, editable: false }, - }); - // An unparsed row that omits `readable` is not an explicit mask: the vote stands. - expect(buildEffectiveFieldPermissions([viewAll({ 'deal.amount': { editable: false } })])).toEqual({ - 'deal.amount': { readable: true, editable: false }, - }); + it('the conversion target: viewAllFields beside the bit restores the read, never the edit', () => { + for (const bits of [{ viewAllRecords: true }, { modifyAllRecords: true }]) { + const converted = { objects: { deal: { allowRead: true, allowEdit: true, ...bits, viewAllFields: true } } }; + expect(buildEffectiveFieldPermissions([converted, hider])).toEqual({ 'deal.amount': { readable: true, editable: false } }); + expect(buildEffectiveFieldPermissions([converted, lock])).toEqual({ 'deal.amount': { readable: true, editable: false } }); + } }); - it('superuserFieldVote: per field with a field name, object-wide without one', () => { - const sets = [viewAll(mask)]; - expect(superuserFieldVote(sets, 'deal', 'amount')).toBeNull(); - expect(superuserFieldVote(sets, 'deal', 'stage')).toEqual({ readable: true, editable: false }); - expect(superuserFieldVote(sets, 'deal')).toEqual({ readable: true, editable: false }); - expect(superuserFieldVote([{ objects: { deal: { modifyAllRecords: true } }, fields: mask }], 'deal', 'amount')) - .toEqual({ readable: true, editable: true }); - // The mask is read on the set that declares it, never on a sibling. - expect(superuserFieldVote([{ objects: { deal: { viewAllRecords: true } } }, { fields: mask }], 'deal', 'amount')) - .toEqual({ readable: true, editable: false }); + it('a field no set names follows the object grant, so the bits change nothing there', () => { + expect(buildEffectiveFieldPermissions([{ objects: { deal: { allowRead: true, modifyAllRecords: true } } }])).toEqual({}); }); }); -describe('[field-axis split, ruling 6912661484] viewAllFields: a read vote through the same shared vote, never an edit vote', () => { +describe('[field-axis split, ruling 6912661484] viewAllFields: a read vote, never an edit vote', () => { const hider = { objects: { deal: { allowRead: true } }, fields: { 'deal.amount': { readable: false, editable: false } } }; const reader = (objects: Record, fields?: Record) => ({ objects, fields }); it('alone it reads every field another set hides, read-only, by the object entry and by the wildcard', () => { for (const objects of [{ deal: { allowRead: true, viewAllFields: true } }, { '*': { allowRead: true, viewAllFields: true } }]) { expect(buildEffectiveFieldPermissions([reader(objects), hider])).toEqual({ 'deal.amount': { readable: true, editable: false } }); - expect(superuserFieldVote([reader(objects)], 'deal', 'amount')).toEqual({ readable: true, editable: false }); + expect(viewAllFieldsReadVote([reader(objects)], 'deal', 'amount')).toBe(true); } }); it('the set\'s own readable: false row beats its own viewAllFields; another set\'s bit still reads the field', () => { const own = reader({ deal: { allowRead: true, viewAllFields: true } }, { 'deal.amount': { readable: false, editable: false } }); expect(buildEffectiveFieldPermissions([own])).toEqual({ 'deal.amount': { readable: false, editable: false } }); - expect(superuserFieldVote([own], 'deal', 'amount')).toBeNull(); + expect(viewAllFieldsReadVote([own], 'deal', 'amount')).toBe(false); + expect(viewAllFieldsReadVote([own], 'deal', 'stage')).toBe(true); expect(buildEffectiveFieldPermissions([own, reader({ deal: { viewAllFields: true } })])) .toEqual({ 'deal.amount': { readable: true, editable: false } }); + // The mask is read on the set that declares it, never on a sibling. + expect(viewAllFieldsReadVote([reader({ deal: { viewAllFields: true } }), { fields: own.fields }], 'deal', 'amount')).toBe(true); + }); + + it('an edit lock beside it binds, and only an explicit false is a mask', () => { + const bit = { deal: { allowRead: true, allowEdit: true, viewAllFields: true } }; + expect(buildEffectiveFieldPermissions([reader(bit, { 'deal.amount': { readable: true, editable: false } })])).toEqual({ + 'deal.amount': { readable: true, editable: false }, + }); + // An unparsed row that omits `readable` is not an explicit mask: the vote stands. + expect(buildEffectiveFieldPermissions([reader(bit, { 'deal.amount': { editable: false } })])).toEqual({ + 'deal.amount': { readable: true, editable: false }, + }); }); it('an explicit entry is the set\'s whole answer: a wildcard bit does not reach an object the set names', () => { const named = reader({ '*': { viewAllFields: true }, deal: { allowRead: true } }); expect(buildEffectiveFieldPermissions([named, hider])).toEqual({ 'deal.amount': { readable: false, editable: false } }); }); - - it('beside View All or Modify All it changes nothing: those bits already cast the vote', () => { - for (const bits of [{ viewAllRecords: true }, { modifyAllRecords: true }]) { - const without = reader({ '*': { allowRead: true, ...bits } }); - const withBit = reader({ '*': { allowRead: true, ...bits, viewAllFields: true } }); - expect(buildEffectiveFieldPermissions([withBit, hider])).toEqual(buildEffectiveFieldPermissions([without, hider])); - expect(superuserFieldVote([withBit], 'deal', 'amount')).toEqual(superuserFieldVote([without], 'deal', 'amount')); - } - }); }); describe('[field-axis split, ruling 6912661484] a wildcard viewAllFields is posture-blind: it votes on a private object\'s fields and grants no object', () => { @@ -150,7 +114,7 @@ describe('[field-axis split, ruling 6912661484] a wildcard viewAllFields is post }); it('the field axis: the same wildcard still casts its read vote on the private object\'s field', () => { - expect(superuserFieldVote([wildcard], 'vault', 'pin')).toEqual({ readable: true, editable: false }); + expect(viewAllFieldsReadVote([wildcard], 'vault', 'pin')).toBe(true); // Control: without the bit the field stays hidden, so the vote below is the bit's. expect(buildEffectiveFieldPermissions([{ objects: { '*': { allowRead: true } } }, hider])).toEqual({ 'vault.pin': { readable: false, editable: false }, diff --git a/packages/lint/src/finding-user-text.test.ts b/packages/lint/src/finding-user-text.test.ts index fe21d7327d0..743f6373844 100644 --- a/packages/lint/src/finding-user-text.test.ts +++ b/packages/lint/src/finding-user-text.test.ts @@ -28,7 +28,6 @@ import { SECURITY_CROSS_SET_FIELD_REOPEN, SECURITY_MASTER_DETAIL_UNGRANTED, SECURITY_PRIVATE_NO_READSCOPE, - SECURITY_SUPERUSER_FIELD_MASK_INERT, SECURITY_UPDATE_POLICY_NO_CHECK, validateSecurityPosture, type SecurityFinding, @@ -146,7 +145,6 @@ const ADVISORY_RULES = [ SECURITY_PRIVATE_NO_READSCOPE, SECURITY_MASTER_DETAIL_UNGRANTED, SECURITY_BOOK_AUDIENCE_UNKNOWN_SET, - SECURITY_SUPERUSER_FIELD_MASK_INERT, SECURITY_CBP_MASTER_REFERENCE_HIDDEN, SECURITY_UPDATE_POLICY_NO_CHECK, SECURITY_CBP_OWNER_POLICY_WITHOUT_OPT_IN, @@ -162,7 +160,7 @@ const OMD_DETAIL_FIELDS = { const omdDetail = (extra: Record = {}) => ({ name: 'omd_obligation', label: 'Obligation', sharingModel: 'controlled_by_parent', fields: OMD_DETAIL_FIELDS, ...extra, }); -/** A field one set hides or locks, and a second set whose object-wide bit re-opens it. */ +/** A field one set hides, and a second set whose `viewAllFields` re-opens it. */ const reopenStack = (hidingRow: Record, otherDeal: Record) => ({ objects: [{ name: 'deal', label: 'Deal', sharingModel: 'private', fields: { margin: { type: 'number', label: 'Margin' } } }], permissions: [ @@ -170,8 +168,8 @@ const reopenStack = (hidingRow: Record, otherDeal: Record ({ - permissionSet: 'consultant', otherSet: 'deal_lead', field: 'deal.margin', object: 'deal', bit, reopened, +const reopenParams = () => ({ + permissionSet: 'consultant', otherSet: 'deal_lead', field: 'deal.margin', object: 'deal', }); const omdStack = (detail: Record, using: string) => ({ @@ -184,7 +182,7 @@ const omdStack = (detail: Record, using: string) => ({ /** * One stack per advisory push site, with the params each finding must carry - * (the names its sentence interpolates). Every push site of the eight rule ids + * (the names its sentence interpolates). Every push site of the seven rule ids * is reached: the two owner-policy functions, and the second one in both of * its remedy states. */ @@ -222,42 +220,6 @@ const CASES: ReadonlyArray<{ label: string; rule: string; stack: Record