























@@ -215,6 +215,51 @@ describe("package-openclaw-for-docker", () => {
215215]);
216216});
217217218+it("rejects path-like npm pack stdout before resolving Docker package tarballs", async () => {
219+for (const filename of [
220+"../openclaw-2026.6.17.tgz",
221+"/tmp/openclaw-2026.6.17.tgz",
222+String.raw`C:\temp\openclaw-2026.6.17.tgz`,
223+"openclaw-nested/evil.tgz",
224+String.raw`openclaw-nested\evil.tgz`,
225+"openclaw-C:evil.tgz",
226+]) {
227+await expect(
228+packOpenClawPackageForDocker("/repo", "/out", {
229+prepareChangelog: async () => {},
230+restoreChangelog: async () => {},
231+runCaptureImpl: async () => `${filename}\n`,
232+}),
233+).rejects.toThrow("npm pack reported unsafe OpenClaw tarball filename");
234+}
235+});
236+237+it("ignores unsafe output directory tarball names when npm stdout is not usable", async () => {
238+const outputDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-docker-pack-"));
239+try {
240+fs.writeFileSync(path.join(outputDir, "openclaw-C:evil.tgz"), "");
241+fs.writeFileSync(path.join(outputDir, String.raw`openclaw-nested\evil.tgz`), "");
242+await expect(
243+packOpenClawPackageForDocker("/repo", outputDir, {
244+prepareChangelog: async () => {},
245+restoreChangelog: async () => {},
246+runCaptureImpl: async () => "npm notice\n",
247+}),
248+).rejects.toThrow("missing packed OpenClaw tarball");
249+250+fs.writeFileSync(path.join(outputDir, "openclaw-2026.6.17.tgz"), "");
251+await expect(
252+packOpenClawPackageForDocker("/repo", outputDir, {
253+prepareChangelog: async () => {},
254+restoreChangelog: async () => {},
255+runCaptureImpl: async () => "npm notice\n",
256+}),
257+).resolves.toBe(path.join(outputDir, "openclaw-2026.6.17.tgz"));
258+} finally {
259+fs.rmSync(outputDir, { recursive: true, force: true });
260+}
261+});
262+218263it("restores the changelog when ignore-scripts packaging fails", async () => {
219264const calls: string[] = [];
220265此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。