Skip to content

Commit b274de2

Browse files
committed
fix(integrations): validate clerk, crowdstrike, infisical, ketch, onepassword, persona, rootly
1 parent 0be28a0 commit b274de2

96 files changed

Lines changed: 757 additions & 200 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/docs/content/docs/integrations/ketch.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Retrieve consent status for a data subject. Returns the current consent preferen
4343
| Parameter | Type | Description |
4444
| --------- | ---- | ----------- |
4545
| `purposes` | object | Map of purpose codes to consent status and legal basis |
46-
| ↳ `allowed` | string | Consent status for the purpose: "granted" or "denied" |
46+
| ↳ `allowed` | string | Consent status for the purpose: "true" or "false" |
4747
| ↳ `legalBasisCode` | string | Legal basis code \(e.g., "consent_optin", "consent_optout", "disclosure", "other"\) |
48-
| `vendors` | object | Map of vendor consent statuses |
48+
| `vendors` | array | TCF vendor IDs returned with the consent record |
4949

5050
</ReferenceDetails>
5151

@@ -64,15 +64,15 @@ Update consent preferences for a data subject. Sets the consent status for speci
6464
| `environmentCode` | string | Yes | Environment code defined in Ketch \(e.g., "production"\) |
6565
| `jurisdictionCode` | string | No | Jurisdiction code \(e.g., "gdpr", "ccpa"\) |
6666
| `identities` | json | Yes | Identity map \(e.g., \{"email": "user@example.com"\}\) |
67-
| `purposes` | json | Yes | Map of purpose codes to consent settings \(e.g., \{"analytics": \{"allowed": "granted", "legalBasisCode": "consent_optin"\}\}\) |
67+
| `purposes` | json | Yes | Map of purpose codes to consent settings. "allowed" is "true" or "false" \("granted"/"denied" are accepted and converted\) \(e.g., \{"analytics": \{"allowed": "true", "legalBasisCode": "consent_optin"\}\}\) |
6868
| `collectedAt` | number | No | UNIX timestamp when consent was collected \(defaults to current time\) |
6969

7070
#### Output
7171

7272
| Parameter | Type | Description |
7373
| --------- | ---- | ----------- |
7474
| `purposes` | object | Updated consent status map of purpose codes to consent settings |
75-
| ↳ `allowed` | string | Consent status for the purpose: "granted" or "denied" |
75+
| ↳ `allowed` | string | Consent status for the purpose: "true" or "false" |
7676
| ↳ `legalBasisCode` | string | Legal basis code \(e.g., "consent_optin", "consent_optout", "disclosure", "other"\) |
7777

7878
</ReferenceDetails>
@@ -142,7 +142,7 @@ Submit a data subject rights request (e.g., access, delete, correct, restrict pr
142142
| `jurisdictionCode` | string | Yes | Jurisdiction code \(e.g., "gdpr", "ccpa"\) |
143143
| `rightCode` | string | Yes | Privacy right code to invoke \(e.g., "access", "delete", "correct", "restrict_processing"\) |
144144
| `identities` | json | Yes | Identity map \(e.g., \{"email": "user@example.com"\}\) |
145-
| `userData` | json | No | Optional data subject information \(e.g., \{"email": "user@example.com", "firstName": "John", "lastName": "Doe"\}\) |
145+
| `userData` | json | Yes | Data subject information sent as the request "user"; Ketch requires it for rights requests \(e.g., \{"email": "user@example.com", "firstName": "John", "lastName": "Doe"\}\) |
146146

147147
#### Output
148148

‎apps/docs/content/docs/integrations/onepassword.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ List all vaults accessible by the Connect token or Service Account
4646
| ↳ `attributeVersion` | number | Vault attribute version |
4747
| ↳ `contentVersion` | number | Vault content version |
4848
| ↳ `items` | number | Number of items in the vault |
49-
| ↳ `type` | string | Vault type \(USER_CREATED, PERSONAL, or EVERYONE\) |
49+
| ↳ `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, or TRANSFER\) |
5050
| ↳ `createdAt` | string | Creation timestamp |
5151
| ↳ `updatedAt` | string | Last update timestamp |
5252

@@ -78,7 +78,7 @@ Get details of a specific vault by ID
7878
| `attributeVersion` | number | Vault attribute version |
7979
| `contentVersion` | number | Vault content version |
8080
| `items` | number | Number of items in the vault |
81-
| `type` | string | Vault type \(USER_CREATED, PERSONAL, or EVERYONE\) |
81+
| `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, or TRANSFER\) |
8282
| `createdAt` | string | Creation timestamp |
8383
| `updatedAt` | string | Last update timestamp |
8484

‎apps/sim/blocks/blocks/clerk.test.ts‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22
import { ClerkBlock } from '@/blocks/blocks/clerk'
3+
import { clerkListUsersTool } from '@/tools/clerk/list_users'
4+
import type { ClerkListUsersParams } from '@/tools/clerk/types'
35

46
/**
57
* A tool call merges the stored row with the model's args (keyed by tool param names) and spreads
@@ -10,6 +12,31 @@ const toolCall = (args: Record<string, unknown>, operation: string) => ({
1012
...ClerkBlock.tools.config?.params?.(args, { operation }),
1113
})
1214

15+
/**
16+
* The canvas executor spreads the mapper result over the block's serialized inputs and passes no
17+
* context. Serialized inputs keep non-empty advanced values saved under another operation.
18+
*/
19+
const canvasCall = (inputs: Record<string, unknown>) => ({
20+
...inputs,
21+
...ClerkBlock.tools.config?.params?.(inputs),
22+
})
23+
24+
const stringParam = (value: unknown) => (typeof value === 'string' ? value : undefined)
25+
26+
const listUsersUrl = (params: Record<string, unknown>) => {
27+
const url = clerkListUsersTool.request.url
28+
if (typeof url !== 'function') throw new Error('expected a URL builder')
29+
const toolParams: ClerkListUsersParams = {
30+
secretKey: 'sk',
31+
emailAddress: stringParam(params.emailAddress),
32+
phoneNumber: stringParam(params.phoneNumber),
33+
externalId: stringParam(params.externalId),
34+
username: stringParam(params.username),
35+
userId: stringParam(params.userId),
36+
}
37+
return new URL(url(toolParams)).searchParams
38+
}
39+
1340
describe('ClerkBlock tool calls', () => {
1441
it('parses metadata the model sends as a JSON string', () => {
1542
const params = toolCall(
@@ -19,4 +46,41 @@ describe('ClerkBlock tool calls', () => {
1946
expect(params.publicMetadata).toEqual({ plan: 'pro' })
2047
expect(params.emailAddress).toEqual(['a@example.com'])
2148
})
49+
50+
it('keeps the filters the model sends to List Users', () => {
51+
const query = listUsersUrl(
52+
toolCall({ secretKey: 'sk', username: 'alice', externalId: 'ext_1' }, 'clerk_list_users')
53+
)
54+
expect(query.getAll('username')).toEqual(['alice'])
55+
expect(query.getAll('external_id')).toEqual(['ext_1'])
56+
})
57+
})
58+
59+
describe('ClerkBlock canvas List Users', () => {
60+
const staleCreateUserInputs = {
61+
secretKey: 'sk',
62+
username: 'stale-bob',
63+
externalId: 'stale-ext',
64+
phoneNumber: '+15550000000',
65+
}
66+
67+
it('does not filter by values saved under Create or Update User', () => {
68+
const query = listUsersUrl(
69+
canvasCall({ ...staleCreateUserInputs, operation: 'clerk_list_users' })
70+
)
71+
expect(query.has('username')).toBe(false)
72+
expect(query.has('external_id')).toBe(false)
73+
expect(query.has('phone_number')).toBe(false)
74+
})
75+
76+
it('filters by the List Users filter fields over stale same-named values', () => {
77+
const query = listUsersUrl(
78+
canvasCall({
79+
...staleCreateUserInputs,
80+
operation: 'clerk_list_users',
81+
usernameFilter: 'alice',
82+
})
83+
)
84+
expect(query.getAll('username')).toEqual(['alice'])
85+
})
2286
})

‎apps/sim/blocks/blocks/clerk.ts‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ClerkIcon } from '@/components/icons'
22
import type { BlockConfig, BlockMeta } from '@/blocks/types'
33
import { AuthMode, IntegrationType } from '@/blocks/types'
4-
import { mapperOperation, withSavedCredential } from '@/blocks/utils'
4+
import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils'
55
import { getTrigger } from '@/triggers'
66

77
/**
@@ -849,13 +849,6 @@ export const ClerkBlock: BlockConfig = {
849849

850850
// Map UI fields to API params based on operation
851851
switch (operation) {
852-
case 'clerk_list_users':
853-
if (emailAddressFilter) cleanParams.emailAddress = emailAddressFilter
854-
if (usernameFilter) cleanParams.username = usernameFilter
855-
if (phoneNumberFilter) cleanParams.phoneNumber = phoneNumberFilter
856-
if (externalIdFilter) cleanParams.externalId = externalIdFilter
857-
if (userIdFilter) cleanParams.userId = userIdFilter
858-
break
859852
case 'clerk_create_user':
860853
case 'clerk_update_user':
861854
case 'clerk_create_organization_invitation':
@@ -919,6 +912,16 @@ export const ClerkBlock: BlockConfig = {
919912
}
920913
})
921914

915+
// List Users filters have dedicated subBlocks. The same-named raw keys can hold Create/Update
916+
// User values, so on the canvas they are cleared rather than forwarded as filters.
917+
if (operation === 'clerk_list_users') {
918+
cleanParams.emailAddress = emailAddressFilter || toolCallArg(context, rest.emailAddress)
919+
cleanParams.username = usernameFilter || toolCallArg(context, rest.username)
920+
cleanParams.phoneNumber = phoneNumberFilter || toolCallArg(context, rest.phoneNumber)
921+
cleanParams.externalId = externalIdFilter || toolCallArg(context, rest.externalId)
922+
cleanParams.userId = userIdFilter || toolCallArg(context, rest.userId)
923+
}
924+
922925
return cleanParams
923926
},
924927
},

‎apps/sim/blocks/blocks/crowdstrike.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ describe('CrowdStrike block params', () => {
138138
expect(merged.includeHidden).toBe(true)
139139
})
140140

141+
it('sends no status change when the status dropdown keeps the value the editor seeds', () => {
142+
const updateStatus = CrowdStrikeBlock.subBlocks.find(
143+
(subBlock) => subBlock.id === 'updateStatus'
144+
)
145+
const options = typeof updateStatus?.options === 'function' ? [] : (updateStatus?.options ?? [])
146+
const seeded = updateStatus?.value?.({}) ?? options[0]?.id
147+
148+
const merged = merge({
149+
...credentials,
150+
operation: 'crowdstrike_update_alerts',
151+
compositeIds: '["cid:aid:alert"]',
152+
appendComment: 'Reviewed',
153+
updateStatus: seeded,
154+
})
155+
156+
expect(merged.appendComment).toBe('Reviewed')
157+
expect(merged.updateStatus).toBeUndefined()
158+
})
159+
141160
it('still sends false when the analyst turns the hidden-alert switch off', () => {
142161
const merged = merge({
143162
...credentials,

‎apps/sim/blocks/blocks/crowdstrike.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,22 @@ export const CrowdStrikeBlock: BlockConfig = {
446446
},
447447
},
448448
{
449+
/**
450+
* Leads with "No change" because the editor seeds an empty dropdown with
451+
* its first option: an update that only comments, tags, or assigns must
452+
* not also send `update_status`.
453+
*/
449454
id: 'updateStatus',
450455
title: 'Status',
451456
type: 'dropdown',
452457
options: [
458+
{ label: 'No change', id: '' },
453459
{ label: 'New', id: 'new' },
454460
{ label: 'In Progress', id: 'in_progress' },
455461
{ label: 'Reopened', id: 'reopened' },
456462
{ label: 'Closed', id: 'closed' },
457463
],
464+
value: () => '',
458465
condition: { field: 'operation', value: 'crowdstrike_update_alerts' },
459466
},
460467
{

‎apps/sim/blocks/blocks/infisical.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ export const InfisicalBlock: BlockConfig = {
267267
description:
268268
'Secret object from get/create/update/delete operations (id, secretKey, secretValue, secretComment, secretPath, version, type, environment, isRotatedSecret, rotationId, tags, secretMetadata, actor, createdAt, updatedAt)',
269269
},
270+
approval: {
271+
type: 'json',
272+
description:
273+
'Pending change request (id, policyId, slug, status, hasMerged, folderId, createdAt, updatedAt) returned by create/update/delete instead of the secret when the environment has a secret approval policy',
274+
},
270275
},
271276
}
272277

‎apps/sim/blocks/blocks/ketch.test.ts‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22
import { KetchBlock } from '@/blocks/blocks/ketch'
3+
import { invokeRightTool } from '@/tools/ketch/invoke_right'
4+
import { setConsentTool } from '@/tools/ketch/set_consent'
35

46
const buildParams = KetchBlock.tools.config?.params
57
if (!buildParams) throw new Error('KetchBlock has no params mapper')
@@ -22,4 +24,48 @@ describe('KetchBlock', () => {
2224
analytics: { allowed: 'granted' },
2325
})
2426
})
27+
28+
/**
29+
* Ketch records any `allowed` other than the string "true" as denied, so a granted
30+
* consent written as "granted" (the value this integration used to document) must be sent as "true".
31+
*/
32+
it('sends a granted consent as allowed "true"', () => {
33+
const buildBody = setConsentTool.request.body
34+
if (!buildBody) throw new Error('set consent has no body builder')
35+
const body = buildBody({
36+
organizationCode: 'org',
37+
propertyCode: 'web',
38+
environmentCode: 'production',
39+
identities: { email: 'a@example.com' },
40+
purposes: {
41+
analytics: { allowed: 'granted', legalBasisCode: 'consent_optin' },
42+
marketing: { allowed: 'denied', legalBasisCode: 'consent_optin' },
43+
},
44+
collectedAt: 1,
45+
})
46+
47+
expect(body.purposes).toEqual({
48+
analytics: { allowed: 'true', legalBasisCode: 'consent_optin' },
49+
marketing: { allowed: 'false', legalBasisCode: 'consent_optin' },
50+
})
51+
})
52+
53+
it('surfaces the message of a Ketch error envelope', async () => {
54+
const transform = invokeRightTool.transformResponse
55+
if (!transform) throw new Error('invoke right has no response transform')
56+
const response = new Response(
57+
JSON.stringify({
58+
error: {
59+
code: 'invalid',
60+
message: 'user is required for unauthenticated right invocations',
61+
status: 400,
62+
},
63+
}),
64+
{ status: 400 }
65+
)
66+
67+
const result = await transform(response)
68+
69+
expect(result.output.message).toBe('user is required for unauthenticated right invocations')
70+
})
2571
})

‎apps/sim/blocks/blocks/ketch.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export const KetchBlock: BlockConfig = {
119119
title: 'Purposes',
120120
type: 'code',
121121
placeholder:
122-
'{"analytics": {"allowed": "granted", "legalBasisCode": "consent_optin"}, "marketing": {"allowed": "denied"}}',
122+
'{"analytics": {"allowed": "true", "legalBasisCode": "consent_optin"}, "marketing": {"allowed": "false", "legalBasisCode": "consent_optin"}}',
123123
language: 'json',
124124
condition: { field: 'operation', value: 'set_consent' },
125125
required: { field: 'operation', value: 'set_consent' },
@@ -160,7 +160,7 @@ export const KetchBlock: BlockConfig = {
160160
placeholder: '{"email": "user@example.com", "firstName": "John", "lastName": "Doe"}',
161161
language: 'json',
162162
condition: { field: 'operation', value: 'invoke_right' },
163-
mode: 'advanced',
163+
required: { field: 'operation', value: 'invoke_right' },
164164
},
165165
{
166166
id: 'collectedAt',
@@ -256,7 +256,7 @@ export const KetchBlock: BlockConfig = {
256256
},
257257
outputs: {
258258
purposes: { type: 'json', description: 'Consent status per purpose (allowed, legalBasisCode)' },
259-
vendors: { type: 'json', description: 'Vendor consent statuses' },
259+
vendors: { type: 'json', description: 'TCF vendor IDs returned with the consent record' },
260260
topics: {
261261
type: 'json',
262262
description: 'Subscription topic statuses per contact method',

‎apps/sim/lib/internal/onepassword/client.test.ts‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ vi.mock('dns/promises', () => ({
1414
}))
1515
vi.mock('@/lib/core/security/input-validation.server', () => inputValidationMock)
1616

17-
import { connectRequest } from '@/lib/internal/onepassword/client'
17+
import type { VaultOverview } from '@1password/sdk'
18+
import { connectRequest, normalizeSdkVault } from '@/lib/internal/onepassword/client'
1819

1920
const { mockSecureFetchWithPinnedIP: mockSecureFetch, mockValidateUrlWithDNS } =
2021
inputValidationMockFns
@@ -53,3 +54,31 @@ describe('connectRequest', () => {
5354
})
5455
})
5556
})
57+
58+
describe('normalizeSdkVault', () => {
59+
it('maps the service-account vault overview instead of placeholder values', () => {
60+
const vault = {
61+
id: 'vault-1',
62+
title: 'Engineering',
63+
description: 'Shared engineering secrets',
64+
vaultType: 'transfer',
65+
activeItemCount: 12,
66+
contentVersion: 7,
67+
attributeVersion: 3,
68+
createdAt: new Date('2026-01-01T00:00:00Z'),
69+
updatedAt: new Date('2026-02-01T00:00:00Z'),
70+
} as unknown as VaultOverview
71+
72+
expect(normalizeSdkVault(vault)).toEqual({
73+
id: 'vault-1',
74+
name: 'Engineering',
75+
description: 'Shared engineering secrets',
76+
attributeVersion: 3,
77+
contentVersion: 7,
78+
items: 12,
79+
type: 'TRANSFER',
80+
createdAt: '2026-01-01T00:00:00.000Z',
81+
updatedAt: '2026-02-01T00:00:00.000Z',
82+
})
83+
})
84+
})

0 commit comments

Comments
 (0)