Skip to content

Commit cc2eaf6

Browse files
committed
addressing claude review
1 parent 7c8c3ad commit cc2eaf6

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎scripts/sandbox-browser-entrypoint.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ def has_auth(header_bytes):
224224
name, sep, value = line.partition(":")
225225
if sep and name.strip().lower() == "authorization":
226226
auth = value.strip()
227-
return hmac.compare_digest(auth, EXPECTED_BASIC) or hmac.compare_digest(
228-
auth, EXPECTED_BEARER
229-
)
227+
basic_ok = hmac.compare_digest(auth, EXPECTED_BASIC)
228+
bearer_ok = hmac.compare_digest(auth, EXPECTED_BEARER)
229+
return basic_ok or bearer_ok
230230
return False
231231
232232

‎src/agents/sandbox/browser.create.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { readFileSync } from "node:fs";
12
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
23
import { SANDBOX_BROWSER_IMAGE_CONTRACT_EPOCH } from "./constants.js";
34
import { collectDockerFlagValues, findDockerArgsCall } from "./test-args.js";
@@ -252,6 +253,18 @@ describe("ensureSandboxBrowser create args", () => {
252253
expect(findDockerArgsCall(dockerMocks.execDocker.mock.calls, "create")).toBeUndefined();
253254
});
254255

256+
it("keeps the browser Dockerfile contract label aligned with the runtime constant", () => {
257+
const dockerfile = readFileSync(
258+
new URL("../../../scripts/docker/sandbox/Dockerfile.browser", import.meta.url),
259+
"utf8",
260+
);
261+
const label = dockerfile.match(
262+
/^LABEL org\.openclaw\.sandbox-browser\.contract="([^"]+)"$/m,
263+
)?.[1];
264+
265+
expect(label).toBe(SANDBOX_BROWSER_IMAGE_CONTRACT_EPOCH);
266+
});
267+
255268
it("publishes noVNC on loopback and injects noVNC password env", async () => {
256269
const result = await ensureTestSandboxBrowser({
257270
scopeKey: "session:test",

‎src/agents/sandbox/browser.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ export async function ensureSandboxBrowser(params: {
261261
cdpAuthToken =
262262
(await readDockerContainerEnvVar(containerName, CDP_AUTH_TOKEN_ENV_KEY)) ?? undefined;
263263
if (!cdpAuthToken) {
264+
defaultRuntime.log(
265+
`Removing stale sandbox browser container ${containerName} because it lacks the current CDP relay auth contract; it will be recreated.`,
266+
);
264267
await execDocker(["rm", "-f", containerName], { allowFailure: true });
265268
hasContainer = false;
266269
running = false;

0 commit comments

Comments
 (0)