From ed777b2bcaac158118beb5257b621a2bce1c0098 Mon Sep 17 00:00:00 2001 From: Alanperry1 Date: Sun, 6 Sep 2026 00:49:46 -0500 Subject: [PATCH] fix: suppress workflow commands in Codex output --- action.yml | 8 +++++++- test/actionHardening.test.mjs | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index ff7088b..f2c4bca 100644 --- a/action.yml +++ b/action.yml @@ -365,7 +365,10 @@ runs: FORCE_COLOR: 1 shell: bash run: | - exec env -u NODE_OPTIONS NODE_OPTIONS=--disable-sigusr1 node --disable-sigusr1 "$ACTION_PATH/dist/main.js" run-codex-exec \ + workflow_command_token="codex-action-$(uuidgen)" + echo "::stop-commands::$workflow_command_token" + set +e + env -u NODE_OPTIONS NODE_OPTIONS=--disable-sigusr1 node --disable-sigusr1 "$ACTION_PATH/dist/main.js" run-codex-exec \ --prompt "${CODEX_PROMPT}" \ --prompt-file "${CODEX_PROMPT_FILE}" \ --output-file "$CODEX_OUTPUT_FILE" \ @@ -380,3 +383,6 @@ runs: --effort "$CODEX_EFFORT" \ --safety-strategy "$CODEX_SAFETY_STRATEGY" \ --codex-user "$CODEX_USER" + run_codex_exit=$? + echo "::$workflow_command_token::" + exit "$run_codex_exit" diff --git a/test/actionHardening.test.mjs b/test/actionHardening.test.mjs index d8aed0f..f5e9c05 100644 --- a/test/actionHardening.test.mjs +++ b/test/actionHardening.test.mjs @@ -190,13 +190,21 @@ setInterval(() => {}, 1000); } ); -test("Codex action and its descendants replace inherited Node options", () => { +test("Codex output cannot be interpreted as GitHub workflow commands", () => { const step = actionStep("Run codex exec"); assert.match( step, - /exec env -u NODE_OPTIONS NODE_OPTIONS=--disable-sigusr1 node --disable-sigusr1 "\$ACTION_PATH\/dist\/main\.js" run-codex-exec/ + /workflow_command_token="codex-action-\$\(uuidgen\)"/ ); + assert.match(step, /echo "::stop-commands::\$workflow_command_token"/); + assert.match(step, /echo "::\$workflow_command_token::"/); + assert.match( + step, + /env -u NODE_OPTIONS NODE_OPTIONS=--disable-sigusr1 node --disable-sigusr1 "\$ACTION_PATH\/dist\/main\.js" run-codex-exec/ + ); + assert.match(step, /run_codex_exit=\$\?/); + assert.match(step, /exit "\$run_codex_exit"/); }); test(