Skip to content

Commit 2d0bbdc

Browse files
committed
fix(audits): close review bypasses in source-conventions and record-coercion checks
1 parent 56b710e commit 2d0bbdc

8 files changed

Lines changed: 549 additions & 202 deletions

File tree

‎apps/sim/lib/billing/webhooks/enterprise.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { db } from '@sim/db'
33
import { foldedEmail, organization, outboxEvent, session, subscription, user } from '@sim/db/schema'
44
import { createLogger } from '@sim/logger'
55
import { generateId } from '@sim/utils/id'
6-
import { isRecordLike, toRecord } from '@sim/utils/object'
6+
import { toRecord } from '@sim/utils/object'
77
import { normalizeEmail } from '@sim/utils/string'
88
import { and, eq, inArray, sql } from 'drizzle-orm'
99
import type Stripe from 'stripe'
@@ -330,7 +330,7 @@ async function reconcileManualEnterpriseSubscription(
330330
}
331331

332332
const configOperationId = metadata.simConfigOperationId
333-
const existingMetadata = isRecordLike(existing?.metadata) ? existing.metadata : {}
333+
const existingMetadata = toRecord(existing?.metadata)
334334
const configurationAlreadyApplied =
335335
typeof configOperationId === 'string' &&
336336
configOperationId.length > 0 &&

‎apps/sim/lib/webhooks/providers/emailbison.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const emailBisonHandler: WebhookProviderHandler = {
190190
)
191191
}
192192

193-
const data = isRecordLike(responseBody?.data) ? responseBody.data : null
193+
const data = toRecordOrNull(responseBody?.data)
194194
const externalId = data?.id
195195
if (externalId === undefined || externalId === null || externalId === '') {
196196
throw new Error('Email Bison webhook was created but the API response did not include an ID.')

‎apps/sim/lib/webhooks/providers/slack.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { safeCompare } from '@sim/security/compare'
55
import { hmacSha256Hex } from '@sim/security/hmac'
66
import { toStringOrNull } from '@sim/utils/coerce'
77
import { toError } from '@sim/utils/errors'
8-
import { isRecordLike, toRecord } from '@sim/utils/object'
8+
import { isRecordLike, toRecord, toRecordOrNull } from '@sim/utils/object'
99
import { eq } from 'drizzle-orm'
1010
import { LRUCache } from 'lru-cache'
1111
import { NextResponse } from 'next/server'
@@ -1053,11 +1053,7 @@ export const slackHandler: WebhookProviderHandler = {
10531053
event.title = asString(rawEvent?.title)
10541054
event.previous_title = asString(rawEvent?.previous_title)
10551055
event.tab = asString(rawEvent?.tab)
1056-
event.context = isRecordLike(rawEvent?.context)
1057-
? rawEvent.context
1058-
: isRecordLike(rawEvent?.app_context)
1059-
? rawEvent.app_context
1060-
: null
1056+
event.context = toRecordOrNull(rawEvent?.context) ?? toRecordOrNull(rawEvent?.app_context)
10611057
event.team_id =
10621058
asString(b?.team_id) ||
10631059
asString(rawEvent?.team_id) ||

‎scripts/check-source-conventions.baseline.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@
215215
"apps/sim/lib/mothership/request/go/inline-images.test.ts": 1,
216216
"apps/sim/lib/mothership/request/handlers/complete.ts": 2,
217217
"apps/sim/lib/mothership/request/handlers/error.ts": 2,
218+
"apps/sim/lib/mothership/request/handlers/index.ts": 9,
218219
"apps/sim/lib/mothership/request/handlers/resource.ts": 1,
219220
"apps/sim/lib/mothership/request/handlers/run.ts": 2,
220221
"apps/sim/lib/mothership/request/handlers/session.ts": 1,
@@ -307,6 +308,7 @@
307308
"apps/sim/providers/gemini/core.ts": 1,
308309
"apps/sim/providers/gemini/streaming-tool-loop.ts": 2,
309310
"apps/sim/providers/openai/core.ts": 1,
311+
"apps/sim/providers/openai/index.ts": 1,
310312
"apps/sim/proxy.ts": 5,
311313
"apps/sim/scripts/copilot-messages-reconcile.ts": 1,
312314
"apps/sim/scripts/export-workflow.ts": 4,
@@ -521,7 +523,7 @@
521523
"apps/sim/app/(landing)/integrations/(shell)/page.tsx": 1,
522524
"apps/sim/app/(landing)/integrations/components/integration-card.tsx": 3,
523525
"apps/sim/app/(landing)/integrations/components/integration-grid.tsx": 1,
524-
"apps/sim/app/(landing)/integrations/components/integration-icon.tsx": 2,
526+
"apps/sim/app/(landing)/integrations/components/integration-icon.tsx": 1,
525527
"apps/sim/app/(landing)/integrations/components/request-integration-modal.tsx": 1,
526528
"apps/sim/app/(landing)/knowledge/components/feature-graphics/connector-sync-graphic.tsx": 3,
527529
"apps/sim/app/(landing)/knowledge/components/knowledge-product-previews/knowledge-product-previews.tsx": 1,
@@ -573,7 +575,7 @@
573575
"apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-editor/preview-editor.tsx": 1,
574576
"apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow/components/block/block.tsx": 2,
575577
"apps/sim/components/icons.tsx": 9,
576-
"apps/sim/content/blog/agent-as-yjs-peer/components/agent-peer-demo.tsx": 8,
578+
"apps/sim/content/blog/agent-as-yjs-peer/components/agent-peer-demo.tsx": 9,
577579
"apps/sim/content/blog/enterprise/components.tsx": 3,
578580
"apps/sim/content/blog/v0-5/components/diff-controls-demo.tsx": 5,
579581
"apps/sim/lib/content/mdx.tsx": 7

0 commit comments

Comments
 (0)