fix(FN-4638): align sandbox-exec logger calls and lint

Fusion-Task-Id: FN-4638
Fusion-Task-Lineage: a6dcc3d9-b7ab-42c1-af88-c9e09f770d92
This commit is contained in:
Fusion
2026-05-15 11:17:16 -07:00
committed by gsxdsm
parent 08dd73ee1e
commit cc15f194d3
3 changed files with 7 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ const { detectMock, policyToProfileMock, presetMock, nativeRunMock, nativePrepar
nativeRunMock: vi.fn(), nativeRunMock: vi.fn(),
nativePrepareMock: vi.fn(), nativePrepareMock: vi.fn(),
nativeDisposeMock: vi.fn(), nativeDisposeMock: vi.fn(),
loggerMock: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }, loggerMock: { log: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
execMock: vi.fn(), execMock: vi.fn(),
})); }));
@@ -53,7 +53,7 @@ describe("SandboxExecBackend", () => {
nativeDisposeMock.mockReset(); nativeDisposeMock.mockReset();
execMock.mockReset(); execMock.mockReset();
(execMock as unknown as Record<symbol, unknown>)[promisify.custom] = vi.fn(); (execMock as unknown as Record<symbol, unknown>)[promisify.custom] = vi.fn();
loggerMock.info.mockReset(); loggerMock.log.mockReset();
loggerMock.warn.mockReset(); loggerMock.warn.mockReset();
loggerMock.error.mockReset(); loggerMock.error.mockReset();
loggerMock.debug.mockReset(); loggerMock.debug.mockReset();
@@ -106,7 +106,7 @@ describe("SandboxExecBackend", () => {
expect(cmd).toContain("/bin/sh -c"); expect(cmd).toContain("/bin/sh -c");
expect(result.exitCode).toBe(0); expect(result.exitCode).toBe(0);
expect(result.stdout).toBe("ok"); expect(result.stdout).toBe("ok");
expect(loggerMock.info).toHaveBeenCalled(); expect(loggerMock.log).toHaveBeenCalled();
}); });
it("maps timeout and maxBuffer failures", async () => { it("maps timeout and maxBuffer failures", async () => {

View File

@@ -1,4 +1,4 @@
import { exec, type ExecOptions } from "node:child_process"; import { exec } from "node:child_process";
import { promisify } from "node:util"; import { promisify } from "node:util";
import type { SandboxBackend, SandboxCapabilities, SandboxPolicy, SandboxRunOptions, SandboxRunResult } from "./types.js"; import type { SandboxBackend, SandboxCapabilities, SandboxPolicy, SandboxRunOptions, SandboxRunResult } from "./types.js";

View File

@@ -97,7 +97,7 @@ export class SandboxExecBackend implements SandboxBackend {
tmpDirOverride: os.tmpdir(), tmpDirOverride: os.tmpdir(),
}; };
log.info("[event:sandbox:prepare] backend=sandbox-exec"); log.log("[event:sandbox:prepare] backend=sandbox-exec");
} }
async run(command: string, options: SandboxRunOptions): Promise<SandboxRunResult> { async run(command: string, options: SandboxRunOptions): Promise<SandboxRunResult> {
@@ -124,7 +124,7 @@ export class SandboxExecBackend implements SandboxBackend {
const profile = policyToSbplProfile(basePolicy, this.ctx); const profile = policyToSbplProfile(basePolicy, this.ctx);
const wrappedCommand = `sandbox-exec -p ${shEscape(profile)} /bin/sh -c ${shEscape(command)}`; const wrappedCommand = `sandbox-exec -p ${shEscape(profile)} /bin/sh -c ${shEscape(command)}`;
log.info(`[event:sandbox:run] backend=sandbox-exec cmd=${JSON.stringify(command)}`); log.log(`[event:sandbox:run] backend=sandbox-exec cmd=${JSON.stringify(command)}`);
try { try {
const execOptions: Parameters<typeof exec>[1] = { const execOptions: Parameters<typeof exec>[1] = {
@@ -146,7 +146,7 @@ export class SandboxExecBackend implements SandboxBackend {
timedOut: false, timedOut: false,
bufferExceeded: false, bufferExceeded: false,
}; };
log.info(`[event:sandbox:run] backend=sandbox-exec durationMs=${Date.now() - startedAt} exitCode=0`); log.log(`[event:sandbox:run] backend=sandbox-exec durationMs=${Date.now() - startedAt} exitCode=0`);
return result; return result;
} catch (error) { } catch (error) {
const errObj = error as Record<string, unknown>; const errObj = error as Record<string, unknown>;