Skip to content

Q CLI should auto-trust chained/piped read-only commands #1917

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
blakehurd opened this issue May 20, 2025 · 0 comments
Open
3 tasks done

Q CLI should auto-trust chained/piped read-only commands #1917

blakehurd opened this issue May 20, 2025 · 0 comments

Comments

@blakehurd
Copy link

Checks

Operating system

macOS 15.4.1 (24E263)

Expected behaviour

Q CLI should automatically trust chained or piped commands that only perform read operations without requiring explicit approval each time. The trust system should analyze the entire command chain to determine if it's read-only.

Actual behaviour

Currently, Q CLI requires explicit approval for chained or piped read-only commands (like "cat file.txt | grep pattern" or "echo file.txt | xargs grep pattern"), even though these operations don't modify any files.

[chat-transcript]
You're welcome! I'm glad I could help you report the issue with the Q CLI trusted commands configuration. The development team should now be aware of the problem and will work on addressing it.

If you have any other questions about Amazon Q CLI or need assistance with anything else, feel free to ask anytime.
[Too

> Is xargs grep readonly?

The `xargs grep` command itself is not inherently read-only. It's a combination of two commands:

1. `xargs` - Takes input from standard input and executes a command using that input as arguments
2. `grep` - Searches for patterns in files

When used together as `xargs grep`, the command is typically used to search for patterns across multiple files, but it doesn't modify the files by default. It only reads their contents to find matching patterns.

However, it's important to note that while the basic usage is read-only (just searching and displaying results), you could potentially use `xargs` with other commands that do modify files. For example, if you piped the output to something that writes to files, it would no longer be read-only.

In the context of our earlier discussion about trusted commands in Amazon Q CLI, adding `xargs` and `grep` to the trusted commands list should be safe from a read-only perspective when used in their standard pattern-matching capacity.
[Tool uses: none]

> Can you please report an issue about this not being trusted by default?

I'll help you report an issue about `xargs grep` not being trusted by default in the Amazon Q CLI.
[Tool uses: report_issue]





I've submitted a new issue report about `xargs grep` not being trusted by default in the Q CLI. The report includes:

- Title: xargs grep should be trusted by default in Q CLI
- Actual behavior: xargs grep commands require explicit approval each time they are run
- Expected behavior: xargs grep should be included in the default list of trusted commands as a read-only operation
- Steps to reproduce: Details of how to observe the approval prompt for a simple xargs grep command

The GitHub issue has been created and will be reviewed by the Amazon Q development team. They'll consider adding `xargs grep` to the default trusted commands list since it's primarily a read-only operation used for searching through files.
[Tool uses: none]

> is cat readonly?

Yes, the `cat` command is read-only. It's used to display the contents of files without modifying them. The name "cat" comes from "concatenate," as it can also be used to combine multiple files and display their contents, but it never alters the original files.

Because of its read-only nature, `cat` is typically included in the default list of trusted commands for tools like Amazon Q CLI, as it doesn't pose any risk of modifying your system or files.
[Tool uses: none]

> /tools

> /trust

> /help

> /tools 

> please report an issue that Q CLI should auto-trust chained / piped reads

I'll help you report an issue about Q CLI needing to auto-trust chained or piped read operations.
[Tool uses: report_issue]

(...truncated)

Steps to reproduce

  1. Run a chained read-only command in Q CLI, such as "cat file.txt | grep pattern" or "echo file.txt | xargs grep pattern"
  2. Observe that Q CLI prompts for approval despite all commands in the chain being read-only operations

Environment

<This will be visible to anyone. Do not include personal or sensitive information>

[q-details]
version = "1.10.1"
hash = "cb90e381cf8391beef4b966623d913e258cbb08d"
date = "2025-05-16T13:53:39.016927Z (4d ago)"

[system-info]
os = "macOS 15.4.1 (24E263)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"

[environment]
cwd = "/Users/USER"
cli-path = "/Users/USER"
install-method = "brew"

[env-vars]
PATH = "/Users/USER/.toolbox/bin:/opt/homebrew/opt/python3@/libexec/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/.local/bin"
QTERM_SESSION_ID = "9654039764ad463faa543c4e88cb4693"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.10.1"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.apple.Terminal"

[chat-settings]
interactive=true

[chat-trusted_tools]

[chat-failed_request_ids]
none

[chat-context]
current_profile=default
profiles=
default
codetree-dev

global_context=
.amazonq/rules/**/*.md
README.md
AmazonQ.md

profile_context=none

files=none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant