Skip to content

Commit 5b79ab0

Browse files
committed
fix: parse codex computer use timeout env strictly
1 parent 929b3a4 commit 5b79ab0

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

extensions/codex/src/app-server/config.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,23 @@ allowed_sandbox_modes = ["read-only", "workspace-write"]
714714
marketplaceSource: "github:example/plugins",
715715
},
716716
);
717+
718+
for (const value of ["0x10", "1e3"]) {
719+
expectFields(
720+
resolveCodexComputerUseConfig({
721+
pluginConfig: {},
722+
env: {
723+
OPENCLAW_CODEX_COMPUTER_USE: "1",
724+
OPENCLAW_CODEX_COMPUTER_USE_MARKETPLACE_DISCOVERY_TIMEOUT_MS: value,
725+
},
726+
}),
727+
"computer use config",
728+
{
729+
enabled: true,
730+
marketplaceDiscoveryTimeoutMs: 60_000,
731+
},
732+
);
733+
}
717734
});
718735

719736
it("allows plugin config to opt in to guardian-reviewed local execution", () => {

extensions/codex/src/app-server/config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const START_OPTIONS_KEY_SECRET_SYMBOL = Symbol.for("openclaw.codexAppServerStart
1010
const START_OPTIONS_KEY_SECRET = getStartOptionsKeySecret();
1111
const UNIX_CODEX_REQUIREMENTS_PATH = "/etc/codex/requirements.toml";
1212
const WINDOWS_CODEX_REQUIREMENTS_SUFFIX = "\\OpenAI\\Codex\\requirements.toml";
13+
const PLAIN_DECIMAL_NUMBER_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))$/;
1314

1415
type CodexAppServerTransportMode = "stdio" | "websocket";
1516
type CodexAppServerPolicyMode = "yolo" | "guardian";
@@ -1035,10 +1036,11 @@ function readBooleanEnv(value: string | undefined): boolean | undefined {
10351036
}
10361037

10371038
function readNumberEnv(value: string | undefined): number | undefined {
1038-
if (value === undefined) {
1039+
const trimmed = value?.trim();
1040+
if (!trimmed || !PLAIN_DECIMAL_NUMBER_RE.test(trimmed)) {
10391041
return undefined;
10401042
}
1041-
const parsed = Number(value);
1043+
const parsed = Number(trimmed);
10421044
return Number.isFinite(parsed) ? parsed : undefined;
10431045
}
10441046

0 commit comments

Comments
 (0)