Files
reverse-engineering-anything/src/firmware/FirmwareVersion.test.ts
T
morlutoandCursor Agent bef4321afb fix(firmware): accept the verified Binwalk and Unblob release lines (#844)
* fix(firmware): accept the verified Binwalk and Unblob release lines

Exact --version equality rejected every build except Binwalk 3.1.0 and
Unblob 26.6.4, then stored that constant as the observed engine version.
Admit the 3.1 and 26.6 lines, keep the audited build as verified, and
report the banner that actually ran.

* chore(docs): regenerate skill metadata after firmware contract text

docs:check failed because SKILL.md lagged the Binwalk/Unblob release-line
tool descriptions.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-10-07 12:19:28 +08:00

51 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { admitFirmwareVersion } from "./FirmwareVersion.js";
describe("firmware release lines", () => {
it("accepts the verified banners without an extra limitation", () => {
expect(admitFirmwareVersion("binwalk", "binwalk 3.1.0")).toEqual({
status: "verified",
version: "3.1.0",
});
expect(admitFirmwareVersion("unblob", "26.6.4")).toEqual({
status: "verified",
version: "26.6.4",
});
});
it.each([
["binwalk", "binwalk 3.1.2", "3.1.2"],
["binwalk", "binwalk 3.1.0-1", "3.1.0-1"],
["unblob", "26.6.5", "26.6.5"],
] as const)(
"accepts %s %s on the verified line",
(engine, banner, version) => {
const admitted = admitFirmwareVersion(engine, banner);
expect(admitted).toMatchObject({ status: "compatible", version });
if (admitted.status !== "compatible")
throw new Error("expected a compatible release");
expect(admitted.limitation).toContain(version);
expect(admitted.limitation).toContain(
engine === "binwalk" ? "3.1.0" : "26.6.4",
);
},
);
it.each([
["binwalk", "binwalk 3.2.0", "Binwalk 3.1.x"],
["binwalk", "unsupported", "Binwalk 3.1.x"],
["binwalk", "3.1.2", "Binwalk 3.1.x"],
["unblob", "26.7.0", "Unblob 26.6.x"],
["unblob", "unblob 26.6.4", "Unblob 26.6.x"],
["unblob", "", "missing"],
] as const)("rejects %s banner %j", (engine, banner, detail) => {
const admitted = admitFirmwareVersion(engine, banner);
expect(
admitted.status === "verified" || admitted.status === "compatible",
).toBe(false);
if (admitted.status === "verified" || admitted.status === "compatible")
throw new Error("expected a rejected banner");
expect(admitted.message).toContain(detail);
});
});