Skip to content

Commit 7f3ddcb

Browse files
committed
fix(cloudflare): validate response envelopes and conditional inputs
1 parent cff2bdc commit 7f3ddcb

79 files changed

Lines changed: 123 additions & 96 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/cloudflare.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6596,7 +6596,7 @@ Permanently deletes a Cloudflare Access (Zero Trust) service token, revoking it.
65966596

65976597
### Cloudflare Rotate Access Service Token
65986598

6599-
Generates a new Client Secret for a service token and revokes the old one.
6599+
Generates a new Client Secret. The previous secret expires immediately unless previous_client_secret_expires_at schedules a later expiration.
66006600

66016601
#### Input
66026602

@@ -8767,7 +8767,7 @@ Updates a specific zone setting such as SSL mode, security level, cache level, o
87678767
| `enabled` | boolean | No | Enrollment value for ssl_recommender; this setting uses enabled instead of value |
87688768
| `zoneId` | string | Yes | The zone ID to update settings for |
87698769
| `settingId` | string | Yes | Setting to update \(e.g., "ssl", "security_level", "cache_level", "always_use_https", "browser_cache_ttl", "http3", "min_tls_version", "ciphers"\) |
8770-
| `value` | string | No | New value for the setting as a string, or a JSON string for complex values \(e.g., "full" for SSL, "medium" for security_level, "aggressive" for cache_level, \["ECDHE-RSA-AES128-GCM-SHA256"\] for ciphers\) |
8770+
| `value` | string | No | Required except for ssl_recommender. New value as a string, or a JSON string for complex values \(e.g., "full" for SSL, "medium" for security_level, "aggressive" for cache_level, \["ECDHE-RSA-AES128-GCM-SHA256"\] for ciphers\) |
87718771
| `apiKey` | string | Yes | Cloudflare API Token |
87728772

87738773
#### Output

‎apps/sim/tools/cloudflare/cloudflare.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,3 +1117,32 @@ describe('Cloudflare review regressions', () => {
11171117
expect(result.output.value).toBe(String(enabled))
11181118
})
11191119
})
1120+
1121+
describe('Cloudflare response envelopes and conditional inputs', () => {
1122+
it.each([undefined, null])('accepts confirmed group deletion with result %s', async (result) => {
1123+
const transform = cloudflareTools.cloudflareDeleteAccessGroupTool.transformResponse
1124+
if (!transform) throw new Error('Expected response transform')
1125+
const response = await transform(envelope(result))
1126+
expect(response.success).toBe(true)
1127+
expect(response.output.id).toBeNull()
1128+
})
1129+
1130+
it.each([undefined, null, 'true'])(
1131+
'rejects an Access list envelope with success %s',
1132+
async (success) => {
1133+
const transform = cloudflareTools.cloudflareListAccessApplicationsTool.transformResponse
1134+
if (!transform) throw new Error('Expected response transform')
1135+
const response = await transform(new Response(JSON.stringify({ success, result: [] })))
1136+
expect(response.success).toBe(false)
1137+
}
1138+
)
1139+
1140+
it.each([
1141+
{ settingId: 'ssl_recommender', field: 'enabled' },
1142+
{ settingId: 'ssl', field: 'value' },
1143+
])('rejects $settingId updates without $field', ({ settingId, field }) => {
1144+
const body = cloudflareTools.cloudflareUpdateZoneSettingTool.request.body
1145+
if (!body) throw new Error('Expected request body')
1146+
expect(() => body({ apiKey, zoneId: 'zone', settingId })).toThrow(field)
1147+
})
1148+
})

‎apps/sim/tools/cloudflare/create_access_application.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ export const createAccessApplicationTool: ToolConfig<
432432

433433
transformResponse: async (response: Response) => {
434434
const data = await readCloudflareResponse(response)
435-
const success = response.ok && data.success !== false && isRecordLike(data.result)
435+
const success = response.ok && data.success === true && isRecordLike(data.result)
436436
return {
437437
success,
438438
output: mapCloudflareFields(data.result, ACCESS_APPLICATION_OUTPUTS),

‎apps/sim/tools/cloudflare/create_access_group.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const createAccessGroupTool: ToolConfig<
8484
},
8585
transformResponse: async (response) => {
8686
const data = await readCloudflareResponse(response)
87-
const success = response.ok && data.success !== false && isRecordLike(data.result)
87+
const success = response.ok && data.success === true && isRecordLike(data.result)
8888
return {
8989
success,
9090
output: mapCloudflareFields(data.result, ACCESS_GROUP_OUTPUTS),

‎apps/sim/tools/cloudflare/create_access_policy.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export const createAccessPolicyTool: ToolConfig<
183183

184184
transformResponse: async (response: Response) => {
185185
const data = await readCloudflareResponse(response)
186-
const success = response.ok && data.success !== false && isRecordLike(data.result)
186+
const success = response.ok && data.success === true && isRecordLike(data.result)
187187
return {
188188
success,
189189
output: mapCloudflareFields(data.result, ACCESS_POLICY_OUTPUTS),

‎apps/sim/tools/cloudflare/create_access_service_token.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const createAccessServiceTokenTool: ToolConfig<
9494

9595
transformResponse: async (response: Response) => {
9696
const data = await readCloudflareResponse(response)
97-
const success = response.ok && data.success !== false && isRecordLike(data.result)
97+
const success = response.ok && data.success === true && isRecordLike(data.result)
9898
return {
9999
success,
100100
output: mapCloudflareFields(data.result, SERVICE_TOKEN_SECRET_OUTPUTS),

‎apps/sim/tools/cloudflare/create_dns_record.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const createDnsRecordTool: ToolConfig<
151151

152152
transformResponse: async (response: Response) => {
153153
const data = await readCloudflareResponse(response)
154-
const success = response.ok && data.success !== false && isRecordLike(data.result)
154+
const success = response.ok && data.success === true && isRecordLike(data.result)
155155
return {
156156
success,
157157
output: mapCloudflareFields(data.result, DNS_RECORD_OUTPUTS),

‎apps/sim/tools/cloudflare/create_r2_bucket.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const createR2BucketTool: ToolConfig<
8383

8484
transformResponse: async (response: Response) => {
8585
const data = await readCloudflareResponse(response)
86-
const success = response.ok && data.success !== false && isRecordLike(data.result)
86+
const success = response.ok && data.success === true && isRecordLike(data.result)
8787
return {
8888
success,
8989
output: mapCloudflareFields(data.result, R2_BUCKET_OUTPUTS),

‎apps/sim/tools/cloudflare/create_rate_limit_rule.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export const createRateLimitRuleTool: ToolConfig<
236236
const data = await readCloudflareResponse(response)
237237
const success =
238238
response.ok &&
239-
data.success !== false &&
239+
data.success === true &&
240240
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
241241
return {
242242
success,

‎apps/sim/tools/cloudflare/create_ruleset.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const createRulesetTool: ToolConfig<
108108
const data = await readCloudflareResponse(response)
109109
const success =
110110
response.ok &&
111-
data.success !== false &&
111+
data.success === true &&
112112
(isRecordLike(data.result) || (params?.dry_run === true && data.result === null))
113113
return {
114114
success,

0 commit comments

Comments
 (0)