Skip to content

Commit 80337c4

Browse files
committed
fix(connectors): address parallel audit findings
- servicenow: case-insensitive sys_id pattern; validate workflowState/incidentState/incidentPriority as numeric, kbCategory via allowlist - salesforce: include 400 in userinfo host fallthrough for sandbox tokens - zendesk: add missing 'new' and 'hold' options to ticketStatus dropdown
1 parent cb4e2c8 commit 80337c4

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

apps/sim/connectors/salesforce/salesforce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ async function fetchUserinfo(
102102

103103
// Only fall through to the next host on auth-shaped failures; surface
104104
// other errors (e.g. 5xx) immediately so we don't mask real problems.
105-
if (response.status !== 401 && response.status !== 403) {
105+
if (response.status !== 400 && response.status !== 401 && response.status !== 403) {
106106
break
107107
}
108108
}

apps/sim/connectors/servicenow/servicenow.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ const PAGE_SIZE = 100
2020
* fetches (`/api/now/table/{table}/{sys_id}`) likewise treat the sys_id as a
2121
* URL path segment and must be constrained to safe characters.
2222
*/
23-
const SYS_ID_PATTERN = /^[a-f0-9]{32}$/
23+
const SYS_ID_PATTERN = /^[a-f0-9]{32}$/i
24+
const NUMERIC_ID_PATTERN = /^\d+$/
25+
const KB_CATEGORY_PATTERN = /^[\w \-./]+$/
2426

2527
interface ServiceNowRecord {
2628
sys_id: string
@@ -363,18 +365,22 @@ function buildKBQuery(sourceConfig: Record<string, unknown>): string {
363365

364366
const workflowState = sourceConfig.workflowState as string | undefined
365367
if (workflowState && workflowState !== 'all') {
366-
parts.push(`workflow_state=${workflowState}`)
368+
if (NUMERIC_ID_PATTERN.test(workflowState)) {
369+
parts.push(`workflow_state=${workflowState}`)
370+
} else {
371+
logger.warn('Skipping workflowState filter: value is not a numeric ID', { workflowState })
372+
}
367373
}
368374

369375
const kbCategory = sourceConfig.kbCategory as string | undefined
370376
const trimmedCategory = kbCategory?.trim()
371377
if (trimmedCategory) {
372-
if (trimmedCategory.includes('^')) {
373-
logger.warn('Skipping kbCategory filter: value contains "^" separator', {
378+
if (KB_CATEGORY_PATTERN.test(trimmedCategory)) {
379+
parts.push(`kb_category.label=${trimmedCategory}`)
380+
} else {
381+
logger.warn('Skipping kbCategory filter: value contains disallowed characters', {
374382
kbCategory: trimmedCategory,
375383
})
376-
} else {
377-
parts.push(`kb_category.label=${trimmedCategory}`)
378384
}
379385
}
380386

@@ -390,12 +396,22 @@ function buildIncidentQuery(sourceConfig: Record<string, unknown>): string {
390396

391397
const incidentState = sourceConfig.incidentState as string | undefined
392398
if (incidentState && incidentState !== 'all') {
393-
parts.push(`state=${incidentState}`)
399+
if (NUMERIC_ID_PATTERN.test(incidentState)) {
400+
parts.push(`state=${incidentState}`)
401+
} else {
402+
logger.warn('Skipping incidentState filter: value is not a numeric ID', { incidentState })
403+
}
394404
}
395405

396406
const incidentPriority = sourceConfig.incidentPriority as string | undefined
397407
if (incidentPriority && incidentPriority !== 'all') {
398-
parts.push(`priority=${incidentPriority}`)
408+
if (NUMERIC_ID_PATTERN.test(incidentPriority)) {
409+
parts.push(`priority=${incidentPriority}`)
410+
} else {
411+
logger.warn('Skipping incidentPriority filter: value is not a numeric ID', {
412+
incidentPriority,
413+
})
414+
}
399415
}
400416

401417
parts.push('ORDERBYDESCsys_updated_on')

apps/sim/connectors/zendesk/zendesk.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,10 @@ export const zendeskConnector: ConnectorConfig = {
362362
description: 'Filter tickets by status (applies only when syncing tickets)',
363363
options: [
364364
{ label: 'All Statuses', id: 'all' },
365+
{ label: 'New', id: 'new' },
365366
{ label: 'Open', id: 'open' },
366367
{ label: 'Pending', id: 'pending' },
368+
{ label: 'On Hold', id: 'hold' },
367369
{ label: 'Solved', id: 'solved' },
368370
{ label: 'Closed', id: 'closed' },
369371
],

0 commit comments

Comments
 (0)