@harrylabsj/kiwi 0.12.21 → 0.12.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -78,6 +78,46 @@ function recordIfVulnerable(pkgDir, name, out) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const root = process.env.npm_config_local_prefix || process.cwd();
|
|
81
|
+
|
|
82
|
+
// Node 下界守卫:随包依赖(undici 8.10.2、@earendil-works/pi-* 1.2.0)声明
|
|
83
|
+
// engines.node >=22.19.0。低版本 npm 默认只报 EBADENGINE 警告后继续安装,故障
|
|
84
|
+
// 会推迟到运行时(undici 8 需要 22.19+ 的运行时行为)。这里按**被安装包自己的**
|
|
85
|
+
// engines 显式 fail-closed,并给出固定错误码,便于平台/排障直接定位。
|
|
86
|
+
let enginesNode = "";
|
|
87
|
+
try {
|
|
88
|
+
enginesNode = String(
|
|
89
|
+
JSON.parse(readFileSync(path.join(root, "package.json"), "utf8")).engines?.node ?? "",
|
|
90
|
+
).trim();
|
|
91
|
+
} catch {
|
|
92
|
+
/* 没有可读的 package.json 时不额外约束(保持原有行为)。 */
|
|
93
|
+
}
|
|
94
|
+
if (enginesNode !== "") {
|
|
95
|
+
// 只支持单一下界 ">=X.Y" / ">=X.Y.Z"(后者语义更严,必须逐位比较 patch)。
|
|
96
|
+
// 复合范围(">=22.19.0 <23"、向上/波浪号、|| 等)不做近似解释,直接 fail-closed:
|
|
97
|
+
// 静默跳过或只比 major/minor 都会错误放行更低 patch。
|
|
98
|
+
const nodeFloor = /^>=\s*(\d+)\.(\d+)(?:\.(\d+))?$/.exec(enginesNode);
|
|
99
|
+
if (nodeFloor === null) {
|
|
100
|
+
console.error(
|
|
101
|
+
`[a106] NODE_ENGINE_UNSUPPORTED: engines.node=${JSON.stringify(enginesNode)}; ` +
|
|
102
|
+
'only a single lower bound ">=X.Y[.Z]" is supported. Rewrite the package engines ' +
|
|
103
|
+
"to that form instead of skipping the Node check.",
|
|
104
|
+
);
|
|
105
|
+
process.exit(1);
|
|
106
|
+
}
|
|
107
|
+
const need = [Number(nodeFloor[1]), Number(nodeFloor[2]), Number(nodeFloor[3] ?? "0")];
|
|
108
|
+
const current = process.versions.node.split(".").map(Number);
|
|
109
|
+
const atLeast = (a, b) =>
|
|
110
|
+
a[0] !== b[0] ? a[0] > b[0] : a[1] !== b[1] ? a[1] > b[1] : a[2] >= b[2];
|
|
111
|
+
if (!atLeast(current, need)) {
|
|
112
|
+
console.error(
|
|
113
|
+
`[a106] NODE_VERSION_UNSUPPORTED: package requires node ${enginesNode}, ` +
|
|
114
|
+
`current ${process.versions.node}; deploy on Node >=${need[0]}.${need[1]}.${need[2]} ` +
|
|
115
|
+
"(e.g. 22.19.0) instead of an older sandbox runtime.",
|
|
116
|
+
);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
81
121
|
const offenders = [];
|
|
82
122
|
for (const vuln of VULNERABLE) {
|
|
83
123
|
collectCopies(root, vuln.name, offenders);
|