feat: complete REA remediation program
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { access, chmod, mkdtemp, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { access, chmod, rm, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "./fixtures/temporaryDirectory.js";
|
||||
|
||||
import {
|
||||
type HopperApplicationLauncherOptions,
|
||||
linuxDemoLaunch,
|
||||
usesLinuxDemo,
|
||||
} from "../src/hopper/BridgeLauncher.js";
|
||||
|
||||
@@ -52,8 +54,77 @@ describe("Hopper bridge launcher selection", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("builds the namespace launch without sudo or a shell command", () => {
|
||||
const launch = linuxDemoLaunch(
|
||||
options("/opt/hopper/bin/Hopper"),
|
||||
{
|
||||
directory: "/tmp/rea-fixture",
|
||||
socketPath: "/tmp/rea-fixture/bridge.sock",
|
||||
token: "not-forwarded",
|
||||
runId: "fixture-run",
|
||||
},
|
||||
["--analysis"],
|
||||
"user-mount-namespace",
|
||||
);
|
||||
|
||||
expect(launch).toMatchObject({
|
||||
command: "/usr/bin/unshare",
|
||||
ownershipCommand: "/usr/bin/python3",
|
||||
args: [
|
||||
"--user",
|
||||
"--map-root-user",
|
||||
"--mount",
|
||||
"--propagation",
|
||||
"private",
|
||||
"/usr/bin/python3",
|
||||
"/rea/hopper-demo-x11.py",
|
||||
"--strategy",
|
||||
"user-mount-namespace",
|
||||
"--mount-private-x11",
|
||||
"--hopper",
|
||||
"/opt/hopper/bin/Hopper",
|
||||
"--socket",
|
||||
"/tmp/rea-fixture/bridge.sock",
|
||||
"--",
|
||||
"/opt/hopper/bin/Hopper",
|
||||
"--analysis",
|
||||
],
|
||||
});
|
||||
expect(launch?.args).not.toContain("sudo");
|
||||
expect(launch?.args).not.toContain("-c");
|
||||
});
|
||||
|
||||
it("keeps an ordinary Linux launch on the direct Python adapter", () => {
|
||||
expect(
|
||||
linuxDemoLaunch(
|
||||
options("/opt/hopper/bin/Hopper"),
|
||||
{
|
||||
directory: "/tmp/rea-fixture",
|
||||
socketPath: "/tmp/rea-fixture/bridge.sock",
|
||||
token: "not-forwarded",
|
||||
runId: "fixture-run",
|
||||
},
|
||||
[],
|
||||
"direct",
|
||||
),
|
||||
).toMatchObject({
|
||||
command: "/usr/bin/python3",
|
||||
args: [
|
||||
"/rea/hopper-demo-x11.py",
|
||||
"--strategy",
|
||||
"direct",
|
||||
"--hopper",
|
||||
"/opt/hopper/bin/Hopper",
|
||||
"--socket",
|
||||
"/tmp/rea-fixture/bridge.sock",
|
||||
"--",
|
||||
"/opt/hopper/bin/Hopper",
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects an unpinned wrapper before executing it", async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), "rea-hopper-wrapper-"));
|
||||
const directory = await createTestTempDirectory("rea-hopper-wrapper-");
|
||||
const wrapper = join(directory, "hopper-wrapper");
|
||||
const marker = join(directory, "executed");
|
||||
try {
|
||||
@@ -75,7 +146,9 @@ describe("Hopper bridge launcher selection", () => {
|
||||
),
|
||||
).rejects.toMatchObject({
|
||||
code: 72,
|
||||
stderr: expect.stringContaining("unsupported Hopper binary"),
|
||||
stderr: expect.stringContaining(
|
||||
'"failure_code":"unsupported_hopper_build"',
|
||||
),
|
||||
});
|
||||
await expect(access(marker)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user