Files
reverse-engineering-anything/src/javascript/recovery/WakaruVersion.ts
T
Pionxzhandmorluto ded59689ce fix(javascript): accept the Wakaru 1.x release line and verify 1.14.0 (#1540)
* fix(javascript): accept the Wakaru 1.x release line and verify 1.14.0

Exact --version equality rejected every Wakaru build except 1.13.0, and
strict report schemas rejected any added field, so each upstream release
broke recovery until REA re-pinned. Wakaru now documents that --version,
--json and provenance.json change only by addition within a major version.

Admit ^1.13.0 with the verified/compatible split used for Binwalk and
Unblob, report the observed version instead of the pinned constant, and
add a limitation for unverified releases. Parse reports with loose
objects and keep the reported module status as a string; path, identity,
range and file-set checks stay exact.

Move the audited pin, submodule, CI binary and verifier to 1.14.0, and
document where to get the binary from the refusal message.

* fix(javascript): project known Wakaru warning fields

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
2026-10-10 23:02:15 +08:00

40 lines
1.5 KiB
TypeScript

import { satisfies, valid } from "semver";
import { WAKARU_ACCEPTED_RANGE, WAKARU_RELEASE } from "./WakaruRelease.js";
/** Admission of one observed `wakaru --version` banner. */
export type WakaruVersionAdmission =
| { readonly status: "verified"; readonly version: string }
| {
readonly status: "compatible";
readonly version: string;
readonly limitation: string;
}
| { readonly status: "unsupported"; readonly message: string };
/** Caller-facing accepted releases, naming the verified build. */
export const wakaruReleaseLine = (): string =>
`Wakaru ${WAKARU_ACCEPTED_RANGE} (verified with ${WAKARU_RELEASE.version})`;
/** Classify a `wakaru <version>` banner against the accepted release range. */
export const admitWakaruVersion = (banner: string): WakaruVersionAdmission => {
const token = banner.startsWith("wakaru ")
? banner.slice("wakaru ".length)
: undefined;
if (
token === undefined ||
valid(token) !== token ||
!satisfies(token, WAKARU_ACCEPTED_RANGE)
)
return {
status: "unsupported",
message: `Unsupported Wakaru version ${banner.length === 0 ? "missing" : banner}; accepted releases are ${wakaruReleaseLine()}`,
};
if (token === WAKARU_RELEASE.version)
return { status: "verified", version: token };
return {
status: "compatible",
version: token,
limitation: `This session uses Wakaru ${token}. The report parser is verified against ${WAKARU_RELEASE.version}; other ${WAKARU_ACCEPTED_RANGE} releases are accepted and the observed version is reported.`,
};
};