Files
writer-work-flow/apps/web/lib/security/dependencyFloors.ts
Yaojia Wang f4c2c4e8ec fix(frontend): 升级 Next→15.5.20 + React 19.2.7 修 RCE/补丁 + 版本下界守卫(CR-C1)
- next/eslint-config-next 15.1.3→15.5.20(backport 安全维护线),react/react-dom 19.0.0→19.2.7
- @types/react(-dom) →^19.2.0;pnpm audit --prod 无 next/react/react-dom 高危/严重告警
- 新增 lib/security/dependencyFloors 守卫 + 回归测试锁定安全下界
- 连带修 useDraftStream.test noUncheckedIndexedAccess(重锁失效增量缓存后暴露,对齐 useReviewStream 既有 ! 约定)
2026-07-08 11:04:55 +02:00

31 lines
1.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 依赖安全下界守卫:锁定 next/react/react-dom 不得低于修补 RCE / 安全补丁的最低版本。
// dependencyFloors.test.ts 读取 package.json 声明版本比对回归防止误降级回易受攻击版本CR-C1
export const SECURITY_FLOORS = {
next: "15.5.20",
react: "19.2.7",
"react-dom": "19.2.7",
} as const;
// 语义版本比较version >= floor仅比对 major.minor.patch忽略预发布 / 构建元数据)。
// 去除前导 ^ / ~ 范围符;缺省段按 0 计;非数字段按 0 计。
export function isAtLeast(version: string, floor: string): boolean {
const a = parseSemver(version);
const b = parseSemver(floor);
for (let i = 0; i < 3; i += 1) {
const av = a[i] ?? 0;
const bv = b[i] ?? 0;
if (av > bv) return true;
if (av < bv) return false;
}
return true;
}
function parseSemver(raw: string): number[] {
const cleaned = raw.trim().replace(/^[\^~]/, "");
return cleaned.split(".").map((part) => {
const n = Number.parseInt(part, 10);
return Number.isNaN(n) ? 0 : n;
});
}