Files
rea/src/application/frida/FridaInstrumentationPort.ts
T
4481f86188 fix(frida): drain admitted operations and honor queued cancellation (#2305)
* fix(frida): drain admitted operations and honor queued cancellation

* fix(frida): settle cancelled loads before queued resume

* test(frida): share lifecycle fixtures without duplicating assertions

* fix(frida): preserve operation admission before session close

* test(apple): bound cold archive fixture compilation

* fix(frida): retain cancelled script creation evidence

* test(release): scope preflight schema to selected jobs

* fix(process): report no remaining time after a provider deadline fires

Node timers can fire while performance.now() is still a fraction of a
millisecond short of the monotonic deadline. ProviderStartupDeadline then
reported interruption "timeout" and an aborted signal while remainingMs()
returned ceil(0.x) = 1, so polling loops guarded by remainingMs() > 0
(Hopper and Ghidra startup) could run past an elapsed deadline, and the
real-timer test "aborts a bounded wait when its real monotonic deadline
expires" failed intermittently in CI (expected 1 to be 0).

Once the deadline's own timer has classified a timeout, report zero
remaining time. A deterministic regression test fires the timer with the
monotonic clock 0.4 ms short of the deadline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(comparison): recheck historical calls-only changes (#2223)

* fix(comparison): preserve incomplete function call evidence

Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty.

Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls.

* fix(comparison): recheck historical calls-only changes

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
(cherry picked from commit 688defca0f)

* fix(ci): isolate Linux Hopper process fixture inventory

(cherry picked from commit 8cac51e12184d56a9ba80a4427b3e6082ddac1ec)

* fix(android): make DEX descriptor pattern portable

(cherry picked from commit 1335bcddc569a1cfb34b6efedcb6f2e3aaaa3357)

* fix: repair the static-check failures on the default branch (#2895)

* fix: repair the static-check failures on the default branch

The default branch fails its own required `Static checks` job three ways, so
every pull request reports that job as failed regardless of its own change.

- `npm run format:check` reports `src/domain/functionComparison.test.ts` and
  `src/ida/IdaOperationRunner.ts`.
- `npm run lint` reports a duplicate `import { join } from "node:path"` in
  `tests/boundary/mcp/ghidraInventoryMcp.test.ts` (lines 4 and 17).
- `npm run typecheck` reports `format: "devin"` missing from the client format
  union in `src/application/SupportedClients.ts`, and an unchecked index in
  `tests/boundary/cli/clientProfileLifecycle.test.ts`, whose pair array is
  inferred as `string[][]`.

Apply the pinned formatter, drop the duplicate import, list the `"devin"` format
that its own definition already uses, and mark the pair array `as const`.

Validation: `npm run check:fast` and `npm run format:check` pass.

* fix(setup): keep Devin on the JSON configuration dialect

---------

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
(cherry picked from commit df3d96da80)

---------

Co-authored-by: morluto <morluto@users.noreply.github.com>
Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: Lucien <164857476+dakjdakd@users.noreply.github.com>
Co-authored-by: 吴佳浩Alben <35291372+XiaoBinGan@users.noreply.github.com>
Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
2026-10-14 02:56:00 +08:00

137 lines
3.9 KiB
TypeScript

import type {
AnalysisError,
AnalysisErrorOptions,
} from "../../domain/analysisErrorBase.js";
import { AnalysisCancelledError } from "../../domain/analysisErrorCore.js";
import type { OptionalProviderLoadFailure } from "../OptionalObservationProviders.js";
import type { JsonValue } from "../../domain/jsonValue.js";
import type { Result } from "../../domain/result.js";
export interface FridaRemoteConnection {
readonly address: string;
readonly token?: string;
readonly certificate?: string;
readonly origin?: string;
readonly keepaliveInterval?: number;
}
export interface FridaDeviceSelector {
readonly deviceId?: string;
readonly remote?: FridaRemoteConnection;
}
export interface FridaDeviceObservation {
readonly deviceId: string;
readonly name: string;
readonly type: string;
}
export interface FridaProcessObservation {
readonly pid: number;
readonly name: string;
readonly identifier: string | null;
}
export type StartFridaSessionInput = FridaDeviceSelector &
(
| { readonly mode: "attach"; readonly pid: number }
| {
readonly mode: "spawn";
readonly program: string;
readonly argv?: readonly string[];
}
);
export type FridaScriptSource =
| { readonly sourceKind: "inline"; readonly source: string }
| { readonly sourceKind: "file"; readonly path: string };
export interface FridaSessionObservation {
readonly sessionId: string;
readonly deviceId: string;
readonly target: string;
readonly pid: number;
readonly mode: "attach" | "spawn";
readonly state: "paused" | "running" | "detached";
}
export interface FridaScriptObservation {
readonly scriptId: string;
readonly sourceKind: "inline" | "file";
readonly sourcePath: string | null;
readonly sourceSha256: string;
readonly messages: readonly JsonValue[];
readonly messagesTruncated: boolean;
}
export class FridaScriptLoadCancelledError extends AnalysisCancelledError {
constructor(
readonly script: FridaScriptObservation,
options?: AnalysisErrorOptions,
) {
super("load_frida_script", options);
}
}
export interface FridaSessionStatus extends FridaSessionObservation {
/** True only after REA has successfully resumed this spawned target. */
readonly targetResumeObserved: boolean;
readonly scripts: readonly {
readonly scriptId: string;
readonly name: string;
}[];
readonly messages: readonly JsonValue[];
readonly messagesTruncated: boolean;
}
export interface FridaSessionCleanupObservation {
readonly targetResumeObserved: boolean;
}
/** Shared application boundary for Frida runtime instrumentation workflows. */
export interface FridaInstrumentationPort {
availabilityFailure?(): OptionalProviderLoadFailure | undefined;
listDevices(remote?: FridaRemoteConnection): Promise<
Result<
{
readonly devices: readonly FridaDeviceObservation[];
readonly cleanupError: string | null;
},
AnalysisError
>
>;
listProcesses(selector: FridaDeviceSelector): Promise<
Result<
{
readonly deviceId: string;
readonly processes: readonly FridaProcessObservation[];
readonly cleanupError: string | null;
},
AnalysisError
>
>;
startSession(
input: StartFridaSessionInput,
): Promise<Result<FridaSessionObservation, AnalysisError>>;
/** Own cancellation and new-script cleanup before returning a final load outcome. */
loadScript(
sessionId: string,
source: FridaScriptSource,
signal?: AbortSignal,
): Promise<Result<FridaScriptObservation, AnalysisError>>;
resumeSession(
sessionId: string,
signal?: AbortSignal,
): Promise<Result<null, AnalysisError>>;
unloadScript(
sessionId: string,
scriptId: string,
signal?: AbortSignal,
): Promise<Result<null, AnalysisError>>;
status(sessionId: string): FridaSessionStatus | undefined;
closeSession(
sessionId: string,
): Promise<Result<FridaSessionCleanupObservation, AnalysisError>>;
closeAll(): Promise<void>;
}