Skip to content

fix(worker): sanitize --once human-readable output#244

Merged
Maleick merged 1 commit into
mainfrom
bug/fix-terminal-control-injection-in-worker-output
May 19, 2026
Merged

fix(worker): sanitize --once human-readable output#244
Maleick merged 1 commit into
mainfrom
bug/fix-terminal-control-injection-in-worker-output

Conversation

@Maleick
Copy link
Copy Markdown
Owner

@Maleick Maleick commented May 19, 2026

Motivation

  • The human-readable worker --once path printed fields read from .autoresearch/state.json (for example run_id, status, goal, metric, and reason) directly to the terminal, which allows repository-controlled ANSI/OSC/control-sequence injection into terminals or logs.

Description

  • Route state-derived fields through formatDisplayValue(...) in the human-readable worker --once output in src/cli-commands.ts so run_id, status, goal, reason, and metric are sanitized while leaving the JSON (--json) output path unchanged.

Testing

  • Ran npm run typecheck which completed successfully, and ran npm test which failed because the test environment lacks compiled dist/*.js artifacts (numerous MODULE_NOT_FOUND errors), so full test validation could not be completed here.

Codex Task

Copilot AI review requested due to automatic review settings May 19, 2026 04:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and reason through formatDisplayValue(...) in worker --once human output.
  • Adds a human-readable Metric: line (sanitized) when available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/cli-commands.ts
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 thread src/cli-commands.ts
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)}`);
@Maleick Maleick merged commit 7b73c47 into main May 19, 2026
4 of 5 checks passed
@Maleick Maleick deleted the bug/fix-terminal-control-injection-in-worker-output branch May 19, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants