frida-test 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -26
- package/bin/frida-test-compile.js +1 -1
- package/bin/frida-test.js +1 -1
- package/dist/host/bundler.d.ts.map +1 -0
- package/dist/{bundler.js → host/bundler.js} +12 -14
- package/dist/host/cli-frida-test-compiler.d.ts.map +1 -0
- package/dist/{cli-frida-test-compiler.js → host/cli-frida-test-compiler.js} +2 -2
- package/dist/host/cli-frida-test.d.ts.map +1 -0
- package/dist/{cli-frida-test.js → host/cli-frida-test.js} +10 -4
- package/dist/host/collector.d.ts.map +1 -0
- package/dist/host/collector.js +40 -0
- package/dist/host/device.d.ts +12 -0
- package/dist/host/device.d.ts.map +1 -0
- package/dist/host/device.js +19 -0
- package/dist/{logger.d.ts → host/logger.d.ts} +0 -2
- package/dist/host/logger.d.ts.map +1 -0
- package/dist/{logger.js → host/logger.js} +1 -3
- package/dist/host/protocol.d.ts.map +1 -0
- package/dist/host/protocol.js +12 -0
- package/dist/host/reporter/console.d.ts +4 -0
- package/dist/host/reporter/console.d.ts.map +1 -0
- package/dist/{reporter → host/reporter}/console.js +5 -9
- package/dist/host/reporter/json.d.ts.map +1 -0
- package/dist/host/reporter/summary.d.ts.map +1 -0
- package/dist/{reporter → host/reporter}/summary.js +6 -5
- package/dist/host/runner.d.ts.map +1 -0
- package/dist/{runner.js → host/runner.js} +20 -10
- package/dist/host/target.d.ts.map +1 -0
- package/dist/{target.js → host/target.js} +11 -6
- package/package.json +14 -8
- package/src/agent-runtime/expect.ts +5 -0
- package/src/agent-runtime/fridaTest.ts +9 -0
- package/src/agent-runtime/globals.d.ts +8 -4
- package/src/agent-runtime/globals.ts +10 -4
- package/src/agent-runtime/matchers.ts +102 -119
- package/src/agent-runtime/mock.ts +131 -0
- package/src/agent-runtime/modifiers.ts +102 -0
- package/src/agent-runtime/registry.ts +14 -3
- package/src/agent-runtime/spy.ts +30 -0
- package/dist/bundler.d.ts.map +0 -1
- package/dist/cli-frida-test-compiler.d.ts.map +0 -1
- package/dist/cli-frida-test.d.ts.map +0 -1
- package/dist/collector.d.ts.map +0 -1
- package/dist/collector.js +0 -27
- package/dist/device.d.ts +0 -28
- package/dist/device.d.ts.map +0 -1
- package/dist/device.js +0 -68
- package/dist/logger.d.ts.map +0 -1
- package/dist/protocol.d.ts.map +0 -1
- package/dist/protocol.js +0 -6
- package/dist/reporter/console.d.ts +0 -3
- package/dist/reporter/console.d.ts.map +0 -1
- package/dist/reporter/json.d.ts.map +0 -1
- package/dist/reporter/summary.d.ts.map +0 -1
- package/dist/runner.d.ts.map +0 -1
- package/dist/target.d.ts.map +0 -1
- /package/dist/{bundler.d.ts → host/bundler.d.ts} +0 -0
- /package/dist/{cli-frida-test-compiler.d.ts → host/cli-frida-test-compiler.d.ts} +0 -0
- /package/dist/{cli-frida-test.d.ts → host/cli-frida-test.d.ts} +0 -0
- /package/dist/{collector.d.ts → host/collector.d.ts} +0 -0
- /package/dist/{protocol.d.ts → host/protocol.d.ts} +0 -0
- /package/dist/{reporter → host/reporter}/json.d.ts +0 -0
- /package/dist/{reporter → host/reporter}/json.js +0 -0
- /package/dist/{reporter → host/reporter}/summary.d.ts +0 -0
- /package/dist/{runner.d.ts → host/runner.d.ts} +0 -0
- /package/dist/{target.d.ts → host/target.d.ts} +0 -0
package/dist/collector.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { readdir, stat } from "node:fs/promises";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
const TEST_FILE_SUFFIX = ".test.ts";
|
|
4
|
-
async function findTestFiles(absolutePath) {
|
|
5
|
-
let fileInfo;
|
|
6
|
-
try {
|
|
7
|
-
fileInfo = await stat(absolutePath);
|
|
8
|
-
}
|
|
9
|
-
catch (err) {
|
|
10
|
-
throw new Error(`Path does not exist: ${absolutePath}`, { cause: err });
|
|
11
|
-
}
|
|
12
|
-
if (fileInfo.isDirectory()) {
|
|
13
|
-
const entries = await readdir(absolutePath, {
|
|
14
|
-
recursive: true,
|
|
15
|
-
withFileTypes: true,
|
|
16
|
-
});
|
|
17
|
-
return entries.filter((entry) => entry.isFile() && entry.name.endsWith(TEST_FILE_SUFFIX)).map((entry) => join(entry.parentPath, entry.name));
|
|
18
|
-
}
|
|
19
|
-
if (absolutePath.endsWith(TEST_FILE_SUFFIX)) {
|
|
20
|
-
return [absolutePath];
|
|
21
|
-
}
|
|
22
|
-
throw new Error(`Not a *${TEST_FILE_SUFFIX} file: ${absolutePath}`);
|
|
23
|
-
}
|
|
24
|
-
export async function collectTestSuitePaths(srcPaths) {
|
|
25
|
-
const results = await Promise.all(srcPaths.map((p) => findTestFiles(resolve(p))));
|
|
26
|
-
return [...new Set(results.flat())].sort();
|
|
27
|
-
}
|
package/dist/device.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Device } from "frida";
|
|
2
|
-
export type DeviceSelector = "usb" | "local" | "remote" | {
|
|
3
|
-
id: string;
|
|
4
|
-
} | {
|
|
5
|
-
host: string;
|
|
6
|
-
certificate?: string;
|
|
7
|
-
origin?: string;
|
|
8
|
-
token?: string;
|
|
9
|
-
keepaliveInterval?: number;
|
|
10
|
-
};
|
|
11
|
-
export type TargetDef = {
|
|
12
|
-
file: string;
|
|
13
|
-
} | {
|
|
14
|
-
frontmost: true;
|
|
15
|
-
} | {
|
|
16
|
-
name: string;
|
|
17
|
-
} | {
|
|
18
|
-
identifier: string;
|
|
19
|
-
} | {
|
|
20
|
-
pid: number;
|
|
21
|
-
};
|
|
22
|
-
export declare function resolveDevice(selector?: DeviceSelector): Promise<Device>;
|
|
23
|
-
export interface Target {
|
|
24
|
-
pid: number;
|
|
25
|
-
wasSpawned: boolean;
|
|
26
|
-
}
|
|
27
|
-
export declare function resolveTarget(device: Device, targetDef: TargetDef): Promise<Target>;
|
|
28
|
-
//# sourceMappingURL=device.d.ts.map
|
package/dist/device.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../src/device.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGpC,MAAM,MAAM,cAAc,GACtB,KAAK,GACL,OAAO,GACP,QAAQ,GACR;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GACd;IACE,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEN,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7H,wBAAsB,aAAa,CAAC,QAAQ,GAAE,cAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAcvF;AAED,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDzF"}
|
package/dist/device.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import frida from "frida";
|
|
2
|
-
export async function resolveDevice(selector = "local") {
|
|
3
|
-
if (selector === "usb")
|
|
4
|
-
return frida.getUsbDevice();
|
|
5
|
-
if (selector === "local")
|
|
6
|
-
return frida.getLocalDevice();
|
|
7
|
-
if (selector === "remote")
|
|
8
|
-
return frida.getRemoteDevice();
|
|
9
|
-
if ("id" in selector)
|
|
10
|
-
return frida.getDevice(selector.id);
|
|
11
|
-
// Pass network parameters to addRemoteDevice
|
|
12
|
-
const manager = frida.getDeviceManager();
|
|
13
|
-
return manager.addRemoteDevice(selector.host, {
|
|
14
|
-
certificate: selector.certificate,
|
|
15
|
-
origin: selector.origin,
|
|
16
|
-
token: selector.token,
|
|
17
|
-
keepaliveInterval: selector.keepaliveInterval,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export async function resolveTarget(device, targetDef) {
|
|
21
|
-
if ("file" in targetDef) {
|
|
22
|
-
const file = targetDef.file.trim();
|
|
23
|
-
if (!file)
|
|
24
|
-
throw new Error("Target file/program must not be empty");
|
|
25
|
-
const pid = await device.spawn(file);
|
|
26
|
-
return { pid, wasSpawned: true };
|
|
27
|
-
}
|
|
28
|
-
if ("pid" in targetDef) {
|
|
29
|
-
return { pid: targetDef.pid, wasSpawned: false };
|
|
30
|
-
}
|
|
31
|
-
if ("frontmost" in targetDef) {
|
|
32
|
-
const app = await device.getFrontmostApplication();
|
|
33
|
-
if (!app) {
|
|
34
|
-
throw new Error("No frontmost application found on the target device");
|
|
35
|
-
}
|
|
36
|
-
return { pid: app.pid, wasSpawned: false };
|
|
37
|
-
}
|
|
38
|
-
if ("name" in targetDef) {
|
|
39
|
-
const targetName = targetDef.name.trim();
|
|
40
|
-
if (!targetName)
|
|
41
|
-
throw new Error("Target process name must not be empty");
|
|
42
|
-
const processes = await device.enumerateProcesses();
|
|
43
|
-
const needle = targetName.toLowerCase();
|
|
44
|
-
const tiers = [
|
|
45
|
-
processes.filter((p) => p.name === targetName),
|
|
46
|
-
processes.filter((p) => p.name.toLowerCase() === needle),
|
|
47
|
-
processes.filter((p) => p.name.toLowerCase().includes(needle)),
|
|
48
|
-
];
|
|
49
|
-
const matches = tiers.find((tier) => tier.length > 0) ?? [];
|
|
50
|
-
if (matches.length === 0) {
|
|
51
|
-
throw new Error(`No running process matching '${targetName}' was found.`);
|
|
52
|
-
}
|
|
53
|
-
if (matches.length > 1) {
|
|
54
|
-
const names = matches.map((p) => `${p.name} (pid ${p.pid})`).join(", ");
|
|
55
|
-
throw new Error(`Ambiguous process target '${targetName}', matches: ${names}`);
|
|
56
|
-
}
|
|
57
|
-
return { pid: matches[0].pid, wasSpawned: false };
|
|
58
|
-
}
|
|
59
|
-
const identifier = targetDef.identifier.trim();
|
|
60
|
-
if (!identifier)
|
|
61
|
-
throw new Error("Target identifier must not be empty");
|
|
62
|
-
const apps = await device.enumerateApplications();
|
|
63
|
-
const matchedApp = apps.find((a) => a.identifier === identifier);
|
|
64
|
-
if (!matchedApp || !matchedApp.pid || matchedApp.pid === 0) {
|
|
65
|
-
throw new Error(`Application '${identifier}' is not currently running.`);
|
|
66
|
-
}
|
|
67
|
-
return { pid: matchedApp.pid, wasSpawned: false };
|
|
68
|
-
}
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM;IACjB,UAAU,UAAU,OAAO;IAG3B,IAAI,QAAQ,MAAM;IAGlB,GAAG,QAAQ,MAAM;IACjB,IAAI,QAAQ,MAAM;IAClB,KAAK,QAAQ,MAAM;IACnB,OAAO,QAAQ,MAAM;CACtB,CAAC"}
|
package/dist/protocol.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,GACvB;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,qBAAqB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,eAAe,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;AAE7B,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,eAAe,EAAE,CAAC;CACtC"}
|
package/dist/protocol.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/reporter/console.ts"],"names":[],"mappings":"AACA,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA6BxF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAWjE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporter/json.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG5F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/reporter/summary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAcjD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CA+BzD"}
|
package/dist/runner.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAA4B,MAAM,OAAO,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,UAAU;IAQnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAV1B,OAAO,CAAC,OAAO,CAAC,CAAU;IAC1B,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,UAAU,CAAC,CAAQ;IAE3B,YACmB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAC/B;IAEJ,IAAI,YAAY,IAAI,SAAS,eAAe,EAAE,CAE7C;IAEK,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBhC;IAEK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CASpC;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAS7B;IAED,OAAO,CAAC,SAAS;CA6BlB"}
|
package/dist/target.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../src/target.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEpC,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC;CACrB;AACD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7H,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA4DzF"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|