






















@@ -26,6 +26,19 @@ export async function packageBuildCommitFromTgz(tgzPath: string): Promise<string
2626return info.commit ?? "";
2727}
282829+function resolveNpmPackTarballFilename(value: unknown): string {
30+const filename = typeof value === "string" ? value.trim() : "";
31+if (
32+!filename.endsWith(".tgz") ||
33+filename.includes("\0") ||
34+filename !== path.basename(filename) ||
35+filename !== path.win32.basename(filename)
36+) {
37+die("npm pack did not report a safe tarball filename");
38+}
39+return filename;
40+}
41+2942export function resolveOpenClawRegistryVersion(specOrAlias: string): string {
3043const rawValue = specOrAlias.trim();
3144const value = rawValue.startsWith("openclaw@") ? rawValue.slice("openclaw@".length) : rawValue;
@@ -139,11 +152,8 @@ export async function packOpenClaw(input: {
139152],
140153{ quiet: true },
141154).stdout;
142-const packed = JSON.parse(output).at(-1)?.filename as string | undefined;
143-if (!packed) {
144-die("npm pack did not report a filename");
145-}
146-const tgzPath = path.join(input.destination, path.basename(packed));
155+const packed = resolveNpmPackTarballFilename(JSON.parse(output).at(-1)?.filename);
156+const tgzPath = path.join(input.destination, packed);
147157const version = await packageVersionFromTgz(tgzPath);
148158say(`Packed ${tgzPath}`);
149159say(`Target package version: ${version}`);
@@ -170,10 +180,7 @@ export async function packOpenClaw(input: {
170180quiet: true,
171181},
172182).stdout;
173-const packed = JSON.parse(output).at(-1)?.filename as string | undefined;
174-if (!packed) {
175-die("npm pack did not report a filename");
176-}
183+const packed = resolveNpmPackTarballFilename(JSON.parse(output).at(-1)?.filename);
177184const tgzPath = path.join(input.destination, `openclaw-main-${shortHead}.tgz`);
178185await copyFile(path.join(input.destination, packed), tgzPath);
179186const buildCommit = await packageBuildCommitFromTgz(tgzPath);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。