mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-09 03:22:40 +00:00
fix(testbox): reject unsafe Crabbox version tuples
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user