I built the tool my agent-guard README said didn't exist yet
说明与用途
bash‑write‑targets 能够静态列出 Bash 命令可能写入的文件,提升 agent‑guard 的安全审计能力。
问题
Agent-guard’s Bash PreToolUse hook lacked a robust static parser to list potential file write targets in a command string, limiting its safety audit capabilities.
结果
The tool accurately captures write targets for redirection, heredocs, command substitution, tee, file operations, sed, dd, truncate, touch, zip, and various command flags, while conservatively skipping ambiguous cases.
工作流
- 1. Install bash-write-targets via pip.
- 2. Run
targets '<bash command>'to receive a list of write targets. - 3. Optionally use
--jsonfor machine‑readable output.
证据
Bash write-target extraction is static and approximate.
What it catches: > >> &> 2> heredocs (bodies are stripped so <<EOF content isn't mistaken for targets), $(...) and backticks (scanned recursively), tee (all operands, -a aware), cp/mv/install destinations, sed -i (script vs. file disambiguation), dd of=, truncate, touch, zip archives, and -o/--output flags for curl, wget, gcc, sort, pandoc, psql, tar -f.
Pure static parsing over the command string. Nothing is executed, no subshell is spawned, no file is touched — auditing a destructive command cannot itself be destructive.
- 记录日期: 2026-10-21T08:56:05.019Z