Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/checks/build-protected-managed-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ source_root="$PWD"
cache_to=""
cache_from=""
audit_evidence_from=""
runtime_user="root"
runtime_user="sandbox"
while (($# > 0)); do
case "$1" in
--audit-evidence-from)
Expand Down
47 changes: 26 additions & 21 deletions test/platform/images/protected-managed-image-build-script.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ beforeEach(() => {
registryLog = path.join(testRoot, "registry.log");
registryStatus = "404";
teeFailureMode = "";
imageUser = "root";
imageUser = "sandbox";
mkdirSync(stubBin);
writeExecutable(
"docker",
Expand Down Expand Up @@ -353,37 +353,42 @@ describe("protected managed-image source-root boundary", () => {
});

describe("protected managed-image build-cache boundary", () => {
it("keeps the legacy root runtime contract unless a reviewed transition selects sandbox", () => {
stubBuildInvocation();
it.each(["linux/amd64", "linux/arm64"])(
"builds every agent as sandbox by default on %s",
(platform) => {
stubBuildInvocation();

const result = runBuild(REPO_ROOT, [], platform);

expect(result.status, result.stderr).toBe(0);
expect(recordedBuildInvocations()).toHaveLength(3);
expect(
recordedBuildInvocations().every((invocation) =>
invocation.includes("--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=sandbox"),
),
).toBe(true);
},
);

const legacy = runBuild(REPO_ROOT);
it("preserves an explicitly selected runtime user", () => {
stubBuildInvocation();
imageUser = "root";
const result = runBuild(REPO_ROOT, ["--runtime-user", "root"]);

expect(legacy.status, legacy.stderr).toBe(0);
expect(result.status, result.stderr).toBe(0);
expect(recordedBuildInvocations()).toHaveLength(3);
expect(
recordedBuildInvocations().every((invocation) =>
invocation.includes("--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=root"),
),
).toBe(true);

writeFileSync(dockerLog, "", "utf8");
imageUser = "sandbox";
const transitioned = runBuild(REPO_ROOT, ["--runtime-user", "sandbox"]);

expect(transitioned.status, transitioned.stderr).toBe(0);
expect(recordedBuildInvocations()).toHaveLength(3);
expect(
recordedBuildInvocations().every((invocation) =>
invocation.includes("--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=sandbox"),
),
).toBe(true);
});

it("rejects an image whose final Config.User does not match the selected runtime user", () => {
stubBuildInvocation();
imageUser = "root";

const result = runBuild(REPO_ROOT, ["--runtime-user", "sandbox"]);
const result = runBuild(REPO_ROOT);

expect(result.status, result.stderr).toBe(1);
expect(recordedBuildInvocations()).toHaveLength(1);
Expand Down Expand Up @@ -411,12 +416,12 @@ describe("protected managed-image build-cache boundary", () => {
expect(recordedBuildInvocation("openclaw")).toContain("--platform linux/arm64");
expect(recordedBuildInvocation("openclaw")).toContain("--build-arg TARGETARCH=arm64");
expect(recordedBuildInvocation("openclaw")).toContain(
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=root",
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=sandbox",
);
expect(recordedBuildInvocation("hermes")).toContain("--platform linux/arm64");
expect(recordedBuildInvocation("hermes")).toContain("--build-arg TARGETARCH=arm64");
expect(recordedBuildInvocation("hermes")).toContain(
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=root",
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=sandbox",
);
expect(recordedBuildInvocation("langchain-deepagents-code")).toContain(
"--platform linux/arm64",
Expand All @@ -425,7 +430,7 @@ describe("protected managed-image build-cache boundary", () => {
"--build-arg TARGETARCH=arm64",
);
expect(recordedBuildInvocation("langchain-deepagents-code")).toContain(
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=root",
"--build-arg NEMOCLAW_MANAGED_IMAGE_RUNTIME_USER=sandbox",
);
});

Expand Down
Loading