Skip to content

Commit 94ee3ea

Browse files
committed
test(security): satisfy the gates the effective-access read reaches
The effective-access test's fake engine routes findOne through assertEngineFindOnePredicate and the pinned ledger records it; the REST door's test pays the objectql load at collection; the system-context page names mayDescribeAnotherUser on the row that owns the explain gate, now that both reads ask it. Claude-Session: https://claude.ai/code/session_01FEkQ5kUXrK37qc2vkfEHQ4 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9dbf86c commit 94ee3ea

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎content/docs/permissions/system-context.mdx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ bugs — it is the protection or the side effect that silently does not happen.
111111
| 7 | Write bypass = `true`, effective write scope = `org` | plugin-security | Get: widest write scope without holding any capability | `registerSecurityService` |
112112
| 8 | Metadata-plane schema masking exempt (ADR-0106 D4) | metadata-core | Get: unmasked object schema. Note: the exemption is a **caller** property — it short-circuits before the security service is consulted | `isObjectSchemaMaskExempt` |
113113
| 8b | Authoring-trail reads admitted | rest, runtime | Get: a metadata item's version history, audit rows and stored-version diff (`GET /meta/:type/:name/history`, `/audit`, `/diff`) without `studio.access` or `manage_metadata`, and a package's commit timeline (`GET /packages/:id/commits`) without `studio.access`. Note: narrower than the schema-mask exemption the draft switches ask (`isObjectSchemaMaskExempt`): neither door admits `setup.access`, which organization admins hold | `mayReadAuthoringTrail`, `requireCommitTrailReadCapability` |
114-
| 9 | `explain()` may target a principal other than the caller | plugin-security | Get: no `manage_users` / delegated-admin check | `explainAccessForCaller` |
114+
| 9 | `explain()` and the effective-access read (`describeEffectiveAccess`) may target a principal other than the caller | plugin-security | Get: no `manage_users` / delegated-admin check — both reads ask the one caller gate | `explainAccessForCaller`, `mayDescribeAnotherUser` |
115115
| 9b | The master-detail write check the `security` service serves (`checkControlledByParentWrite`, ADR-0055) answers `allow` | plugin-security | Get: `allow` for any record, with no master judged — the write path's own first exit, so a gate composing it admits exactly what the record's own system-context update would. Lose: nothing a caller reaches today: its two consumers, the `sys_attachment` and `sys_comment` parent gates, return before they ask for a system session | `checkControlledByParentWrite` |
116116
| 10 | Anonymous-deny treats the caller as authenticated | core | Get: passes the 401 seam with no `userId` | `shouldDenyAnonymous` |
117117
| 12 | Session-resolution middleware skipped | plugin-auth | Get: no session lookup attempted | `packages/plugins/plugin-auth/src/auth-plugin.ts#start` |
@@ -592,7 +592,8 @@ and CI refuses one that differs from what the tree produces.
592592
| `packages/plugins/plugin-security/src/position-catalog-refusal.ts#assertPositionNamesCatalogRow` | 1 | 23b |
593593
| `packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts#registerAuthzMiddleware` | 1 | 1, 2, 30 |
594594
| `packages/plugins/plugin-security/src/security-plugin-cbp-write-gate.ts#checkControlledByParentWrite` | 1 | 9b |
595-
| `packages/plugins/plugin-security/src/security-plugin-explain-access.ts#explainAccessForCaller` | 2 | 9 |
595+
| `packages/plugins/plugin-security/src/security-plugin-explain-access.ts#explainAccessForCaller` | 1 | 9 |
596+
| `packages/plugins/plugin-security/src/security-plugin-explain-access.ts#mayDescribeAnotherUser` | 1 | 9 |
596597
| `packages/plugins/plugin-security/src/security-plugin-field-readers.ts#resolveProjectionFieldMask` | 1 | 4 |
597598
| `packages/plugins/plugin-security/src/security-plugin-object-admission.ts#canExport` | 1 | 5 |
598599
| `packages/plugins/plugin-security/src/security-plugin-object-admission.ts#canReadObject` | 1 | 6 |

‎packages/plugins/plugin-security/src/effective-access.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import { afterEach, describe, it, expect } from 'vitest';
2222
import { resetPlatformAdminEmailMemo } from '@objectstack/core';
23+
import { assertEngineFindOnePredicate } from '@objectstack/metadata-core';
2324
import { PermissionSetSchema, type PermissionSet } from '@objectstack/spec/security';
2425
import { PermissionEvaluator } from './permission-evaluator';
2526
import { describeEffectiveAccess, type EffectiveAccessHost } from './security-plugin-effective-access';
@@ -53,6 +54,7 @@ function engine(tables: Tables, catalog: { positions: Array<{ name: string; perm
5354
return typeof opts?.limit === 'number' ? rows.slice(0, opts.limit) : rows;
5455
},
5556
async findOne(object: string, opts: any) {
57+
assertEngineFindOnePredicate(object, opts);
5658
return (tables[object] ?? []).find((row) => match(row, opts?.where)) ?? null;
5759
},
5860
}, catalog);

‎packages/rest/src/security-routes.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import { describe, it, expect, vi } from 'vitest';
55
import { RestServer } from './rest-server';
6+
// Paid at collection, not inside a clocked case: the server reaches it lazily.
7+
import '@objectstack/objectql';
68

79
// ── helpers ──────────────────────────────────────────────────────────────────
810

‎scripts/engine-double-contract.pinned.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4106,6 +4106,11 @@
41064106
"verb": "findOne",
41074107
"pinned": 1
41084108
},
4109+
{
4110+
"file": "packages/plugins/plugin-security/src/effective-access.test.ts",
4111+
"verb": "findOne",
4112+
"pinned": 1
4113+
},
41094114
{
41104115
"file": "packages/plugins/plugin-security/src/engine-find-bare-array.pin.test.ts",
41114116
"verb": "findOne",

0 commit comments

Comments
 (0)