实现示例type CacheFile = { name: string; sha512?: string } function nameHasHash(n: string): boolean { return /@\d+\.\d+\.\d+-[A-Fa-f0-9]{64}\.zip$/.test(n) } function hex64(h?: string): boolean { return !!h && /^[A-Fa-f0-9]{128}$/.test(h) } function evaluate(list: CacheFile[]): { ok: boolean; errors: string[] } { const errors: string[] = []; for (const f of list) { if (!nameHasHash(f.name)) errors.push(`name:${f.name}`); if (f.sha512 && !hex64(f.sha512)) errors.push(`hash:${f.name}`) } return { ok: errors.length === 0, errors } } 审计与运行治理审计缓存文件名与哈希;不合规阻断并提示重新缓存与校验。零安装模式下仍需锁文件与一致性门禁。

发表评论 取消回复