实现示例type GDep = { group: string; name: string; version: string; sha256?: string; repo: string } const allowRepos = new Set<string>(['https://repo1.maven.org','https://maven.example.com']) function hex64(h?: string): boolean { return !!h && /^[A-Fa-f0-9]{64}$/.test(h) } function validRepo(u: string): boolean { try { const x = new URL(u); return x.protocol === 'https:' && allowRepos.has(x.origin) } catch { return false } } function semverLike(v: string): boolean { return /^(\d+\.\d+\.\d+)(?:[-A-Za-z0-9_.]+)?$/.test(v) } function evaluate(list: GDep[]): { ok: boolean; errors: string[] } { const errors: string[] = [] for (const d of list) { if (!d.group || !d.name || !semverLike(d.version)) errors.push(`id:${d.group}:${d.name}`) if (!validRepo(d.repo)) errors.push(`repo:${d.group}:${d.name}`) if (d.sha256 && !hex64(d.sha256)) errors.push(`hash:${d.group}:${d.name}`) } return { ok: errors.length === 0, errors } } 审计与CI门禁审计仓库与版本、校验和;异常阻断并输出修复建议。锁定文件与版本对齐需审批与归档。

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论
立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部
1.732235s