实现示例

type Repo = { name: string; urls: string[]; sha256: string }

const allowOrigins = new Set<string>(['https://mirror.example.com','https://github.com'])

function hex64(h: string): boolean { return /^[A-Fa-f0-9]{64}$/.test(h) }
function urlAllowed(u: string): boolean { try { const x = new URL(u); return x.protocol === 'https:' && allowOrigins.has(x.origin) } catch { return false } }

function evaluate(r: Repo): { ok: boolean; errors: string[] } {
  const errors: string[] = []
  if (!r.name || !hex64(r.sha256)) errors.push('entry')
  if (r.urls.length === 0 || !r.urls.every(urlAllowed)) errors.push('urls')
  return { ok: errors.length === 0, errors }
}

审计与运行治理

  • 审计外部仓库 URL 与哈希;异常阻断并输出修复建议。
  • 镜像清单变更需审批与归档。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部