feat: add Frida instrumentation support (#1359)
* feat: add Frida instrumentation support * fix: resolve Frida CI checks * test: cover Frida contract validation branches * docs: link Frida instrumentation guide * fix(frida): handle cancellation cleanup safely * fix(frida): address PR review findings * fix(frida): preserve resume and message observations * fix(ci): use canonical registry for rolldown * fix(frida): declare foreign code effects * fix(frida): retain failed startup resources for cleanup retries Keep failed startup session and spawn handles owned until detach, resume, and remote lease cleanup complete. Serialize retries and release each remote reference once. Await CLI provider cleanup while preserving the primary failure and any completed observations. Add regressions for retained startup resources, concurrent cleanup, shared remote leases, and CLI cleanup outcomes. Validation: 41 focused tests pass on the PR head and its latest-main integration; serial static and docs checks pass. Real Linux Frida 17.23.2 workflows and the native spawn/controlled-failure cleanup probe pass. Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) --------- Co-authored-by: N0zoM1z0 <1705004398@qq.com>
This commit is contained in:
co-authored by
N0zoM1z0
parent
0b7145361e
commit
4a4ae9b2b9
File diff suppressed because it is too large
Load Diff
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
declare module "frida" {
|
||||
export interface FridaMessage {
|
||||
readonly type: string;
|
||||
readonly payload?: unknown;
|
||||
readonly description?: string;
|
||||
readonly stack?: string;
|
||||
}
|
||||
|
||||
export type SignalHandler = (...args: never[]) => void;
|
||||
|
||||
export interface Signal<Handler extends SignalHandler> {
|
||||
connect(handler: Handler): void;
|
||||
disconnect(handler: Handler): void;
|
||||
}
|
||||
|
||||
export interface RemoteDeviceOptions {
|
||||
certificate?: string;
|
||||
origin?: string;
|
||||
token?: string;
|
||||
keepaliveInterval?: number;
|
||||
}
|
||||
|
||||
export interface SpawnOptions {
|
||||
argv?: string[];
|
||||
env?: Record<string, string>;
|
||||
envp?: Record<string, string>;
|
||||
cwd?: string;
|
||||
stdio?: "inherit" | "pipe";
|
||||
}
|
||||
|
||||
export interface Process {
|
||||
readonly pid: number;
|
||||
readonly name: string;
|
||||
}
|
||||
|
||||
export interface Script {
|
||||
readonly isDestroyed: boolean;
|
||||
readonly message: Signal<
|
||||
(message: FridaMessage, data: Buffer | null) => void
|
||||
>;
|
||||
load(): Promise<void>;
|
||||
unload(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
readonly pid: number;
|
||||
readonly detached: Signal<() => void>;
|
||||
isDetached(): boolean;
|
||||
createScript(
|
||||
source: string,
|
||||
options?: { readonly name?: string },
|
||||
): Promise<Script>;
|
||||
detach(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Device {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly type: string;
|
||||
enumerateProcesses(): Promise<Process[]>;
|
||||
getProcessByPid(pid: number): Promise<Process>;
|
||||
spawn(program: string, options?: SpawnOptions): Promise<number>;
|
||||
resume(pid: number): Promise<void>;
|
||||
attach(pid: number): Promise<Session>;
|
||||
}
|
||||
|
||||
export interface DeviceManager {
|
||||
enumerateDevices(): Promise<Device[]>;
|
||||
getDeviceById(id: string, timeout: number): Promise<Device>;
|
||||
addRemoteDevice(
|
||||
address: string,
|
||||
options?: RemoteDeviceOptions,
|
||||
): Promise<Device>;
|
||||
removeRemoteDevice(address: string): Promise<void>;
|
||||
}
|
||||
|
||||
export function getDeviceManager(): DeviceManager;
|
||||
}
|
||||
Reference in New Issue
Block a user