Files
reverse-engineering-anything/src/cli/flutterCommands.ts
T
Adolanium 996ab6e2ae fix(zip): bound the member count of a ZIP inventory (#14997)
* fix(limits): admit a ZIP member count on reader limits

artifact.member_count now resolves artifact_limits.zip.member_count. Recorded Evidence from before this group may omit zip.

* fix(zip): refuse a central directory past the member count

Count every central-directory record before retaining it. The refusal omits required_value because later records stay unread.

* test(zip): cover a central directory past the member count

Three empty members at a count of two refuse through the reader and through the zip format reader.

* docs(limits): name zip.member_count on the member-count setting

The existing REA_ARTIFACT_MEMBER_COUNT seed already supplies that default.

* test(artifacts): select the ZIP member count with the explicit fields

The acceptance case ignores an invalid artifact.member_count seed only when every backed field is selected. zip.member_count is one of those fields.

* fix(schemas): record the ZIP member-count input summaries

extract_artifact and inspect_artifact changed their input compact schema when zip.member_count was advertised.

* fix(zip): keep member count on Flutter, Playwright, and SAZ

Those readers omitted the session count and described the refusal as a byte budget. They now admit artifact.member_count and report the count.

* test(zip): cover member-count refusals outside artifact inventory

A two-member archive at a session count of one stays a count for Flutter, Playwright traces, and SAZ. One member still passes that cap.

* docs(limits): name the ZIP consumers of artifact.member_count

Flutter APK inventory, Playwright trace import, and SAZ decoding use the session count and report it as a count.

* fix(capture): read the fixed-limit boundary from the ceiling

CaptureFormatError keeps that boundary on ceiling. The SAZ reply read cause.boundary, so a fixed-limit reply omitted the field the parent requires.

* fix(limits): recover ZIP member count through the session setting

Flutter, Playwright, and SAZ have no artifact_limits argument. The refusal names artifact.member_count, leaves parameter unset, and tells the caller to raise that setting. sessionSettingConstraint owns the error next to the other resource refusals.

* fix(android): keep a partial JNI report at the ZIP member count

readAndroidJniLibraries already returns a partial inventory when its entry allowance stops the scan. The session member count is that same stop. The reader takes artifact.member_count, and the report names the unexamined remainder instead of aborting the inspection.

* fix(zip): resolve the member count from the selected environment

ZIP admission and its refusal use the launch environment selected for the runtime. Only SAZ sends that count to the capture decoder.

* fix(zip): drop the unused ZipReaderLimits export

Knip reports the type because no caller imports it. ZIP limits stay on the schema.

* fix(playwright): return an invalid member-count seed as a result

The trace catch uses the count captured before the failure. A configuration error stays a Result and keeps the archive hash.

* fix(jni): name the member count on a partial library scan

The partial report keeps the count that stopped the scan and the recovery for artifact.member_count.

* fix(settings): register artifact.member_count for its ZIP consumers

Scoped inspection of the Flutter, Playwright, capture, and JNI operations includes the setting.

* test(artifacts): parse Evidence that omits the audit-log policy

The merged reader-limit schema still accepts a record that omits the Kubernetes audit-log policy.
2026-11-29 13:08:56 -05:00

95 lines
3.4 KiB
TypeScript

import type { RequestAnalysisPort } from "../ports/AnalysisProvider.js";
import type {
FlutterRequest,
FlutterOperation,
} from "../domain/flutter/flutterBuildAnalysis.js";
import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js";
import { withEvidenceCallerInputPath } from "../domain/evidence.js";
import { recognizeEvidence } from "../domain/evidenceValidation.js";
import { createFlutterBuildAnalysisService } from "../application/ProviderOperationServices.js";
import { createFlutterBuildAnalysisProvider } from "../composition/flutter.js";
import { FLUTTER_TOOL_CONTRACTS } from "../contracts/flutter/flutterToolContracts.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { contractNamed } from "./contractCliDescription.js";
import {
registerContractCommand,
type ContractCommandContext,
} from "./contractCommand.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
import { bindCliEvidenceCallerPath } from "./cliEvidenceCallerPath.js";
/** Expose the same explicit Flutter requests through one-shot CLI commands. */
export const registerFlutterCommands = (
cli: CliInstance,
logger: Logger,
environment: Readonly<Record<string, string | undefined>> = process.env,
provider: RequestAnalysisPort<FlutterRequest> = createFlutterBuildAnalysisProvider(
environment,
),
): void => {
/**
* Run one operation on the APK the caller selected, recording that spelling
* in Evidence, including a result completed before cleanup failed. The
* contract admits a relative path, resolved by the provider from the working
* directory, so the CLI passes it on as spelled.
*/
const run =
(operation: FlutterOperation) =>
(input: { readonly path: string }, { signal }: ContractCommandContext) =>
finishAnalysisCommand(
bindCliEvidenceCallerPath(input.path, () =>
createFlutterBuildAnalysisService(provider).execute(
operation,
input,
{
signal,
},
),
),
{ close: () => provider.close() },
"flutter",
operation,
signal,
undefined,
{
recoverCompletedObservation: (observation) => {
// Only authenticated Evidence is recovered; otherwise the error stands.
const parsed = recognizeEvidence(observation);
return parsed.ok && parsed.value !== undefined
? withEvidenceCallerInputPath(parsed.value, input.path)
: undefined;
},
},
).then(projectCliAnalysisResult);
registerContractCommand(
cli,
logger,
contractNamed(FLUTTER_TOOL_CONTRACTS, "identify_flutter_build"),
{
description:
"Identify a Flutter build's Dart snapshot hash and engine facts by pure APK parsing",
positionals: ["path"],
jsonText: ["apk_limits"],
},
run("identify_flutter_build"),
);
registerContractCommand(
cli,
logger,
contractNamed(FLUTTER_TOOL_CONTRACTS, "inspect_dart_aot"),
{
description:
"Inspect one ABI's Dart AOT snapshot: sections, headers, and the string pool",
positionals: ["path"],
jsonText: ["pool_policy", "apk_limits"],
omit: {
detail:
"The CLI returns complete Evidence; a summary needs a session that retains it for inspect_analysis_view",
},
},
run("inspect_dart_aot"),
);
};