fix(worker): sanitize --once human-readable output#244
Merged
Maleick merged 1 commit intoMay 19, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the CLI’s human-readable worker --once output against terminal escape/control-sequence injection by sanitizing state-derived fields, while keeping the --json output behavior unchanged.
Changes:
- Routes
run_id,status,goal, andreasonthroughformatDisplayValue(...)inworker --oncehuman output. - Adds a human-readable
Metric:line (sanitized) when available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| console.log(` Run ID: ${formatDisplayValue(result.run_id)}`); | ||
| console.log(` Status: ${formatDisplayValue(result.status)}`); | ||
| console.log(` Goal: ${formatDisplayValue(result.goal)}`); | ||
| if (result.metric) console.log(` Metric: ${formatDisplayValue(result.metric)}`); |
Comment on lines
+1372
to
+1374
| console.log(` Run ID: ${formatDisplayValue(result.run_id)}`); | ||
| console.log(` Status: ${formatDisplayValue(result.status)}`); | ||
| console.log(` Goal: ${formatDisplayValue(result.goal)}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
worker --oncepath printed fields read from.autoresearch/state.json(for examplerun_id,status,goal,metric, andreason) directly to the terminal, which allows repository-controlled ANSI/OSC/control-sequence injection into terminals or logs.Description
formatDisplayValue(...)in the human-readableworker --onceoutput insrc/cli-commands.tssorun_id,status,goal,reason, andmetricare sanitized while leaving the JSON (--json) output path unchanged.Testing
npm run typecheckwhich completed successfully, and rannpm testwhich failed because the test environment lacks compileddist/*.jsartifacts (numerousMODULE_NOT_FOUNDerrors), so full test validation could not be completed here.Codex Task