Merge remote-tracking branch 'origin/main' into feat/pkg-inventory
# Conflicts: # docs/product-catalog.json # docs/verification/managed-conformance-manifest.json # skills/reverse-engineer-anything/SKILL.md # src/generatedMcpToolCatalog.ts
This commit is contained in:
@@ -70,6 +70,7 @@ it("reuses immutable engine state while keeping each Evidence observation separa
|
||||
|
||||
it("bounds output per operation across a retained session rather than accumulating earlier captures", async () => {
|
||||
const { service, apk, launches, provider } = await setup("large-manifest");
|
||||
const expectedManifest = "x".repeat(1024 * 1024);
|
||||
for (let index = 0; index < 34; index += 1) {
|
||||
const result = await service.execute("inspect_android_package", {
|
||||
path: apk,
|
||||
@@ -78,8 +79,8 @@ it("bounds output per operation across a retained session rather than accumulati
|
||||
expect(
|
||||
androidResultSchemas.inspect_android_package.parse(
|
||||
result.value.normalized_result,
|
||||
).manifest.text.length,
|
||||
).toBe(1024 * 1024);
|
||||
).manifest.text,
|
||||
).toBe(expectedManifest);
|
||||
}
|
||||
expect(launches).toHaveLength(1);
|
||||
await provider.close();
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import { EventEmitter } from "node:events";
|
||||
import { PassThrough } from "node:stream";
|
||||
import {
|
||||
serializeMessage,
|
||||
type JSONRPCMessage,
|
||||
} from "@modelcontextprotocol/client";
|
||||
import { expect, it } from "vitest";
|
||||
import type { ProviderProcessHandle } from "../../../src/process/ProviderProcess.js";
|
||||
import {
|
||||
JadxMcpTransport,
|
||||
type JadxLauncher,
|
||||
} from "../../../src/android/JadxMcpTransport.js";
|
||||
|
||||
class FixtureProcess extends EventEmitter implements ProviderProcessHandle {
|
||||
readonly pid = 1;
|
||||
readonly stdout = new PassThrough();
|
||||
readonly stdin = new PassThrough();
|
||||
readonly stderr = new PassThrough();
|
||||
readonly exitCode = null;
|
||||
readonly signalCode = null;
|
||||
|
||||
kill(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
it("decodes split UTF-8 and newline bytes, then routes multiple complete frames", async () => {
|
||||
const process = new FixtureProcess();
|
||||
const launcher: JadxLauncher = async ({ runId }) => ({
|
||||
process,
|
||||
ownership: {
|
||||
runId,
|
||||
leaderPid: process.pid,
|
||||
processGroupId: process.pid,
|
||||
expectedParentPid: process.pid,
|
||||
},
|
||||
cleanup: async () => {
|
||||
process.emit("exit", 0, null);
|
||||
process.emit("close", 0, null);
|
||||
process.stdout.end();
|
||||
process.stderr.end();
|
||||
process.stdin.end();
|
||||
return { cleaned: true, signaled: false };
|
||||
},
|
||||
});
|
||||
const transport = new JadxMcpTransport(
|
||||
{ command: "fixture", arguments: [] },
|
||||
launcher,
|
||||
);
|
||||
const received: JSONRPCMessage[] = [];
|
||||
transport.onmessage = (message) => received.push(message);
|
||||
|
||||
await transport.start();
|
||||
const first = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
result: { content: [{ type: "text", text: "snow 雪 🦊" }] },
|
||||
} satisfies JSONRPCMessage;
|
||||
const second = {
|
||||
jsonrpc: "2.0",
|
||||
id: 2,
|
||||
result: { content: [{ type: "text", text: "second" }] },
|
||||
} satisfies JSONRPCMessage;
|
||||
const third = {
|
||||
jsonrpc: "2.0",
|
||||
id: 3,
|
||||
result: { content: [{ type: "text", text: "third" }] },
|
||||
} satisfies JSONRPCMessage;
|
||||
for (const byte of Buffer.from(serializeMessage(first)))
|
||||
process.stdout.write(Buffer.from([byte]));
|
||||
process.stdout.write(
|
||||
Buffer.from(serializeMessage(second) + serializeMessage(third)),
|
||||
);
|
||||
|
||||
expect(received).toEqual([first, second, third]);
|
||||
await transport.close();
|
||||
});
|
||||
|
||||
it("accepts a complete JSON-RPC frame at the 8 MiB boundary", async () => {
|
||||
const process = new FixtureProcess();
|
||||
const launcher: JadxLauncher = async ({ runId }) => ({
|
||||
process,
|
||||
ownership: {
|
||||
runId,
|
||||
leaderPid: process.pid,
|
||||
processGroupId: process.pid,
|
||||
expectedParentPid: process.pid,
|
||||
},
|
||||
cleanup: async () => {
|
||||
process.emit("exit", 0, null);
|
||||
process.emit("close", 0, null);
|
||||
process.stdout.end();
|
||||
process.stderr.end();
|
||||
process.stdin.end();
|
||||
return { cleaned: true, signaled: false };
|
||||
},
|
||||
});
|
||||
const transport = new JadxMcpTransport(
|
||||
{ command: "fixture", arguments: [] },
|
||||
launcher,
|
||||
);
|
||||
const received: JSONRPCMessage[] = [];
|
||||
transport.onmessage = (message) => received.push(message);
|
||||
const response = {
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
result: { content: [{ type: "text", text: "" }] },
|
||||
} satisfies JSONRPCMessage;
|
||||
const emptyFrameBytes = Buffer.byteLength(serializeMessage(response)) - 1;
|
||||
const maxFrameResponse = {
|
||||
...response,
|
||||
result: {
|
||||
content: [
|
||||
{ type: "text", text: "x".repeat(8 * 1024 * 1024 - emptyFrameBytes) },
|
||||
],
|
||||
},
|
||||
} satisfies JSONRPCMessage;
|
||||
const frame = Buffer.from(serializeMessage(maxFrameResponse));
|
||||
|
||||
expect(frame.at(-1)).toBe(10);
|
||||
expect(frame.length - 1).toBe(8 * 1024 * 1024);
|
||||
await transport.start();
|
||||
process.stdout.write(frame);
|
||||
|
||||
expect(received).toEqual([maxFrameResponse]);
|
||||
await transport.close();
|
||||
});
|
||||
@@ -110,6 +110,32 @@ describe("ASAR path boundary", () => {
|
||||
});
|
||||
|
||||
describe("ASAR inventory freshness", () => {
|
||||
it("preserves missing-container I/O as an I/O failure instead of malformed format", async () => {
|
||||
const root = await createTestTempDirectory("rea-asar-missing-");
|
||||
const reader = new AsarArtifactReader(join(root, "missing.asar"));
|
||||
|
||||
await expect(
|
||||
reader.entries()[Symbol.asyncIterator]().next(),
|
||||
).rejects.toMatchObject({
|
||||
reason: "io",
|
||||
message: expect.stringContaining("ENOENT"),
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves an ASAR path replaced by a directory as a filesystem failure", async () => {
|
||||
const fixture = await archiveFixture();
|
||||
await rm(fixture.archive);
|
||||
await mkdir(fixture.archive);
|
||||
const reader = new AsarArtifactReader(fixture.archive);
|
||||
|
||||
await expect(
|
||||
reader.entries()[Symbol.asyncIterator]().next(),
|
||||
).rejects.toMatchObject({
|
||||
reason: "io",
|
||||
message: expect.stringContaining("EISDIR"),
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["archive", "bundle"] as const)(
|
||||
"refreshes a replaced archive when inventorying a %s target",
|
||||
async (target) => {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
ProviderProcessSupervisor,
|
||||
spawnOwnedProviderProcess,
|
||||
} from "../../../src/process/ProviderProcess.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
it.skipIf(process.platform === "win32")(
|
||||
"rejects a FIFO replacement without blocking the owner process",
|
||||
async () => {
|
||||
const root = await createTestTempDirectory("rea-directory-fifo-");
|
||||
await writeFile(join(root, "module.js"), "export {}\n");
|
||||
const probe = fileURLToPath(
|
||||
new URL("../../fixtures/directoryReaderFifoProbe.mjs", import.meta.url),
|
||||
);
|
||||
const readerModule = fileURLToPath(
|
||||
new URL(
|
||||
"../../../dist/artifacts/DirectoryArtifactReader.js",
|
||||
import.meta.url,
|
||||
),
|
||||
);
|
||||
const launch = await spawnOwnedProviderProcess({
|
||||
command: process.execPath,
|
||||
arguments: [probe, readerModule, root],
|
||||
runId: `rea-fifo-probe-${randomUUID()}`,
|
||||
cwd: tmpdir(),
|
||||
hostEnvironment: process.env,
|
||||
});
|
||||
const supervisor = new ProviderProcessSupervisor({
|
||||
...launch,
|
||||
ownsProcessLifetime: true,
|
||||
});
|
||||
|
||||
try {
|
||||
const closed = await supervisor.waitForOutputClose(2_000);
|
||||
expect(closed).toBe(true);
|
||||
expect(supervisor.snapshot().stdout.text.trim()).toBe("integrity");
|
||||
} finally {
|
||||
const stopped = await supervisor.stop({
|
||||
terminationGraceMs: 100,
|
||||
killGraceMs: 500,
|
||||
});
|
||||
expect(stopped.status).not.toBe("incomplete");
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -3,7 +3,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { PROCEDURES, inventory, jsonResult } from "./enhancedToolsHarness.js";
|
||||
|
||||
import type { AnalysisOperationPort } from "../../../src/application/AnalysisProvider.js";
|
||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../../../src/contracts/managedWorkflowToolContracts.js";
|
||||
import { MANAGED_WORKFLOW_TOOL_CONTRACTS } from "../../../src/contracts/managed/managedWorkflowToolContracts.js";
|
||||
import { ENHANCED_TOOL_CONTRACTS } from "../../../src/contracts/enhancedToolContracts.js";
|
||||
import { SESSION_TOOL_CONTRACTS } from "../../../src/contracts/sessionToolContracts.js";
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
|
||||
@@ -13,7 +13,7 @@ import { composeBinarySession } from "../../../src/application/binary/BinarySess
|
||||
import type { BinarySession } from "../../../src/application/binary/BinarySession.js";
|
||||
import type { BinaryTarget } from "../../../src/domain/binaryTarget.js";
|
||||
import { SessionProviderRouter } from "../../../src/application/binary/SessionProviderRouter.js";
|
||||
import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../src/contracts/managedWorkflowExamples.js";
|
||||
import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../src/contracts/managed/managedWorkflowExamples.js";
|
||||
import { ManagedStaticProvider } from "../../../src/dotnet/ManagedStaticProvider.js";
|
||||
import { createServer } from "../../../src/server/createServer.js";
|
||||
import { buildManagedPeFixture } from "../../../src/dotnet/ManagedPe.fixture.js";
|
||||
|
||||
@@ -6,6 +6,7 @@ import { z } from "zod";
|
||||
|
||||
import { TOOL_CONTRACTS } from "../../../src/contracts/toolContracts.js";
|
||||
import { emptyArraySchema } from "../../../src/domain/emptyArraySchema.js";
|
||||
import { processScenarioSchema } from "../../../src/domain/processScenario.js";
|
||||
import { GENERATED_MCP_TOOL_CATALOG } from "../../../src/generatedMcpToolCatalog.js";
|
||||
import { toolRegistrationOptions } from "../../../src/server/toolRegistrationOptions.js";
|
||||
|
||||
@@ -27,6 +28,76 @@ function schemaErrors(tools: readonly ToolSchemas[]): string[] {
|
||||
);
|
||||
}
|
||||
|
||||
const advertiseAndEnforceProcessEnvironmentKeyConstraint =
|
||||
async (): Promise<void> => {
|
||||
const contract = TOOL_CONTRACTS.find(
|
||||
({ name }) => name === "capture_process_scenario",
|
||||
);
|
||||
if (contract === undefined)
|
||||
throw new Error("Process capture contract was not registered");
|
||||
|
||||
let handlerCalled = false;
|
||||
const server = new McpServer({ name: "process-schema", version: "0" });
|
||||
server.registerTool(
|
||||
contract.name,
|
||||
{
|
||||
title: contract.title,
|
||||
description: contract.description,
|
||||
inputSchema: processScenarioSchema.shape,
|
||||
},
|
||||
async () => {
|
||||
handlerCalled = true;
|
||||
return {
|
||||
content: [{ type: "text" as const, text: "handler ran" }],
|
||||
isError: true,
|
||||
};
|
||||
},
|
||||
);
|
||||
const client = new Client({ name: "process-schema", version: "0" });
|
||||
const [clientTransport, serverTransport] =
|
||||
InMemoryTransport.createLinkedPair();
|
||||
try {
|
||||
await server.connect(serverTransport);
|
||||
await client.connect(clientTransport);
|
||||
const advertised = (await client.listTools()).tools.find(
|
||||
({ name }) => name === contract.name,
|
||||
);
|
||||
if (advertised === undefined)
|
||||
throw new Error("Process capture tool was not advertised");
|
||||
|
||||
const validate = new Ajv2020({
|
||||
strict: false,
|
||||
validateFormats: false,
|
||||
}).compile(advertised.inputSchema);
|
||||
const valid = { executable: "node", environment: { APP_MODE: "test" } };
|
||||
const reserved = {
|
||||
executable: "node",
|
||||
environment: { REA_PROCESS_RUN_ID: "caller-value" },
|
||||
};
|
||||
const reservedWithTrailingNewline = {
|
||||
executable: "node",
|
||||
environment: { "REA_PROCESS_RUN_ID\n": "caller-value" },
|
||||
};
|
||||
expect(validate(valid)).toBe(true);
|
||||
expect(contract.inputSchema.safeParse(valid).success).toBe(true);
|
||||
expect(validate(reserved)).toBe(false);
|
||||
expect(contract.inputSchema.safeParse(reserved).success).toBe(false);
|
||||
expect(validate(reservedWithTrailingNewline)).toBe(true);
|
||||
expect(
|
||||
contract.inputSchema.safeParse(reservedWithTrailingNewline).success,
|
||||
).toBe(true);
|
||||
|
||||
const result = await client.callTool({
|
||||
name: contract.name,
|
||||
arguments: reserved,
|
||||
});
|
||||
expect(result.isError).toBe(true);
|
||||
expect(handlerCalled).toBe(false);
|
||||
} finally {
|
||||
await Promise.allSettled([client.close(), server.close()]);
|
||||
}
|
||||
};
|
||||
|
||||
describe("MCP JSON Schema validity", () => {
|
||||
it("preserves empty-array validation in the advertised representation", () => {
|
||||
const schema = z.toJSONSchema(emptyArraySchema);
|
||||
@@ -154,3 +225,8 @@ describe("MCP JSON Schema validity", () => {
|
||||
expect(schemaErrors(GENERATED_MCP_TOOL_CATALOG)).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it(
|
||||
"advertises and enforces the process-owned environment key constraint",
|
||||
advertiseAndEnforceProcessEnvironmentKeyConstraint,
|
||||
);
|
||||
|
||||
@@ -8,12 +8,12 @@ import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js
|
||||
import {
|
||||
compareManagedMembersEvidenceValidated,
|
||||
compareManagedMemberPaths,
|
||||
} from "../../../../src/application/ManagedMemberComparisonService.js";
|
||||
} from "../../../../src/application/managed/ManagedMemberComparisonService.js";
|
||||
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
||||
import { managedMemberComparisonResultSchema } from "../../../../src/domain/managedMemberComparison.js";
|
||||
import { managedMemberComparisonResultSchema } from "../../../../src/domain/managed/managedMemberComparison.js";
|
||||
import { createEvidence } from "../../../../src/domain/evidence.js";
|
||||
import { jsonValueSchema } from "../../../../src/domain/jsonValue.js";
|
||||
import { compareManagedMembersInputSchema } from "../../../../src/domain/managedMemberComparison.js";
|
||||
import { compareManagedMembersInputSchema } from "../../../../src/domain/managed/managedMemberComparison.js";
|
||||
import { inspectManagedMembersBytes } from "../../../../src/dotnet/ManagedMemberInspector.js";
|
||||
import { managedPeFixtureTarget } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
import { buildManagedPeFixture } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
|
||||
@@ -5,7 +5,7 @@ import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
compareManagedMembers,
|
||||
managedMemberComparisonResultSchema,
|
||||
} from "../../../../src/domain/managedMemberComparison.js";
|
||||
} from "../../../../src/domain/managed/managedMemberComparison.js";
|
||||
import { inspectManagedMembersBytes } from "../../../../src/dotnet/ManagedMemberInspector.js";
|
||||
import {
|
||||
buildManagedPeFixture,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { compareManagedMembers } from "../../../../src/domain/managedMemberComparison.js";
|
||||
import { compareManagedMembers } from "../../../../src/domain/managed/managedMemberComparison.js";
|
||||
import { inspectManagedMembersBytes } from "../../../../src/dotnet/ManagedMemberInspector.js";
|
||||
import {
|
||||
buildManagedPeFixture,
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
managedArtifactInspectionSchema,
|
||||
managedMemberInspectionSchema,
|
||||
managedNativeBoundaryInspectionSchema,
|
||||
} from "../../../../src/domain/managedArtifact.js";
|
||||
} from "../../../../src/domain/managed/managedArtifact.js";
|
||||
import { ManagedStaticProvider } from "../../../../src/dotnet/ManagedStaticProvider.js";
|
||||
import { buildManagedPeFixture } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { projectManagedApplicationGraphEvidence } from "../../../src/application/ManagedApplicationGraphService.js";
|
||||
import { managedApplicationGraphReferenceInputSchema } from "../../../src/contracts/managedWorkflowToolContracts.js";
|
||||
import { MANAGED_APPLICATION_GRAPH_EXAMPLE } from "../../../src/contracts/managedWorkflowExamples.js";
|
||||
import { projectManagedApplicationGraphEvidence } from "../../../src/application/managed/ManagedApplicationGraphService.js";
|
||||
import { managedApplicationGraphReferenceInputSchema } from "../../../src/contracts/managed/managedWorkflowToolContracts.js";
|
||||
import { MANAGED_APPLICATION_GRAPH_EXAMPLE } from "../../../src/contracts/managed/managedWorkflowExamples.js";
|
||||
import { traceApplicationFeatureEvidence } from "../../../src/application/javascript/JavaScriptApplicationWorkflowService.js";
|
||||
import { MANAGED_STATIC_PROVIDER } from "../../../src/application/InvestigationProviders.js";
|
||||
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import { parseJavaScriptApplicationGraph } from "../../../src/domain/javascript/javascriptApplicationGraph.js";
|
||||
import { managedApplicationGraphResultSchema } from "../../../src/domain/managedApplicationGraph.js";
|
||||
import { managedApplicationGraphResultSchema } from "../../../src/domain/managed/managedApplicationGraph.js";
|
||||
import { inspectManagedArtifactBytes } from "../../../src/dotnet/ManagedArtifactInspector.js";
|
||||
import { inspectManagedMembersBytes } from "../../../src/dotnet/ManagedMemberInspector.js";
|
||||
import { inspectManagedNativeBoundariesBytes } from "../../../src/dotnet/ManagedNativeBoundaryInspector.js";
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
@interface ReaDispatchFixture : NSObject <ReaDispatchProtocol> {
|
||||
int state;
|
||||
}
|
||||
@property(nonatomic, copy) NSString *fixtureName;
|
||||
- (void)performAction:(id)sender;
|
||||
+ (int)fixtureVersion;
|
||||
@end
|
||||
@@ -16,4 +17,11 @@
|
||||
- (void)performAction:(id)sender { state += sender == nil ? 1 : 2; }
|
||||
+ (int)fixtureVersion { return 1; }
|
||||
@end
|
||||
|
||||
@interface NSString (ReaDispatchAdditions)
|
||||
- (NSUInteger)reaFixtureLength;
|
||||
@end
|
||||
@implementation NSString (ReaDispatchAdditions)
|
||||
- (NSUInteger)reaFixtureLength { return self.length; }
|
||||
@end
|
||||
int main(void) { return 0; }
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
let failed: ChildBatch<Int> = captureChildValues(requestedCount: 2) { nil }
|
||||
precondition(failed.values.isEmpty, "AX retrieval failure must return no values")
|
||||
precondition(!failed.complete, "AX retrieval failure must mark traversal incomplete")
|
||||
|
||||
let short = captureChildValues(requestedCount: 3) { [10, 20] }
|
||||
precondition(short.values == [10, 20], "Short retrieval must preserve returned children")
|
||||
precondition(!short.complete, "Short retrieval must mark traversal incomplete")
|
||||
var visited: [Int] = []
|
||||
for (index, value) in short.values.enumerated() {
|
||||
visited.append(index * 10 + value)
|
||||
}
|
||||
precondition(visited == [10, 30], "Traversal must use actual returned indices")
|
||||
|
||||
let complete = captureChildValues(requestedCount: 2) { [10, 20, 30] }
|
||||
precondition(complete.values == [10, 20], "Retrieval must respect the requested node budget")
|
||||
precondition(complete.complete, "A full bounded result must remain complete")
|
||||
|
||||
print("Native UI child retrieval seam passed")
|
||||
@@ -5,7 +5,7 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { buildManagedPeFixture } from "../../../../scripts/lib/managed-pe-fixture.mjs";
|
||||
import { buildManagedPeFixture } from "../../../../scripts/fixtures/managed/pe.mjs";
|
||||
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
||||
|
||||
const workspaces: string[] = [];
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { verifyManagedNativeBoundariesEvidence } from "../../../../src/application/ManagedNativeVerificationService.js";
|
||||
import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../../src/contracts/managedWorkflowExamples.js";
|
||||
import { verifyManagedNativeBoundariesEvidence } from "../../../../src/application/managed/ManagedNativeVerificationService.js";
|
||||
import { MANAGED_NATIVE_VERIFICATION_EXAMPLE } from "../../../../src/contracts/managed/managedWorkflowExamples.js";
|
||||
import { createEvidence } from "../../../../src/domain/evidence.js";
|
||||
import {
|
||||
managedNativeVerificationInputSchema,
|
||||
managedNativeVerificationResultSchema,
|
||||
verifyManagedNativeBoundaries,
|
||||
} from "../../../../src/domain/managedNativeVerification.js";
|
||||
import { managedNativeBoundaryInspectionSchema } from "../../../../src/domain/managedArtifact.js";
|
||||
} from "../../../../src/domain/managed/managedNativeVerification.js";
|
||||
import { managedNativeBoundaryInspectionSchema } from "../../../../src/domain/managed/managedArtifact.js";
|
||||
import { inspectMachoSchema } from "../../../../src/domain/nativeInspection.js";
|
||||
|
||||
const exampleInput = () =>
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { open, unlink } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
const [modulePath, root] = process.argv.slice(2);
|
||||
if (modulePath === undefined || root === undefined)
|
||||
throw new Error("Directory reader FIFO probe requires module and root paths");
|
||||
|
||||
const { DirectoryArtifactReader } = await import(pathToFileURL(modulePath));
|
||||
const reader = new DirectoryArtifactReader(root);
|
||||
let selected;
|
||||
for await (const entry of reader.entries())
|
||||
if (entry.path === "module.js") selected = entry;
|
||||
if (selected === undefined)
|
||||
throw new Error("Expected inventoried regular file");
|
||||
|
||||
const fifo = join(root, selected.path);
|
||||
await unlink(fifo);
|
||||
execFileSync("mkfifo", [fifo]);
|
||||
|
||||
const opening = reader.open(selected).then(
|
||||
(stream) => {
|
||||
stream.destroy();
|
||||
return "opened";
|
||||
},
|
||||
(cause) =>
|
||||
typeof cause === "object" && cause !== null && "reason" in cause
|
||||
? String(cause.reason)
|
||||
: "failed",
|
||||
);
|
||||
const outcome = await Promise.race([
|
||||
opening,
|
||||
new Promise((resolve) => setTimeout(() => resolve("blocked"), 100)),
|
||||
]);
|
||||
process.stdout.write(`${String(outcome)}\n`);
|
||||
|
||||
if (outcome === "blocked") {
|
||||
const writer = await open(fifo, "w");
|
||||
await writer.close();
|
||||
await opening;
|
||||
}
|
||||
await reader.close();
|
||||
Reference in New Issue
Block a user