fix(cloud): harden edge gateways, api-server ssrf, supabase fail-closed quota, and web/admin lifecycle

This commit is contained in:
Yun Chan 2026-11-14 15:10:32 +09:00
parent 2a009e421a
commit c68e81e0aa
46 changed files with 2553 additions and 294 deletions

View file

@ -18,6 +18,7 @@ import { handleCorsPreflightRequest } from '../_shared/cors.ts'
import { createStatusJsonResponder } from '../_shared/json-response.ts'
import {
type DictionaryHints,
MAX_STT_AUDIO_BYTES,
type NormalizedSttResult,
type SttFailureCode,
SttInputError,
@ -118,6 +119,7 @@ export async function runSttChain(
}
const json = createStatusJsonResponder()
const MAX_STT_MULTIPART_BYTES = MAX_STT_AUDIO_BYTES + 1024 * 1024
export function createSttProxyHandler(deps: SttProxyDeps): (req: Request) => Promise<Response> {
const { quota, logger } = deps
@ -137,7 +139,15 @@ export function createSttProxyHandler(deps: SttProxyDeps): (req: Request) => Pro
if (!auth.ok) return auth.response
const user = auth.user
// 2) input
// 2) input (reject oversized Content-Length before buffering multipart body)
const rawContentLength = req.headers.get('content-length')
if (rawContentLength !== null) {
const declaredBytes = Number(rawContentLength.trim())
if (Number.isFinite(declaredBytes) && declaredBytes > MAX_STT_MULTIPART_BYTES) {
return json(413, { error: 'audio_too_large' })
}
}
let formData: FormData
try {
formData = await req.formData()