Skip to content

feat(hooks): allow read-only local curl diagnostics and log syntax ask kinds - #287

Merged
furedea merged 4 commits into
mainfrom
feat/local-curl-and-syntax-audit
Oct 22, 2026
Merged

furedea merged 4 commits into
mainfrom
feat/local-curl-and-syntax-audit

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

概要

ローカル開発サーバーへの読み取り専用 curl が毎回確認を求められていたため,許可範囲を広げる.あわせて,構文による確認要求の原因を監査ログから判別できるようにする.

変更内容

  • allowed_commands.json の localhost 向け curl ルールで,次を許可する.ホストは localhost,127.0.0.1,[::1] に限定したままとする.
    • -w/--write-out: シングルクォートで囲んだ固定書式のみ.使えるのは許可リストにあるプレースホルダ(%{http_code},%{time_total},%{time_connect},%{time_starttransfer},%{size_download},%{content_type},%{url_effective},%{remote_ip}),\n,英数字と一部の記号のみ.ダブルクォート,%output,%{stderr},@file などファイルの読み書きや出力先の変更につながる書式は確認を求める.
    • -D -/--dump-header -: 標準出力のみ.ファイルへの出力は確認を求める.
    • --compressed
  • オプションの順序は固定とし,繰り返しや並べ替えは確認を求める.
  • guard_command.py で,localhost の curl を jq,head,tail,grep,wc の標準入力専用フィルターにパイプする形を,curl 単体と同様に扱う.
    • 各フィルターの引数は,シングルクォートの外側が固定の文字集合だけで構成されていることを要求する.glob や zsh の extended_glob によってフィルターがローカルファイルを読む経路を塞ぐ.
    • ファイルの読み書きやコード実行を伴うオプションがあるフィルターや,それ以外のパイプは従来どおり確認を求める.
  • UnsupportedSyntax に短い理由種別(heredoc,expansion,dollar-quote,wrapper,parse-failure)を追加し,構文による確認要求の監査ログには種別のみを記録する.コマンド本文や引数は記録しない.
  • パイプ検査を shell_inspection.py に分け,shell_syntax.py を行数上限内に収めた.pyproject.toml の known_first_party に登録し,deptry を通す.

テスト

  • uv run --frozen pytest tests/agents: 2173 件成功
  • uv run --group audit vulture: 指摘なし
  • uv run --group audit deptry .: 問題なし
  • lefthook run pre-commit --all-files: 成功

Closes #286

🤖 Generated with Claude Code

…k kinds

Allow curl -w with a fixed format, -D -, and --compressed against
localhost, and treat a localhost curl piped into stdin-only filters
(jq, head, tail, grep, wc) like the curl alone. Record only a short
reason kind for a syntax ask in the audit log, never the command text.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
furedea and others added 3 commits October 22, 2026 13:58
Accept only a single-quoted -w/--write-out format made of allowlisted
placeholders, plain text, and the newline escape, so double-quoted
escapes cannot smuggle a remote URL or -L/-x/-K, and %output, %{stderr},
and @file forms keep asking. Restore the fixed option order of the curl
rule so repeated or reordered options ask again.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Check each filter's text outside single quotes against a strict literal
character set, so globs and zsh extended_glob patterns cannot make a
filter read local files. Register shell_inspection as first-party so
deptry passes.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Split the filter glob test so the hook assertion always runs and only
the real-zsh expansion demonstration skips on runners without zsh.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea
furedea merged commit a1cd944 into main Oct 22, 2026
11 checks passed
@furedea
furedea deleted the feat/local-curl-and-syntax-audit branch October 22, 2026 05:27
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

Successfully merging this pull request may close these issues.

手元の開発サーバーへの curl の確認を減らし,構文解析で確認になった理由を監査ログに残す

1 participant