fix: red-team round 3 hardening across desktop, mobile, core and server

Batch of red-team r3 fixes that were in the working tree before the
2026-09-28 design overhaul, committed as one unit with their tests.

- desktop main: STT timeouts and sidecar, voice recording store, sync
  (credentials, audio, knowledge reindex, push gates), runtime
  provisioner, update policy, AltGr keybindings, voice-command policy,
  dictionary file codec/limits, meeting transcript condensing and a
  local recording ledger so interrupted-session recovery only closes
  meetings this device recorded (a phone's live meeting is left alone).
- mobile: login CSRF via implicit token callbacks rejected, account
  deletion/retention, durable queue retention, knowledge realtime
  without unfiltered DELETE, meeting re-record failure paths, cloud STT
  client, preferences store/resync.
- core: text chunking splits long unbroken transcripts to fit, template
  field policy, dictionary limits, meeting markdown inline handling.
- server: payple webhook policy and cancellation order scope, meeting
  document generation quota, team RPC null-role guard, unified LLM
  quota in-flight accounting, knowledge chunk vector index, meeting
  re-record failure paths (migrations 20260929*).
- ci: portable/runtime feed gates, update-policy schema, Forgejo file
  delete and alias planning.

Four older tests are updated to the new contracts rather than the old
behavior: token-pair auth callbacks are rejected, knowledge realtime no
longer subscribes to DELETE, long transcript lines are split, and
meeting recovery requires the local recording ledger for empty rows.
This commit is contained in:
Yun Chan 2026-09-28 20:45:52 +09:00
parent 2428ede03d
commit ba9ef9741e
161 changed files with 17056 additions and 2379 deletions

View file

@ -217,7 +217,17 @@ export function isWithinRollout(
return rolloutBucket(deviceId, version) < percentage
}
/** 알 수 없는 JSON을 검증·정규화해 정책으로 만든다. 실패 필드는 기본값 유지. */
/**
* 알 수 없는 JSON을 검증·정규화해 정책으로 만든다.
*
* 없는 필드와 형식이 틀린 일반 필드는 기본값을 유지한다. 단 안전 필드는 값이 있는데
* 형식이 틀리면 가장 보수적인 값으로 읽는다(fail-closed) — 예전에는 `"killSwitch": "true"`
* 나 `"stagingPercentage": "5"` 같은 오타가 킬 스위치 꺼짐·100% 배포로 조용히 바뀌어
* 운영자 의도와 정반대로 동작했다.
* - killSwitch : boolean 이 아니면 true (업데이트 중단)
* - stagingPercentage : 정수가 아니면 0 (아무에게도 배포하지 않음; 필수 업데이트는 무관)
* 게시 전 엄격한 검증은 scripts/ci/lib/update-policy-schema.mjs 가 맡는다.
*/
export function parseUpdatePolicy(raw: unknown): UpdatePolicy {
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return DEFAULT_UPDATE_POLICY
const record = raw as Record<string, unknown>
@ -244,8 +254,14 @@ export function parseUpdatePolicy(raw: unknown): UpdatePolicy {
}
if (Number.isSafeInteger(record.stagingPercentage)) {
policy.stagingPercentage = Math.min(100, Math.max(0, record.stagingPercentage as number))
} else if (record.stagingPercentage !== undefined) {
policy.stagingPercentage = 0
}
if (typeof record.killSwitch === 'boolean') {
policy.killSwitch = record.killSwitch
} else if (record.killSwitch !== undefined) {
policy.killSwitch = true
}
if (typeof record.killSwitch === 'boolean') policy.killSwitch = record.killSwitch
if (record.channels && typeof record.channels === 'object' && !Array.isArray(record.channels)) {
const channels = record.channels as Record<string, unknown>