fix: allow plugin state values up to 1 MiB (#130387)

* fix: allow plugin state values up to 1 MiB

* test: type-check plugin state write rejection cases

* fix(ci): keep tar archive paths local on Windows
This commit is contained in:
Peter Steinberger
2026-08-26 14:33:01 -07:00
committed by GitHub
parent fa87acd0b8
commit 820d167d21
5 changed files with 65 additions and 35 deletions
+28 -12
View File
@@ -641,12 +641,18 @@ export async function prepareBundledAiRuntimePackage(
((tarballPath: string, destination: string) =>
// Source-ref validation runs this trusted harness outside the candidate's dependency tree.
// Keep extraction on the system tar contract so only the candidate checkout needs install.
run("tar", ["-xzf", tarballPath, "-C", destination, "--strip-components=1"], destination, {
timeoutMs: resolveTimeoutMs(
"OPENCLAW_DOCKER_PACKAGE_PACK_TIMEOUT_MS",
DEFAULT_PACKAGE_PACK_TIMEOUT_MS,
),
}));
// Use an archive basename so GNU tar cannot treat a Windows drive as a remote host.
run(
"tar",
["-xzf", path.basename(tarballPath), "-C", destination, "--strip-components=1"],
path.dirname(tarballPath),
{
timeoutMs: resolveTimeoutMs(
"OPENCLAW_DOCKER_PACKAGE_PACK_TIMEOUT_MS",
DEFAULT_PACKAGE_PACK_TIMEOUT_MS,
),
},
));
const prepareManifest = packageOptions.prepareManifest ?? (async () => false);
const restoreManifest = packageOptions.restoreManifest ?? (async () => false);
const originalPackageJson = await fs.readFile(packageJsonPath, "utf8");
@@ -831,7 +837,12 @@ async function normalizeOpenClawTarballModes(tarballPath: string) {
);
const stageDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-package-modes-"));
try {
await run("tar", ["-xzf", tarballPath, "-C", stageDir], stageDir, { timeoutMs });
await run(
"tar",
["-xzf", path.basename(tarballPath), "-C", stageDir],
path.dirname(tarballPath),
{ timeoutMs },
);
let stagedFileCount = 0;
const normalizeStagedModes = async (dir: string): Promise<void> => {
for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
@@ -855,11 +866,16 @@ async function normalizeOpenClawTarballModes(tarballPath: string) {
const stageRootEntries = await fs.readdir(stageDir);
const normalizedPath = `${tarballPath}.modes-tmp`;
await fs.rm(normalizedPath, { force: true });
await run("tar", ["-czf", normalizedPath, "-C", stageDir, ...stageRootEntries], stageDir, {
// macOS bsdtar must not add AppleDouble (._*) sidecar entries.
env: { ...process.env, COPYFILE_DISABLE: "1" },
timeoutMs,
});
await run(
"tar",
["-czf", path.basename(normalizedPath), "-C", stageDir, ...stageRootEntries],
path.dirname(normalizedPath),
{
// macOS bsdtar must not add AppleDouble (._*) sidecar entries.
env: { ...process.env, COPYFILE_DISABLE: "1" },
timeoutMs,
},
);
await fs.rename(normalizedPath, tarballPath);
} finally {
await fs.rm(stageDir, { force: true, recursive: true });