fix: parse interactive bash commands safely#170
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for the pull request. A maintainer will review it when available. Please keep the PR focused, explain the why in the description, and make sure local checks pass before requesting review. Contribution guide: https://github.com/AI-Shell-Team/aish/blob/main/CONTRIBUTING.md |
|
This pull request description looks incomplete. Please update the missing sections below before review. Missing items:
|
|
blocked by #169 |
Motivation
sudo/suinside comments, strings, or unrelated tokens as an interactive invocation and routed the command to the PTY executor, allowing an AI-controlled command to solicit and leak live terminal input.sudo/su(command words at shell command positions) as interactive so PTY routing is only used when stdin could legitimately be read by a child process.Description
_needs_interactive_bashwith ashlex-based tokenizer that respects quoting and#comments and recognizes shell command separators, so only command-position tokens trigger interactive routing._INTERACTIVE_COMMANDS,_COMMAND_SEPARATORS, and helper_is_shell_assignmentto allow leading environment assignments (e.g.FOO=bar sudo ...), shell negation (!), and separators/pipelines to be handled correctly.tests/tools/test_bash_output_offload.pyto assert that realsudo/suinvocations still match while quoted/comment-only or substring occurrences (e.g.printf 'sudo prompt',echo ok # sudo) no longer trigger PTY execution.Testing
uv run pytest tests/tools/test_bash_output_offload.py -qand the file-level tests passed (10 passed).uv run pytest tests/tools -qand the tools test suite passed (61 passed).uv run ruff check src/aish/tools/code_exec.py tests/tools/test_bash_output_offload.pyand lint checks passed, andgit diff --checkreported no problems.Codex Task