fix(e2e): bound release user journey JSON artifacts
Some checks failed
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / (push) Has been cancelled
CI / -1 (push) Has been cancelled
CI / -2 (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / -3 (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / -4 (push) Has been cancelled
CI / -5 (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / -6 (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled

This commit is contained in:
Vincent Koc 2026-06-07 12:45:32 +02:00
parent 3753c5e2c8
commit 66b91d78fe
No known key found for this signature in database
2 changed files with 50 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import { readTextFileTail } from "../text-file-utils.mjs";
const SCAN_CHUNK_BYTES = 64 * 1024;
const SCAN_CARRY_CHARS = 256;
const ERROR_DETAIL_TAIL_BYTES = 16 * 1024;
const JSON_ARTIFACT_MAX_BYTES = 2 * 1024 * 1024;
function clickClackHttpTimeoutMs() {
return readPositiveInt(
@ -31,8 +32,30 @@ function clickClackHttpBodyMaxBytes() {
);
}
function readJson(file) {
return JSON.parse(fs.readFileSync(file, "utf8"));
function readJson(file, maxBytes = JSON_ARTIFACT_MAX_BYTES) {
const stat = fs.statSync(file);
if (!stat.isFile()) {
throw new Error(`${file} is not a file`);
}
if (stat.size > maxBytes) {
throw new Error(
`JSON artifact exceeded ${maxBytes} bytes: ${file} (${stat.size} bytes). Tail: ${readTextFileTail(
file,
ERROR_DETAIL_TAIL_BYTES,
)}`,
);
}
const text = fs.readFileSync(file, "utf8");
const bytes = Buffer.byteLength(text, "utf8");
if (bytes > maxBytes) {
throw new Error(
`JSON artifact exceeded ${maxBytes} bytes: ${file} (${bytes} bytes). Tail: ${readTextFileTail(
file,
ERROR_DETAIL_TAIL_BYTES,
)}`,
);
}
return JSON.parse(text);
}
function readPositiveInt(raw, fallback, label) {

View file

@ -137,6 +137,31 @@ describe("release user journey assertions", () => {
}
});
it("rejects oversized JSON artifacts before parsing release user journey config", () => {
const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-"));
const home = path.join(root, "home");
const configPath = path.join(home, ".openclaw", "openclaw.json");
try {
mkdirSync(path.dirname(configPath), { recursive: true });
writeFileSync(
configPath,
`DO_NOT_DUMP_OLD_JSON${"x".repeat(2 * 1024 * 1024)}\nrecent json tail`,
"utf8",
);
const result = runAssertion(home, ["configure-mock-model", "18080"]);
expect(result.status).not.toBe(0);
expect(result.stderr).toContain("JSON artifact exceeded");
expect(result.stderr).toContain("recent json tail");
expect(result.stderr).not.toContain("DO_NOT_DUMP_OLD_JSON");
expect(result.stderr.length).toBeLessThan(80 * 1024);
} finally {
rmSync(root, { force: true, recursive: true });
}
});
it("fails when uninstall leaves the managed plugin directory behind", () => {
const root = mkdtempSync(path.join(tmpdir(), "openclaw-release-user-assertions-"));
const home = path.join(root, "home");