feat: ZIP 경로 가드 추가 및 무결성 size 검증 도입 (TDD)

- buildZip에 경로 하드닝 추가: ../, 절대경로(/), 역슬래시(\) 금지
- assets.integrity.index.json에 size(byte) 필드 추가
- verifyIntegrity에서 size 불일치 검증 추가
- 경로/사이즈 검증 테스트 추가: zip.pathGuard.test.ts
- 전체 테스트 그린 유지
This commit is contained in:
2025-11-16 17:30:47 +09:00
parent cf8f02bfca
commit 7928f9b6c5
6 changed files with 275 additions and 1 deletions
+2 -1
View File
@@ -1,7 +1,7 @@
import type { AssetManager } from '@/lib/assets/assetManager'
export type AssetsIntegrityIndex = {
entries: Array<{ path: string; integrity: string }>
entries: Array<{ path: string; integrity: string; size: number }>
bundleHash: string
}
@@ -84,6 +84,7 @@ export function buildAssetsIntegrityIndex(am: AssetManager): Uint8Array {
const entries = am.list().map(ref => ({
path: ref.path,
integrity: `sha256-${sha256Base64(ref.bytes)}`,
size: ref.bytes.length,
}))
// 2) Sort entries by path for deterministic output
entries.sort((a, b) => a.path.localeCompare(b.path))