mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:50:46 +00:00
Harden Codex harness control surfaces (#77459)
* fix(scripts): find codex protocol source from worktrees * fix(test): keep codex harness docker caches writable * fix(test): relax live codex cache mount permissions * test(codex): add live docker harness debug output * fix(test): detect numeric ci env in codex docker harness * fix(codex): skip duplicate agent-command telemetry * fix(tooling): skip sparse-missing oxlint tsconfig * fix(tooling): route changed checks through testbox * fix(qa): keep coverage json source-clean * fix(test): preflight codex docker auth * fix(codex): validate bind option values * fix(codex): parse quoted command arguments * fix(codex): reject extra control args * fix(codex): use content for blank bound prompts * fix(codex): decode local image file urls * fix(codex): treat local media urls as images * fix(codex): keep windows media paths local * fix(codex): reject malformed diagnostics confirmations * fix(codex): reject malformed resume commands * fix(codex): reject malformed thread actions * fix(codex): reject malformed turn controls * fix(codex): reject malformed model controls * fix(codex): resolve empty user input prompts * fix(codex): enforce user input options * fix(codex): reject ambiguous computer-use actions * fix(codex): ignore stale bound turn notifications * test(gateway): close task registries in gateway harness * test(gateway): route cleanup through task seams * fix(codex): describe current permission approvals * fix(codex): disclose command approval amendments * fix(codex): preserve approval detail under truncation * fix(codex): propagate dynamic tool failures * test(codex): align dynamic tool block contract * fix(codex): reject extra read-only command operands * fix(codex): escape command readout fields * fix(codex): escape status probe errors * fix(codex): narrow formatted thread details * fix(codex): escape successful status summaries * fix(codex): escape bound control replies * fix(codex): escape user input prompts * fix(codex): escape control failure replies * fix(codex): escape approval prompt text * test(codex): narrow escaped reply assertions * test(codex): complete strict reply fixtures * test(codex): preserve account fixture literals * test(codex): align status probe fixtures * fix(codex): satisfy sanitizer regex lint * fix(codex): harden command readouts * fix(codex): harden bound image inputs * fix(codex): sanitize command failure replies * test(codex): complete rate limit fixture * test(tooling): isolate postinstall compile cache fixture * fix(codex): keep app-server event ownership explicit --------- Co-authored-by: pashpashpash <nik@vault77.ai>
This commit is contained in:
@@ -22,9 +22,15 @@ DOCKER_USER="${OPENCLAW_DOCKER_USER:-node}"
|
||||
DOCKER_HOME_MOUNT=()
|
||||
DOCKER_TRUSTED_HARNESS_MOUNT=()
|
||||
DOCKER_TRUSTED_HARNESS_CONTAINER_DIR=""
|
||||
DOCKER_CACHE_CONTAINER_DIR="/tmp/openclaw-cache"
|
||||
DOCKER_CLI_TOOLS_CONTAINER_DIR="/tmp/openclaw-npm-global"
|
||||
DOCKER_EXTRA_ENV_FILES=()
|
||||
DOCKER_AUTH_PRESTAGED=0
|
||||
|
||||
openclaw_live_codex_harness_is_ci() {
|
||||
[[ -n "${CI:-}" && "${CI:-}" != "false" ]] || [[ -n "${GITHUB_ACTIONS:-}" && "${GITHUB_ACTIONS:-}" != "false" ]]
|
||||
}
|
||||
|
||||
openclaw_live_codex_harness_append_build_extension() {
|
||||
local extension="${1:?extension required}"
|
||||
local current="${OPENCLAW_DOCKER_BUILD_EXTENSIONS:-${OPENCLAW_EXTENSIONS:-}}"
|
||||
@@ -50,6 +56,13 @@ if [[ "$CODEX_HARNESS_AUTH_MODE" == "api-key" && -z "${OPENAI_API_KEY:-}" ]]; th
|
||||
echo "ERROR: OPENCLAW_LIVE_CODEX_HARNESS_AUTH=api-key requires OPENAI_API_KEY." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ "$CODEX_HARNESS_AUTH_MODE" != "api-key" && ! -s "$HOME/.codex/auth.json" ]]; then
|
||||
echo "ERROR: OPENCLAW_LIVE_CODEX_HARNESS_AUTH=codex-auth requires ~/.codex/auth.json before building the live Docker image." >&2
|
||||
if [[ -n "${OPENAI_API_KEY:-}" ]]; then
|
||||
echo "If this is a Testbox/API-key run, set OPENCLAW_LIVE_CODEX_HARNESS_AUTH=api-key and run through openclaw-testbox-env." >&2
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cleanup_temp_dirs() {
|
||||
if ((${#TEMP_DIRS[@]} > 0)); then
|
||||
@@ -60,7 +73,7 @@ trap cleanup_temp_dirs EXIT
|
||||
|
||||
if [[ -n "${OPENCLAW_DOCKER_CLI_TOOLS_DIR:-}" ]]; then
|
||||
CLI_TOOLS_DIR="${OPENCLAW_DOCKER_CLI_TOOLS_DIR}"
|
||||
elif [[ "${CI:-}" == "true" || "${GITHUB_ACTIONS:-}" == "true" ]]; then
|
||||
elif openclaw_live_codex_harness_is_ci; then
|
||||
CLI_TOOLS_DIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-docker-cli-tools.XXXXXX")"
|
||||
TEMP_DIRS+=("$CLI_TOOLS_DIR")
|
||||
else
|
||||
@@ -68,7 +81,7 @@ else
|
||||
fi
|
||||
if [[ -n "${OPENCLAW_DOCKER_CACHE_HOME_DIR:-}" ]]; then
|
||||
CACHE_HOME_DIR="${OPENCLAW_DOCKER_CACHE_HOME_DIR}"
|
||||
elif [[ "${CI:-}" == "true" || "${GITHUB_ACTIONS:-}" == "true" ]]; then
|
||||
elif openclaw_live_codex_harness_is_ci; then
|
||||
CACHE_HOME_DIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-docker-cache.XXXXXX")"
|
||||
TEMP_DIRS+=("$CACHE_HOME_DIR")
|
||||
else
|
||||
@@ -77,7 +90,10 @@ fi
|
||||
|
||||
mkdir -p "$CLI_TOOLS_DIR"
|
||||
mkdir -p "$CACHE_HOME_DIR"
|
||||
if [[ "${CI:-}" == "true" || "${GITHUB_ACTIONS:-}" == "true" ]]; then
|
||||
if openclaw_live_codex_harness_is_ci; then
|
||||
chmod 0777 "$CLI_TOOLS_DIR" "$CACHE_HOME_DIR" || true
|
||||
fi
|
||||
if openclaw_live_codex_harness_is_ci; then
|
||||
DOCKER_USER="$(id -u):$(id -g)"
|
||||
DOCKER_HOME_DIR="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-docker-home.XXXXXX")"
|
||||
TEMP_DIRS+=("$DOCKER_HOME_DIR")
|
||||
@@ -146,6 +162,11 @@ export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||
export COREPACK_HOME="${COREPACK_HOME:-$XDG_CACHE_HOME/node/corepack}"
|
||||
export NPM_CONFIG_CACHE="${NPM_CONFIG_CACHE:-$XDG_CACHE_HOME/npm}"
|
||||
export npm_config_cache="$NPM_CONFIG_CACHE"
|
||||
if [ "${OPENCLAW_LIVE_CODEX_HARNESS_DEBUG:-}" = "1" ]; then
|
||||
id
|
||||
mount | grep -E 'openclaw-cache|openclaw-npm|/home/node' || true
|
||||
ls -ld "$HOME" "$XDG_CACHE_HOME" "$NPM_CONFIG_PREFIX" 2>/dev/null || true
|
||||
fi
|
||||
# Force the Codex harness to use the staged `~/.codex` auth files. This lane
|
||||
# is not meant to exercise raw OpenAI API-key routing unless the lane
|
||||
# explicitly opts into API-key auth for CI.
|
||||
@@ -254,6 +275,12 @@ DOCKER_RUN_ARGS=(docker run --rm -t \
|
||||
--entrypoint bash \
|
||||
-e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
|
||||
-e HOME=/home/node \
|
||||
-e NPM_CONFIG_PREFIX="$DOCKER_CLI_TOOLS_CONTAINER_DIR" \
|
||||
-e npm_config_prefix="$DOCKER_CLI_TOOLS_CONTAINER_DIR" \
|
||||
-e XDG_CACHE_HOME="$DOCKER_CACHE_CONTAINER_DIR" \
|
||||
-e COREPACK_HOME="$DOCKER_CACHE_CONTAINER_DIR/node/corepack" \
|
||||
-e NPM_CONFIG_CACHE="$DOCKER_CACHE_CONTAINER_DIR/npm" \
|
||||
-e npm_config_cache="$DOCKER_CACHE_CONTAINER_DIR/npm" \
|
||||
-e NODE_OPTIONS=--disable-warning=ExperimentalWarning \
|
||||
-e OPENCLAW_AGENT_HARNESS_FALLBACK=none \
|
||||
-e OPENCLAW_DOCKER_AUTH_PRESTAGED="$DOCKER_AUTH_PRESTAGED" \
|
||||
@@ -287,14 +314,22 @@ openclaw_live_append_array DOCKER_RUN_ARGS DOCKER_EXTRA_ENV_FILES
|
||||
openclaw_live_append_array DOCKER_RUN_ARGS DOCKER_HOME_MOUNT
|
||||
openclaw_live_append_array DOCKER_RUN_ARGS DOCKER_TRUSTED_HARNESS_MOUNT
|
||||
DOCKER_RUN_ARGS+=(\
|
||||
-v "$CACHE_HOME_DIR":/home/node/.cache \
|
||||
-v "$CACHE_HOME_DIR":"$DOCKER_CACHE_CONTAINER_DIR" \
|
||||
-v "$ROOT_DIR":/src:ro \
|
||||
-v "$CONFIG_DIR":/home/node/.openclaw \
|
||||
-v "$WORKSPACE_DIR":/home/node/.openclaw/workspace \
|
||||
-v "$CLI_TOOLS_DIR":/home/node/.npm-global)
|
||||
-v "$CLI_TOOLS_DIR":"$DOCKER_CLI_TOOLS_CONTAINER_DIR")
|
||||
openclaw_live_append_array DOCKER_RUN_ARGS EXTERNAL_AUTH_MOUNTS
|
||||
openclaw_live_append_array DOCKER_RUN_ARGS PROFILE_MOUNT
|
||||
DOCKER_RUN_ARGS+=(\
|
||||
"$LIVE_IMAGE_NAME" \
|
||||
-lc "$LIVE_TEST_CMD")
|
||||
if [[ "${OPENCLAW_LIVE_CODEX_HARNESS_DEBUG:-}" == "1" ]]; then
|
||||
echo "==> Docker debug: host ids and mounted dirs"
|
||||
id
|
||||
ls -ld "$CACHE_HOME_DIR" "$CLI_TOOLS_DIR" "${DOCKER_HOME_DIR:-$HOME}" 2>/dev/null || true
|
||||
printf '==> Docker debug args:'
|
||||
printf ' %q' "${DOCKER_RUN_ARGS[@]}"
|
||||
printf '\n'
|
||||
fi
|
||||
"${DOCKER_RUN_ARGS[@]}"
|
||||
|
||||
Reference in New Issue
Block a user