feat(android): integrate static APK analysis with headless JADX (#738)
* feat(android): integrate static APK analysis with headless JADX * test(android): include APK tools in explicit effects audit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { EventEmitter } from "node:events";
|
||||
import { expect, it } from "vitest";
|
||||
import {
|
||||
withCommandCancellation,
|
||||
type CommandCancellationHost,
|
||||
} from "../../../src/cli/commandCancellation.js";
|
||||
|
||||
it.each([
|
||||
["SIGINT", 130],
|
||||
["SIGTERM", 143],
|
||||
] as const)(
|
||||
"awaits cleanup after %s and removes its listeners",
|
||||
async (event, expectedExit) => {
|
||||
const events = new EventEmitter();
|
||||
const host: CommandCancellationHost = {
|
||||
on: events.on.bind(events),
|
||||
off: events.off.bind(events),
|
||||
};
|
||||
let cleaned = false;
|
||||
const operation = withCommandCancellation(async (signal) => {
|
||||
await new Promise<void>((resolve) =>
|
||||
signal.addEventListener("abort", () => resolve(), { once: true }),
|
||||
);
|
||||
cleaned = true;
|
||||
return "cancelled after cleanup";
|
||||
}, host);
|
||||
expect(host.exitCode).toBeUndefined();
|
||||
events.emit(event);
|
||||
expect(await operation).toBe("cancelled after cleanup");
|
||||
expect(cleaned).toBe(true);
|
||||
expect(host.exitCode).toBe(expectedExit);
|
||||
expect(events.listenerCount("SIGINT")).toBe(0);
|
||||
expect(events.listenerCount("SIGTERM")).toBe(0);
|
||||
},
|
||||
);
|
||||
|
||||
it("leaves the exit code alone on success and removes listeners when execution throws", async () => {
|
||||
const events = new EventEmitter();
|
||||
const host: CommandCancellationHost = {
|
||||
on: events.on.bind(events),
|
||||
off: events.off.bind(events),
|
||||
exitCode: 0,
|
||||
};
|
||||
expect(await withCommandCancellation(async () => "success", host)).toBe(
|
||||
"success",
|
||||
);
|
||||
expect(host.exitCode).toBe(0);
|
||||
await expect(
|
||||
withCommandCancellation(async () => {
|
||||
throw new Error("fixture failure");
|
||||
}, host),
|
||||
).rejects.toThrow("fixture failure");
|
||||
expect(events.listenerCount("SIGINT")).toBe(0);
|
||||
expect(events.listenerCount("SIGTERM")).toBe(0);
|
||||
});
|
||||
@@ -22,6 +22,7 @@ import { PLAYWRIGHT_BROWSER_SCENARIO_PROVIDER_IDENTITY } from "../../../src/brow
|
||||
import { V8_INSPECTOR_PROVIDER_IDENTITY } from "../../../src/browser/V8InspectorProvider.js";
|
||||
import { CLI_COMMAND_NAMES } from "../../../src/cliCommandNames.js";
|
||||
import { createCli } from "../../../src/cli.js";
|
||||
import { JADX_PROVIDER_IDENTITY } from "../../../src/android/JadxRelease.js";
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
import {
|
||||
HOPPER_PROVIDER_IDENTITY,
|
||||
@@ -71,6 +72,7 @@ describe("canonical product catalog", () => {
|
||||
expect(catalog.providers.map(({ id }) => id).sort()).toEqual(
|
||||
[
|
||||
HOPPER_PROVIDER_IDENTITY,
|
||||
JADX_PROVIDER_IDENTITY,
|
||||
GHIDRA_PROVIDER_IDENTITY,
|
||||
NATIVE_MACOS_PROVIDER_IDENTITY,
|
||||
ARTIFACT_GRAPH_PROVIDER,
|
||||
|
||||
Reference in New Issue
Block a user