Skip to content

Commit 9a21632

Browse files
committed
ran lint
1 parent c267afd commit 9a21632

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

apps/sim/app/api/tools/confluence/user/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export async function POST(request: NextRequest) {
3838
const accountIdValidation = validatePathSegment(accountId, {
3939
paramName: 'accountId',
4040
maxLength: 255,
41-
customPattern: /^[a-zA-Z0-9:\-]+$/,
41+
customPattern: /^[a-zA-Z0-9:-]+$/,
4242
})
4343
if (!accountIdValidation.isValid) {
4444
return NextResponse.json({ error: accountIdValidation.error }, { status: 400 })

apps/sim/socket/database/operations.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createLogger } from '@sim/logger'
44
import { and, eq, inArray, or, sql } from 'drizzle-orm'
55
import { drizzle } from 'drizzle-orm/postgres-js'
66
import postgres from 'postgres'
7+
import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
78
import { env } from '@/lib/core/config/env'
89
import { cleanupExternalWebhook } from '@/lib/webhooks/provider-subscriptions'
910
import { loadWorkflowFromNormalizedTables } from '@/lib/workflows/persistence/utils'
@@ -207,6 +208,17 @@ export async function persistWorkflowOperation(workflowId: string, operation: an
207208
}
208209
})
209210

211+
// Audit workflow-level lock/unlock operations
212+
if (
213+
target === OPERATION_TARGETS.BLOCKS &&
214+
op === BLOCKS_OPERATIONS.BATCH_TOGGLE_LOCKED &&
215+
userId
216+
) {
217+
auditWorkflowLockToggle(workflowId, userId).catch((error) => {
218+
logger.error('Failed to audit workflow lock toggle', { error, workflowId })
219+
})
220+
}
221+
210222
const duration = Date.now() - startTime
211223
if (duration > 100) {
212224
logger.warn('Slow socket DB operation:', {
@@ -226,6 +238,43 @@ export async function persistWorkflowOperation(workflowId: string, operation: an
226238
}
227239
}
228240

241+
/**
242+
* Records an audit log entry when all blocks in a workflow are locked or unlocked.
243+
* Only audits workflow-level transitions (all locked or all unlocked), not partial toggles.
244+
*/
245+
async function auditWorkflowLockToggle(workflowId: string, actorId: string): Promise<void> {
246+
const [wf] = await db
247+
.select({ name: workflow.name, workspaceId: workflow.workspaceId })
248+
.from(workflow)
249+
.where(eq(workflow.id, workflowId))
250+
251+
if (!wf) return
252+
253+
const blocks = await db
254+
.select({ locked: workflowBlocks.locked })
255+
.from(workflowBlocks)
256+
.where(eq(workflowBlocks.workflowId, workflowId))
257+
258+
if (blocks.length === 0) return
259+
260+
const allLocked = blocks.every((b) => b.locked)
261+
const allUnlocked = blocks.every((b) => !b.locked)
262+
263+
// Only audit workflow-level transitions, not partial toggles
264+
if (!allLocked && !allUnlocked) return
265+
266+
recordAudit({
267+
workspaceId: wf.workspaceId,
268+
actorId,
269+
action: allLocked ? AuditAction.WORKFLOW_LOCKED : AuditAction.WORKFLOW_UNLOCKED,
270+
resourceType: AuditResourceType.WORKFLOW,
271+
resourceId: workflowId,
272+
resourceName: wf.name,
273+
description: allLocked ? `Locked workflow "${wf.name}"` : `Unlocked workflow "${wf.name}"`,
274+
metadata: { blockCount: blocks.length },
275+
})
276+
}
277+
229278
async function handleBlockOperationTx(
230279
tx: any,
231280
workflowId: string,

0 commit comments

Comments
 (0)