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

@ -5,17 +5,42 @@ const DEFAULT_TITLE = 'D3RO Voice'
const DEFAULT_BODY = '새 알림이 도착했습니다.'
const DEFAULT_TARGET_URL = '/app/dashboard'
function hasUnsafeUrlChars(value) {
for (let i = 0; i < value.length; i += 1) {
const code = value.charCodeAt(i)
if (code <= 0x1f || code === 0x7f || code === 0x5c) {
return true
}
}
return false
}
function sanitizeTargetUrl(rawUrl) {
if (typeof rawUrl !== 'string' || !rawUrl.trim()) {
if (typeof rawUrl !== 'string' || hasUnsafeUrlChars(rawUrl)) {
return DEFAULT_TARGET_URL
}
const trimmed = rawUrl.trim()
if (!trimmed.startsWith('/') || trimmed.startsWith('//') || trimmed.startsWith('/\\')) {
if (!trimmed || !trimmed.startsWith('/') || trimmed.startsWith('//')) {
return DEFAULT_TARGET_URL
}
return trimmed.startsWith('/app/') || trimmed === '/app'
const candidate = trimmed.startsWith('/app/') || trimmed === '/app'
? trimmed
: `/app${trimmed}`
if (candidate === '/app') {
return DEFAULT_TARGET_URL
}
if (candidate.startsWith('/app//')) {
return DEFAULT_TARGET_URL
}
try {
const parsed = new URL(candidate, 'https://d3ro.local')
if (parsed.origin !== 'https://d3ro.local' || !parsed.pathname.startsWith('/app/') || parsed.pathname.includes('//')) {
return DEFAULT_TARGET_URL
}
} catch {
return DEFAULT_TARGET_URL
}
return candidate
}
function parsePushPayload(event) {