实现示例function norm(p: string): string { return p.replace(/\\/g,'/').replace(/\/+/g,'/') }

function allowedPath(p: string, allowRoots: string[]): boolean {

const n = norm(p)

if (n.includes('..')) return false

if (/^\//.test(n)) return false

return allowRoots.some(r => n.startsWith(r.endsWith('/') ? r : r + '/'))

}

type Entry = { path: string; data: Uint8Array }

function filter(entries: Entry[], allowRoots: string[], allowExts: Set<string>): Entry[] {

const out: Entry[] = []

for (const e of entries) {

if (!allowedPath(e.path, allowRoots)) continue

const ext = (e.path.split('.').pop() || '').toLowerCase()

if (!allowExts.has(ext)) continue

out.push(e)

}

return out

}

审计与CI门禁审计记录包含被拒绝路径与文件扩展;异常阻断并输出证据。允许目录与扩展清单需审批与版本化管理。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部