Repository navigation
Expand file tree
/
Copy pathhooks-security-seeds-datasources.json
More file actions
225 lines (225 loc) · 19.8 KB
/
Copy pathhooks-security-seeds-datasources.json
File metadata and controls
225 lines (225 loc) · 19.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
{
"skill_name": "objectstack-data",
"evals": [
{
"id": 1,
"prompt": "Support agents want to search tasks by their project's name.",
"expected_output": "A stored `text` mirror `project_name` on `task`, in `searchableFields: ['name', 'project_name']`; a `beforeInsert` / `beforeUpdate` hook on `task` stamps it, an `afterUpdate` hook on `project` re-stamps it on rename; rows written outside hooks get a backfill.",
"files": [],
"assertions": {
"must_contain": ["searchableFields", "project_name", "beforeInsert", "afterUpdate"],
"must_not_contain": ["'project_id.name'", "type: 'formula'"]
}
},
{
"id": 2,
"prompt": "Sales reps see only their own leads, sales managers their unit and everything below it; every signed-in user reads the `product` catalog.",
"expected_output": "`lead` is `sharingModel: 'private'`; the rep grant carries `readScope: 'own'`, the manager grant `readScope: 'unit_and_below'` (`@objectstack/security-enterprise` + `requires: ['hierarchy-security']`, else fails closed to `own`); `product` is `sharingModel: 'public_read'`.",
"files": [],
"assertions": {
"must_contain": ["sharingModel: 'private'", "readScope", "unit_and_below", "public_read", "hierarchy-security"],
"must_not_contain": ["permissions: {"]
}
},
{
"id": 3,
"prompt": "Expose the `customers` table of our Postgres reporting database as a read-only `legacy_customer` object.",
"expected_output": "A `defineDatasource` entry (say `reporting`) with `schemaMode: 'external'` (the remote schema stays unaltered) and no credential in the declaration: the password is read at connect from `OS_DATASOURCE_REPORTING_PASSWORD` (the name upper-cased) while the host switch `OS_DATASOURCE_ENV_CREDENTIALS` is `on` (`os serve`/`start`/`dev` default it on); the object sets `datasource: 'reporting'` and `external: { remoteName: 'customers', columnMap }`; the write gate stays closed (no `allowWrites`, no `writable`).",
"files": [],
"assertions": {
"must_contain": ["defineDatasource", "datasource", "remoteName", "columnMap", "schemaMode", "OS_DATASOURCE_ENV_CREDENTIALS", "_PASSWORD"],
"must_not_contain": ["columnName:"]
}
},
{
"id": 4,
"prompt": "Seed the `country` table for every environment; add demo `opportunity` rows (dev/test only) closing 45 days after install, owned by the installer, and refreshed from the seed on every replay except `stage`: a nightly job advances it, and a replay must not reset it.",
"expected_output": "`defineSeed(Country, { externalId: 'code', mode: 'upsert', records })` for reference data; `defineSeed(Opportunity, { mode: 'upsert', env: ['dev', 'test'], ... })` for the refreshed demo rows — natural-key lookups, CEL values (`close_date: cel`daysFromNow(45)``, `owner_id: cel`os.user.id``), parents first; `columns: { stage: { applyOn: 'create' } }` so the `upsert` replay leaves the job-owned column (the `ignore` default would refresh nothing).",
"files": [],
"assertions": {
"must_contain": ["defineSeed", "externalId", "upsert", "env:", "daysFromNow", "applyOn: 'create'"],
"must_not_contain": ["new Date(", "defineDataset", "externalId: 'id'"]
}
},
{
"id": 5,
"prompt": "Finance may edit a contract's legal terms (`governing_law`, `liability_cap`) while it is a draft, not once approved, signing or active; legal still edits them.",
"expected_output": "Row-conditioned field permission entries on the finance set — `'clm_contract.governing_law': { readable: true, editable: false, when: \"status in ['approved', 'signing', 'active']\" }`, likewise `liability_cap`; legal keeps its edit grant.",
"files": [],
"assertions": {
"must_contain": ["when:", "editable: false", "readable: true", "clm_contract.governing_law"],
"must_not_contain": ["validations:", "readonlyWhen"]
}
},
{
"id": 6,
"prompt": "Portal users may read only the orders of the accounts they belong to, never another account's.",
"expected_output": "On the roster object `account_member` (`user` + `account` lookup): `membershipKeys: { portal_account_ids: { userField: 'user', valueField: 'account' } }`; a portal permission set reads it (`using: 'account in current_user.portal_account_ids'`), a position names it in `permissionSets`, portal staff join on the `external` tier outside the `everyone` baseline. No policy per account, no owner stamp per order.",
"files": [],
"assertions": {
"must_contain": ["membershipKeys", "current_user.portal_account_ids", "userField", "valueField", "permissionSets", "external"],
"must_not_contain": ["permissions: {"]
}
},
{
"id": 7,
"prompt": "We serve English and Chinese users. An `order` whose `amount` exceeds its account's `credit_limit` must not save; API clients branch on `CREDIT_LIMIT`, a zh-CN rep reads `超出账户信用额度`.",
"expected_output": "A `beforeInsert` / `beforeUpdate` hook on `order` declares `refusals: { CREDIT_LIMIT: { message: 'Over the account credit limit.' } }`; its sandboxed `body: { language: 'js', source }` reads the account via `ctx.api` and refuses by code only (`throw Object.assign(new Error(), { code: 'CREDIT_LIMIT' })`); the zh-CN bundle's `hooks: { <hook>: { refusals: { CREDIT_LIMIT: { message: '超出账户信用额度' } } } }` is served in the caller's locale; a catalogue on a hook without a `js` body is refused at save.",
"files": [],
"assertions": {
"must_contain": ["refusals:", "CREDIT_LIMIT: {", "code: 'CREDIT_LIMIT'", "language: 'js'", "hooks: {", "超出账户信用额度"],
"must_not_contain": ["new Error('", "handler:"]
}
},
{
"id": 8,
"prompt": "Web-form leads arrive ownerless; inside sales holds them until a rep takes one, and two reps must never own the same lead.",
"expected_output": "`queues: [defineQueue({ name: 'crm_inside_sales', label: 'Inside Sales', members: [{ type: 'position', value: 'crm_inside_sales_rep' }] })]` and an `assignmentRules` entry `assignTo: { type: 'queue', value: 'crm_inside_sales' }` with no `strategy` park each lead in the injected `queue` column; a rep claims by an ordinary by-id `{ owner_id: <self> }` update, the loser gets `409 CONCURRENT_UPDATE`.",
"files": [],
"assertions": {
"must_contain": ["defineQueue", "type: 'position'", "type: 'queue'", "CONCURRENT_UPDATE"],
"must_not_contain": ["assigned_to", "beforeInsert"]
}
},
{
"id": 18,
"prompt": "Our package `com.acme.crm` must share every escalated `case` with the members of `support_tier2`, the ownership queue the `com.acme.helpdesk` package ships. `com.acme.crm` declares no dependencies today.",
"expected_output": "A sharing rule in `com.acme.crm` with `sharedWith: { type: 'queue', value: 'support_tier2' }`, and `com.acme.crm`'s manifest declares `dependencies` on `com.acme.helpdesk`: a package's rule reads the queue as its own package's, else the one holder in its declared `dependencies` closure plus `sys`. Without the dependency the only holder sits outside the closure and the rule is refused `outside-closure` (`RESOURCE_CONFLICT`), granting no one. The queue is not redeclared in `com.acme.crm`: a second package holding the name is refused too.",
"files": [],
"assertions": {
"must_contain": ["type: 'queue'", "dependencies", "outside-closure"],
"must_not_contain": ["name: 'support_tier2'"]
}
},
{
"id": 19,
"prompt": "Our package `com.acme.crm` ships a position `crm_case_handler` whose holders must get `hd_agent`, the permission set the `com.acme.helpdesk` package ships. `com.acme.crm` declares no dependencies today.",
"expected_output": "In `com.acme.crm`, the position `{ name: 'crm_case_handler', label: 'Case Handler', permissionSets: ['hd_agent'] }`, and `com.acme.crm`'s manifest declares `dependencies: { 'com.acme.helpdesk': '^1.0.0' }`: a package's position reads each set name as its own package's set, else the one holder in its declared `dependencies` closure plus `sys`. Without the dependency the only holder sits outside the closure: the name is refused `outside-closure`, the boot's catalog reference report logs it, and the position grants nothing through it. The set is not redeclared in `com.acme.crm`: a second package shipping the name is refused at install.",
"files": [],
"assertions": {
"must_contain": ["permissionSets: ['hd_agent']", "dependencies: {", "outside-closure"],
"must_not_contain": ["name: 'hd_agent'"]
}
},
{
"id": 9,
"prompt": "A `vendor` list view of the rows whose `api_key` (a `secret` field) starts with `sk_live`.",
"expected_output": "Redirects: a credential is filtered only by presence, `filter: [{ field: 'api_key', operator: 'is_not_null' }]`; any other filter or sort is `400 INVALID_FIELD`.",
"files": [],
"assertions": {
"must_contain": ["INVALID_FIELD", "is_not_null"],
"must_not_contain": ["starts_with"]
}
},
{
"id": 10,
"prompt": "An `account` whose `tax_id` appears in our `blocked_tax_id` object must not save, on create or edit. Our tax authority also offers a lookup API; can the same hook call it?",
"expected_output": "A `beforeInsert` / `beforeUpdate` hook on `account` with a sandboxed `body: { language: 'js', source, capabilities: ['api.read'] }`: the source returns when the write carries no `tax_id`, reads `ctx.api.object('blocked_tax_id').findOne({ where: { tax_id: ctx.input.tax_id } })` and throws when it finds a row. Not a validation rule (there is no `custom` / `async` type) and not the deprecated inline `handler`. The tax-authority API is not called from the hook: a `body` has no outbound HTTP, so that check goes through a Connector recipe.",
"files": [],
"assertions": {
"must_contain": ["beforeInsert", "beforeUpdate", "language: 'js'", "'api.read'", "ctx.api.object("],
"must_not_contain": ["handler:", "HookContext", "'http.fetch'"]
}
},
{
"id": 11,
"prompt": "Expose the remote `suppliers` table of our `warehouse` datasource as a read-only `ext_supplier` object every member can read.",
"expected_output": "A complete `ObjectSchema.create` with `datasource: 'warehouse'`, `external: { remoteName: 'suppliers' }` and an authored `sharingModel: 'public_read'` — a publish with none is refused (`security-owd-unset`), and on 'private' a member reads no row of a binding whose remote rows carry no owner.",
"files": [],
"assertions": {
"must_contain": ["ObjectSchema.create", "remoteName", "sharingModel: 'public_read'"],
"must_not_contain": ["columnName:"]
}
},
{
"id": 12,
"prompt": "When an `account`'s `industry` changes, copy the new value into `account_industry` on every contact of that account.",
"expected_output": "An `afterUpdate` hook on `account` with a sandboxed `body: { language: 'js', source, capabilities: ['api.write'] }`: the source compares `ctx.input.industry` with `ctx.previous.industry` and, when it changed, makes one bulk write, `ctx.api.object('contact').update({ account_industry: ctx.input.industry }, { where: { account_id: ctx.previous.id }, multi: true })`. The row is keyed on `ctx.previous.id`: a body's `ctx.input` carries `id` only when the payload does, so on a bulk or by-`where` update the key would be empty and the `where` would match every contact. Not the deprecated inline `handler`, and not a bulk method the hook's `ctx.api` does not have (`updateMany` throws \"not implemented\").",
"files": [],
"assertions": {
"must_contain": ["afterUpdate", "language", "js", "api.write", "multi: true", "ctx.previous.id"],
"must_not_contain": ["handler:", "HookContext", "account_id: ctx.input.id"]
}
},
{
"id": 13,
"prompt": "Run our `account` enrichment hook only for accounts whose `annual_revenue` (an optional currency field) is above 1,000,000.",
"expected_output": "The hook's declarative `condition: P`record.annual_revenue != null && record.annual_revenue > 1000000``. `record` is total over the declared fields, so an empty `annual_revenue` reads `null` and CEL has no `>` overload for it: the publish gate refuses the unguarded comparison, and at runtime it would refuse each write on an account with no `annual_revenue`. `has(record.annual_revenue)` is not a guard (a declared field holding null is present).",
"files": [],
"assertions": {
"must_contain": ["condition:", "record.annual_revenue != null", "record.annual_revenue > 1000000"],
"must_not_contain": []
}
},
{
"id": 14,
"prompt": "Seed eight demo members for the gym app. For privacy, mask the phone numbers like `138****4207` and put `N/A` where we have no email.",
"expected_output": "A `defineSeed(Member, { env: ['dev', 'test'], records: [...] })` whose every value is fictional but WELL-FORMED: `+86 138 0013 8000`-style phones, `liyy@example.com`-style emails, option VALUES for selects. Explains that a seed row passes the same field validation as a user's insert, so a masked phone or an `N/A` email is refused and never lands — the table loads short or empty while bookings point at members that do not exist. Does not downgrade the `phone` field to `text` to make the rows load.",
"files": [],
"assertions": {
"must_contain": ["defineSeed", "+86 138", "@example.com"],
"must_not_contain": ["****", "'N/A'", "type: 'text', label: 'Phone'"]
}
},
{
"id": 15,
"prompt": "报销单:申请人默认是当前用户,还有一个审批人和一个复核人。",
"expected_output": "`applicant`, `approver` and `reviewer` are `type: 'user'` fields (the person picker — no `reference`, never a `lookup` to a user object you invent); `applicant` carries `defaultValue: 'current_user'`; none is `required`, since the request does not ask for it and the platform already stamps the owner and `created_by`. Describes the default as SAVE-time — 「保存后申请人会自动填为当前用户;表单里这一栏可能显示为空,留空提交即可」 — and does not promise the create form pre-fills it.",
"files": [],
"assertions": {
"must_contain": ["type: 'user'", "defaultValue: 'current_user'"],
"must_not_contain": ["reference: 'sys_user'", "reference: 'user'", "{ type: 'user', required: true }", "会自动预填"]
}
},
{
"id": 16,
"prompt": "Two objects: performance reviews that only the reviewed person's manager and HR may see, and a price list everyone can read but only finance maintains.",
"expected_output": "`performance_review` is `sharingModel: 'private'` (owner-only by default, widened to the manager and HR with sharing rules / RLS in a permission set, rules/security.md); `price_list` is `sharingModel: 'public_read'` (everyone reads, the owner writes) with finance as its owners. Neither is `public_read_write`, the posture for an ordinary shared business object — the posture is chosen from the request, not by habit. No `permissions` key on the object.",
"files": [],
"assertions": {
"must_contain": ["sharingModel: 'private'", "sharingModel: 'public_read'"],
"must_not_contain": ["sharingModel: 'public_read_write'", "permissions:"]
}
},
{
"id": 17,
"prompt": "In our HR app each `employee` record has a `user` lookup to the person who signs in. An employee may read only their own `leave_request` rows (each has an `employee` lookup), and we don't want an owner stamp or a junction table for it. Call the set `my_employee_ids`.",
"expected_output": "On the `employee` roster: `membershipKeys: { my_employee_ids: { userField: 'user', valueField: 'id' } }`, so the set is the ids of the caller's own employee rows; a permission set reads it (`using: 'employee in current_user.my_employee_ids'`) on `leave_request`, whose `employee` references the roster. The key grants nothing by itself, and tested against a column that does not reference `employee` (or another object's `id`) the policy is refused (`rls-predicate-membership-key-target`). No `owner_id` scoping, no junction object.",
"files": [],
"assertions": {
"must_contain": ["membershipKeys", "my_employee_ids", "valueField: 'id'", "employee in current_user.my_employee_ids"],
"must_not_contain": ["using: 'owner_id"]
}
},
{
"id": 20,
"prompt": "Each `project` shows a `task_count` — the number of its `task` records (each task has a `project` lookup). Add a `client_viewer` permission set: clients read projects, but must never be able to read tasks.",
"expected_output": "`task_count` is a `summary` on `project` (`summaryOperations: { object: 'task', function: 'count' }`). `client_viewer` grants `project: { allowRead: true }` and no `task` entry — and because a roll-up covers every child row and answers only to the parent field's own access, the set also masks the summary: `fields: { 'project.task_count': { readable: false } }`, with no View All / Modify All on `project` (either overrides the mask). The build then finishes without `security-rollup-source-unreadable`; the warning is resolved, not left standing or explained away, and not silenced by granting the `task` read the request forbids.",
"files": [],
"assertions": {
"must_contain": ["function: 'count'", "'project.task_count': { readable: false }"],
"must_not_contain": ["task: { allowRead: true }"]
}
},
{
"id": 21,
"prompt": "In our project tracker a contractor may create a `task` only when they are its `assignee` (a person field). A contractor asks the assistant \"Add a 'Launch checklist' task to the Website relaunch\" and the create answers 403, because the request names no assignee. Author the field and the contractor permission set's policy so the plain request succeeds, without widening whom a contractor may assign.",
"expected_output": "`assignee: { type: 'user', defaultValue: 'current_user' }` on `task`, and on the contractor permission set a `rowLevelSecurity` policy with `object: 'task'`, `operation: 'insert'` and `check: 'assignee == current_user.id'`. The default fills an omitted `assignee` with the acting user before `check` is judged, so a create that names no assignee is admitted and one naming someone else is still refused. The `check` is kept as it is, not loosened or dropped.",
"files": [],
"assertions": {
"must_contain": ["type: 'user'", "defaultValue: 'current_user'", "check: 'assignee == current_user.id'"],
"must_not_contain": []
}
},
{
"id": 22,
"prompt": "Our package `com.acme.crm` ships a position `sales_rep`, live at customers, and a sharing rule in the same package whose `sharedWith` is `{ type: 'position', value: 'sales_rep' }`. The next version must call the position `crm_sales_rep`. What changes in the package?",
"expected_output": "The position becomes `{ name: 'crm_sales_rep', label: 'Sales Rep', renamedFrom: ['sales_rep'], permissionSets: [...] }`: renamed in place with `renamedFrom`, never deleted and re-added, so at boot its holders (`sys_user_position`) move to the new name in every organization. Only holders move: no other reference to the old name is rewritten, so the package's own sharing rule is re-pointed in source to `sharedWith: { type: 'position', value: 'crm_sales_rep' }`, as is any approver, queue member, policy `positions` entry or `current_user.positions` predicate in the package that names `sales_rep`. Stored references in an installed environment (recipients, pending approvers, invitations) are listed by table in the boot log for an administrator to re-point in Setup.",
"files": [],
"assertions": {
"must_contain": ["renamedFrom: ['sales_rep']", "value: 'crm_sales_rep'"],
"must_not_contain": []
}
}
]
}