fix: security hardening + performance refactoring (code review batch 1)
- IDOR fix: deliberation vote now verifies juryMemberId === ctx.user.id - Rate limiting: tRPC middleware (100/min), AI endpoints (5/hr), auth IP-based (10/15min) - 6 compound indexes added to Prisma schema - N+1 eliminated in processRoundClose (batch updateMany/createMany) - N+1 eliminated in batchCheckRequirementsAndTransition (3 batch queries) - Service extraction: juror-reassignment.ts (578 lines) - Dead code removed: award.ts, cohort.ts, decision.ts (680 lines) - 35 bare catch blocks replaced across 16 files - Fire-and-forget async calls fixed - Notification false positive bug fixed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -902,7 +902,9 @@ export const fileRouter = router({
|
||||
entityId: requirement.id,
|
||||
detailsJson: { name: input.name, roundId: input.roundId },
|
||||
})
|
||||
} catch {}
|
||||
} catch (err) {
|
||||
console.error('[File] Audit log failed:', err)
|
||||
}
|
||||
|
||||
return requirement
|
||||
}),
|
||||
@@ -938,7 +940,9 @@ export const fileRouter = router({
|
||||
entityId: id,
|
||||
detailsJson: data,
|
||||
})
|
||||
} catch {}
|
||||
} catch (err) {
|
||||
console.error('[File] Audit log failed:', err)
|
||||
}
|
||||
|
||||
return requirement
|
||||
}),
|
||||
@@ -961,7 +965,9 @@ export const fileRouter = router({
|
||||
entityType: 'FileRequirement',
|
||||
entityId: input.id,
|
||||
})
|
||||
} catch {}
|
||||
} catch (err) {
|
||||
console.error('[File] Audit log failed:', err)
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
}),
|
||||
@@ -1594,7 +1600,8 @@ export const fileRouter = router({
|
||||
try {
|
||||
await client.statObject(bucket, objectKey)
|
||||
results[objectKey] = true
|
||||
} catch {
|
||||
} catch (err) {
|
||||
console.error('Failed to stat MinIO object during existence check:', err)
|
||||
results[objectKey] = false
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user