fix(testbox): reject unsafe Crabbox version tuples

This commit is contained in:
Vincent Koc
2026-06-16 23:11:55 +02:00
parent 003d3100c3
commit 3576d1e967
2 changed files with 26 additions and 1 deletions

View File

@@ -199,12 +199,24 @@ function parseCrabboxVersion(value) {
if (!match) {
return null;
}
const tuple = match.slice(1, 4).map(parseVersionTuplePart);
if (tuple.some((part) => part === null)) {
return null;
}
return {
tuple: match.slice(1, 4).map((part) => Number.parseInt(part, 10)),
tuple,
suffix: match[4] ?? "",
};
}
function parseVersionTuplePart(value) {
if (!/^\d+$/u.test(value)) {
return null;
}
const parsed = Number(value);
return Number.isSafeInteger(parsed) ? parsed : null;
}
function compareVersionTuples(left, right) {
for (let index = 0; index < 3; index += 1) {
const diff = left[index] - right[index];

View File

@@ -449,6 +449,19 @@ describe.concurrent("scripts/crabbox-wrapper", () => {
expect(result.stderr).toContain("selected binary reported version=crabbox 0.22.0-rc.1");
});
it("rejects unsafe Crabbox version numbers at the Blacksmith minimum gate", () => {
const result = runWrapper(
"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",
["run", "--provider", "blacksmith-testbox", "--", "echo ok"],
{ env: { OPENCLAW_FAKE_CRABBOX_VERSION: "crabbox 0.9007199254740993.0" } },
);
expect(result.status).toBe(2);
expect(result.stderr).toContain(
"selected binary reported version=crabbox 0.9007199254740993.0",
);
});
it("accepts post-release Crabbox describe builds at the Blacksmith minimum boundary", () => {
const result = runWrapper(
"provider: hetzner, aws, local-container, blacksmith-testbox, or cloudflare\n",