Skip to content

fix(security): read more of the scripts handed to fish and PowerShell for deny rules - #110

Merged
furedea merged 6 commits into
mainfrom
fix/106-deny-precision
Nov 9, 2026
Merged

furedea merged 6 commits into
mainfrom
fix/106-deny-precision

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

概要

#106 の deny 精度のうち,PowerShell の -Command と fish のスクリプトファイル引数を直す.fish の構文そのものは対象外.ask の下限(シェル名だけで ask)は変えていない.

項目 変更前 変更後
pwsh -Command '-not $false; gh repo delete x --yes' - で始まる語を捨て,ask 本文を全部読み,deny(-CommandWithArgs,-cwa は最初の語だけコード)
fish -C '…' script.fish ファイルを読まず ask 値を取るオプションを飛ばしてファイルを読み,deny 対象があれば deny
fish の if … end など bash で読めない本文 ask 変更なし(対象外)

fish のファイルは,-c,-n(-i が無いとき),-v,-h,--print-debug-categories が付くと読まない.bash として解析できないファイルは捨てて,従来どおり名前だけで ask する(同じ行の別コマンドの deny は残る).

検証

  • 各項目の回帰テストを先に追加し,失敗を確認してから修正した(tests/hooks/test_non_bash_shell_input.py)
  • uv run pytest tests/hooks tests/test_prefix_rules.py tests/test_prefix_audit.py: 3524 passed, 1 skipped
  • ask の下限テスト(既知の非 bash シェルはどう呼んでも ask)は変更なしで通る
  • claude-review は green,CI の各ジョブも green
  • uv run pytest tests 全体では tests/test_hook_generation.py の dsh 関連 10 件が失敗する.ローカルにインストール済みの agent-harness に generate-dsh-hooks が無いため(この PR と無関係)

判断

  • fish の if … end など bash で読めない構文は,部分的に読むと誤判定が増えるため,本物の fish パーサーが要る.部分パーサーは書かず対象外にした(Issue コメント)
  • shell_syntax.py が 500 行の上限を超えたため,fish の処理を fish_script.py,PowerShell のオプション規則を powershell_options.py,script_index を shell_wrappers.py に移した(挙動の変更なし)
  • Codex の再レビューは 3 回とも新しい指摘が出たため,brief に従ってここで止めた.指摘は 1 件目から順に,bash で読めない fish ファイルで兄弟コマンドの deny が ask になる(P1),-n,-v など実行しない fish オプション(P2),-CommandWithArgs(P1),省略形の fish 長オプション(P1),-i と -n の併用(P1)で,いずれも修正済み

未対応の指摘

  • pwsh -cwa '<deny>' "$ARG" で後続の動的引数が deny を隠す(スレッド).6a7ea05 で,動的判定を選んだ words だけに適用して修正
  • pwsh -cwa 'Write-Output' -c '<deny>' のように後続引数がオプション風だと,実行されない文字列を誤って deny にする(P2,スレッド).安全側の誤り(ask が deny になる)で,allow にはならない.最終ラウンドのため修正せず,直し方とあわせて #106 のコメント に記録した

計画:#106 (comment)

Refs #106(fish の構文は未対応のため Close しない)

🤖 Generated with Claude Code

… for deny rules

Read the script file a fish call runs, past fish's valued options.

Keep every word after a PowerShell -Command, including words that start with a dash.

Both calls still ask by shell name when nothing is denied.

Refs #106

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/shell_syntax.py Outdated
unreviewed = unreviewed or (name not in SHELLS and bool(inputs))
if name == "fish":
files = fish_script.file_scripts(innermost.arguments, innermost.dynamic, directories)
scripts += [(script, innermost.wrapper_depth + 1) for script in files]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 — If a fish script file can't be parsed as bash, the deny on the rest of the line is lost.

fish_script.file_scripts returns the file's text whenever the file can be read. Line 230 then calls parse(script, ...), and for fish-only syntax (set -l x (date), if … end, function … end, which is what most .fish files look like) shfmt fails. The resulting UnsupportedSyntax is not caught here, so it escapes the outer parse, and command_verdict turns the whole command into an ask.

Example: with s.fish containing set -l x (date):

  • fish s.fish; gh repo delete x --yes: deny before this PR. Nothing came in on stdin, so fish contributed no scripts and the outer gh repo delete matched the deny rule.
  • After this PR: ask. The parse error in the file's text overrides the deny from the sibling command.

The PR description says unreadable or unparsable fish files fall back to the previous behaviour, and this case contradicts that. One fix is to try parsing each fish file script on its own and drop it (falling back to the name-based ask) if it raises UnsupportedSyntax, rather than letting the error propagate. A regression test for fish <fish-syntax file>; {DELETE} → deny would cover this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3c56f38. A fish script file that shfmt cannot parse is now dropped (the call still asks by shell name), so a sibling deny stays a deny. Tests: test_a_fish_script_file_in_fish_syntax_does_not_hide_a_denied_sibling.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

Blocking findings (P0/P1): 0

  • P2 agents/hooks/lib/shell_syntax.py:226: the text of a fish script file is parsed as bash with no try/except around it. When a .fish file uses fish-only syntax ((cmd), if … end, and so on), the UnsupportedSyntax error escapes the outer parse, and the whole line becomes an ask. So fish s.fish; gh repo delete x --yes used to be denied and is now only asked. The PR description says such files fall back to the previous behaviour, but this case does not. No test covers it.

Checked and found OK:

  • Not skipping leading - words after PowerShell -Command, including abbreviations, -- and / forms, and the case where an earlier option contains a c.
  • fish option parsing: valued short options in bundles, -c and --command (including abbreviations) ending the search for a file, and --.
  • Moving script_index to shell_wrappers.py (no behaviour change).

Minor, not posted inline: abbreviated fish long options that take a value (e.g. --init-com x f.fish) make the guard read the value as the file name. This only misses a deny; the ask floor still applies.

Reviewed by reading the code only. The sandbox did not allow running the tests or ad-hoc checks.

@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T11:48:42.453541Z 6a7ea05 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread agents/hooks/lib/shell_syntax.py Outdated
unreviewed = unreviewed or (name not in SHELLS and bool(inputs))
if name == "fish":
files = fish_script.file_scripts(innermost.arguments, innermost.dynamic, directories)
scripts += [(script, innermost.wrapper_depth + 1) for script in files]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: a sibling command's deny now drops to ask whenever the fish file uses real fish syntax.

fish_script.file_scripts only catches UnsupportedSyntax while reading the file. The text it returns goes to the recursive parse(script, …) on the last line of this loop. That call raises UnsupportedSyntax for real fish syntax (if … end, function, set x (cmd), …). The error isn't caught here, so it escapes parse() for the whole command line. guard_command.command_verdict then returns ask without checking any segment.

Example: gh repo delete x --yes; fish build.fish, where build.fish is an ordinary fish script.

  • Before this PR: the fish file wasn't read, so the gh repo delete segment was denied.
  • After this PR: the parse of build.fish raises, and the whole line only asks.

The same happens with fish -C '<deny-worthy>' real.fish. Most real fish scripts don't parse as bash, so this will come up often. The PR description says a file is only checked "when it can be read and parsed as bash; otherwise ask as before", but the code doesn't implement that fallback.

Suggested fix: parse the file text inside file_scripts, or wrap this branch so a parse failure drops the file's scripts and marks the layer unreviewed, without raising. Please add a test like verdict("forbidden", f"{DELETE}; fish s.fish") == "deny", where s.fish contains if true\n echo hi\nend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3c56f38, same change as the P2 above: the file text is parsed in fish_file_commands and dropped on UnsupportedSyntax. Both orders (deny before and after the fish call) and the -C form are covered by tests.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

1 blocking finding (P1)

  • P1 agents/hooks/lib/shell_syntax.py:226: the new fish script-file reading can turn a deny into an ask. A file with real fish syntax isn't caught when it fails to parse as bash. The error escapes parse() for the whole command line, so a sibling segment that should be denied (for example gh repo delete x --yes; fish build.fish) now only asks. There's no test covering this. See the inline comment for a fix.

Other checks (no problems found):

  • The PowerShell -Command change keeps words that start with - only for -Command and its abbreviations; other script options are unchanged.
  • fish_script.script_index handles bundles (-ic, -Cc), attached and separate long values, --, and -c abbreviations. It also stops at the first operand, which matches fish's + getopt.
  • An unknown or abbreviated valued long option (e.g. --init) misplaces the file but only leads to ask, so it's not a bypass.
  • Moving script_index into shell_wrappers.py doesn't change behaviour.

I couldn't run the test suite in this environment, so the P1 comes from reading the code (fish_script.file_scripts → parse → command_verdict's top-level except UnsupportedSyntax).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 64c35a47a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/hooks/lib/fish_script.py Outdated
Comment on lines +47 to +49
if argument == "-" or runs_command(argument):
return None
index += 2 if takes_next_word(argument) else 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge no-execute では fish スクリプトを展開しないでください

fish -n script.fish または fish --no-execute script.fish の場合も,この走査は -n を単なる値なしオプションとして通過し,ファイル内容を deny 判定へ追加します.しかし,fish の公式 CLI リファレンスでは -n は構文検査だけを行いコマンドを一切実行しないため,deny 対象文字列を含むファイルの安全な構文検査まで誤って deny されます.--no-execute/-n が指定された呼び出しではファイルを実行対象として返さないようにしてください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3c56f38. -n and --no-execute (and abbreviations, and -n inside a short bundle before a valued letter) now leave no file to read, so a syntax check is no longer denied; the call still asks by shell name. Tests: test_a_fish_syntax_check_only_asks_and_never_denies_the_file.

Drop a fish script file that shfmt cannot parse instead of asking for the whole line.

Skip the file for fish -n and --no-execute, which run nothing.

Refs #106

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/shell_syntax.py Outdated
def is_powershell_command(arguments: tuple[str, ...], argument: str) -> bool:
"""Whether the option is PowerShell's -Command or an abbreviation of it, after which every word is code."""
name = option_form(arguments, argument)[1:].lower()
return shell_name(Path(arguments[0]).name) in POWERSHELLS and bool(name) and "command".startswith(name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: -CommandWithArgs / -cwa (pwsh 7.4+) also takes the next word as code, but this prefix check doesn't cover it ("command".startswith("cwa") and "command".startswith("commandwithargs") are both False). It still matches FOREIGN_COMMAND_OPTION, so in foreign_scripts a leading-dash script is still popped: pwsh -cwa '-not $false; gh repo delete x --yes' gets ask instead of deny. This is the same gap the PR fixes for -Command. It isn't a bypass (the result is still ask, not allow), but you could cover it here and add a test case. Note that with -cwa only the first operand is code; the remaining words are arguments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5de9af0. -CommandWithArgs, -cwa and their abbreviations (also --name and /name forms) now keep the first word as code even when it starts with a dash; the rest are its arguments, not code. Tests: test_powershell_command_with_args_keeps_its_first_word_as_code, test_powershell_command_with_args_hands_the_rest_to_the_code_as_arguments.

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary

No blocking findings (0 × P0/P1).

What I checked:

  • fish script files: Reading the file can only add commands to the verdict. The fish call itself is still marked unreviewed (it's in FOREIGN_SHELLS), so the result never drops below ask. Read errors and fish-only syntax are caught (UnsupportedSyntax from shell_input.file_scripts / parse) and fall back to the name-based ask. Option scanning matches fish's getopt: bundled -ic and -Nn, an attached value in -Cc, --, and stopping at the first operand.
  • PowerShell -Command: Leading-dash words are now kept only when the option is -Command or an abbreviation of it. Other foreign shells (nu, fish) keep the old skipping behaviour.
  • Refactor: Moving script_index / SHELL_VALUED_OPTIONS into shell_wrappers.py doesn't change behaviour.

Non-blocking:

  • P3: -CommandWithArgs / -cwa still drops a leading-dash script, so it gets ask instead of deny (inline comment).
  • Minor, not commented inline: an abbreviated long option such as --init (for --init-command) isn't recognised as taking a value. Its value is then taken as the script path, so the result is ask rather than deny. Not a bypass.

I couldn't run the test suite in this read-only environment, so this review is from reading the code.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c56f38117

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/hooks/lib/fish_script.py Outdated
Comment on lines +70 to +71
if argument.startswith("--"):
return "=" not in argument and argument in VALUED_LONG_OPTIONS

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 値付き長形式の省略形でも次の語を読み飛ばしてください

fish --init-cmd 'echo init' script.fish のように値を別トークンで渡す省略形では,fish の公式 CLI リファレンスもこの形式を実行例として掲載しています.しかし,ここでは完全名だけが VALUED_LONG_OPTIONS に一致するため,'echo init' をスクリプトファイル名として選び,実際に実行される script.fish を検査しません.そのファイルに deny 対象のコマンドがあっても結果が ask に留まるため,--init-cmd や --profile-s など有効な一意省略形も値付きオプションとして扱ってください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5de9af0. A long option, or an abbreviation that no flag option shares, now takes the next word as its value (--init-com, --profile-s, --deb, --debug). One note: --init-cmd is not a prefix of --init-command, so it is not a valid abbreviation and stays a flag.

Comment thread agents/hooks/lib/shell_syntax.py Outdated
Comment on lines +434 to +437
def is_powershell_command(arguments: tuple[str, ...], argument: str) -> bool:
"""Whether the option is PowerShell's -Command or an abbreviation of it, after which every word is code."""
name = option_form(arguments, argument)[1:].lower()
return shell_name(Path(arguments[0]).name) in POWERSHELLS and bool(name) and "command".startswith(name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge CommandWithArgs の先頭スクリプトを保持してください

pwsh -CommandWithArgs '-not $false; gh repo delete x --yes' arg1 の場合,PowerShell の公式 CLI リファレンスでは -CommandWithArgs の最初の文字列が実行コマンドですが,この判定は -Command の接頭辞しか認識しません.その結果,後段の走査が - で始まる実際のスクリプトを捨てて arg1 だけを解析し,deny 対象の削除コマンドが ask に退行します.正式名と -cwa の双方で最初の文字列をスクリプトとして保持してください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 5de9af0, same change as the P3 above, with a test for -CommandWithArgs, -cwa and --commandwithargs.

…h long options

Keep the first word after -CommandWithArgs (-cwa) as code, with the rest as its arguments.

Skip the value of an abbreviated fish long option when looking for the script file.

Move the PowerShell option rules to powershell_options.py to stay under the file-length limit.

Refs #106

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary (read-only)

No P0–P3 findings.

What I checked:

  • PowerShell -Command / -CommandWithArgs (powershell_options.py, foreign_scripts): with -Command or an abbreviation of it, words starting with - are now kept. -cwa/-CommandWithArgs keep only the first word as code. Other PowerShell options that match FOREIGN_COMMAND_OPTION (such as -NonInteractive) still skip dashed words the old way. Reading more of the script can only add deny matches, so I found no way for this change to weaken a deny.
  • fish script files (fish_script.py): the option scan follows fish's getopt spec (c:C:p:d:f:D:o:). The value-taking letter in a short bundle consumes the rest of the bundle. -c and -n (including abbreviated or bundled forms) mean no file is read. A long option that is ambiguous between a flag and a valued option is treated as a flag. Every failure path (computed name, missing file, unreadable file, an UnsupportedSyntax from parsing fish-only syntax) falls back to the existing name-based ask. The fish call itself is still marked unreviewed, so a harmless file never turns the call into allow.
  • Moving script_index and SHELL_VALUED_OPTIONS into shell_wrappers.py does not change behaviour.
  • The new tests cover the changed behaviour well: abbreviations, attached and separate values, --, paths, the cd directory, fish-syntax files with denied commands next to them, and the -n syntax-check-only cases.

I couldn't run the tests in this environment (command approval was required), so this is based on reading the code.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5de9af00fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agents/hooks/lib/fish_script.py Outdated
)
letters = argument[1:]
position = valued_letter(letters)
return any(letter in "cn" for letter in (letters if position is None else letters[: position + 1]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge interactive 併用時は -n でもスクリプトを検査してください

fish -i -n script.fish(または fish -in script.fish)では,この判定が n を見つけてファイル検査を打ち切るため,ファイル内の deny 対象が ask に退行します.しかし,fish の upstream 実装は interactive と no-execute の併用時に警告後 opts.no_exec = false としており,その後スクリプトファイルを実行します.単独の -n を直した後も残るこの組み合わせでは,-i/--interactive がある場合に no-execute 扱いを解除してください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8e7ece6. -i or --interactive now cancels -n or --no-execute, so the file is read again; tests cover -i -n, -in, the long forms, and -i after --no-execute.

Comment thread agents/hooks/lib/fish_script.py Outdated
Comment on lines +61 to +62
if argument == "-" or replaces_file(argument):
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge fish の終了オプションではファイルを検査しないでください

fish --version script.fish や fish --print-debug-categories script.fish でもこの走査は後続ファイルを実行対象として読み,deny 文字列があれば拒否します.fish の公式 CLI リファレンスでは,前者はバージョンを表示して終了し,後者もカテゴリを表示して終了するため,ファイルは実行されません.-v/--version,--print-debug-categories(およびファイルを実行せずヘルプだけを処理する -h/--help)ではファイルを返さないようにしてください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 8e7ece6. -v, -h, --version, --help and --print-debug-categories (and their unambiguous abbreviations) now leave no file to read; the call still asks by shell name.

Read no file for fish -v, -h, --version, --help and --print-debug-categories, which exit early.

Keep reading the file when -i cancels -n.

Refs #106

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Review summary (read-only): I found no blocking issues.

What I checked:

  • PowerShell -Command / -CommandWithArgs: takes_code stops the code word from being dropped when it starts with -. -CommandWithArgs joins only its first word as code. Other options such as -ExecutionPolicy Bypass keep their old handling. pwsh -Command - (read from stdin) still reaches the stdin inspection, because input_scripts runs for any foreign shell.
  • fish file scripts: script_index matches fish's +-prefixed getopt string: it stops at the first operand, and the valued letters CcdofDp are correct. -c, -v, -h and -n (unless -i cancels it) all correctly suppress reading the file. The commands read from the file are only added on top of the fish layer, and that layer stays unreviewed (ask), so this change can only add denies, never allows. Recursion through a self-invoking script stops at the depth > 8 limit, and fish_file_commands suppresses the error.
  • Behaviour I'd accept as is: an abbreviated long option that fish rejects as ambiguous (e.g. --print-), or a computed option before the file, can make the guard read a file fish would not run. The worst outcome is an extra deny; nothing can become allowed this way.

I couldn't run the test suite in this environment, so this review comes from reading the code. The new tests cover the changed behaviour well.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8e7ece6055

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Only PowerShell joins its words; elsewhere the words after the script are its positional arguments.
words = operands if shell_name(Path(arguments[0]).name) in POWERSHELLS else operands[:1]
# Only PowerShell's -Command joins its words; elsewhere the words after the script are its positional arguments.
words = operands if powershell_options.joins_following_words(shell, argument) else operands[:1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge CommandWithArgs の後続引数を動的コード扱いしないでください

pwsh -cwa 'gh repo delete x --yes' "$ARG" のように,実行コードは静的でも後続の $args が動的な場合,words を先頭要素へ絞る前に全 operands の動的フラグを検査して UnsupportedSyntax を送出するため,deny 対象が ask に退行します.PowerShell の公式 CLI リファレンスどおり -CommandWithArgs では最初の文字列だけがコードで,残りは引数なので,動的判定もこの行で選択した words だけに適用してください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid, and not a bypass: the result is ask, not allow. Not fixed in this PR because three Codex re-reviews in a row kept producing new findings, so the lane stops here as instructed. The fix is to apply the dynamic-word check only to the words chosen for the script (the first operand for -CommandWithArgs). Recorded in the PR body as open.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6a7ea05. The computed-value check now covers only the words chosen as the script (the first operand for -CommandWithArgs, all words for -Command), so a computed argument after the code no longer hides a deny. Computed code still asks. Tests: test_a_computed_argument_after_the_code_of_command_with_args_does_not_hide_a_deny, test_computed_code_still_asks.

…puted values

A computed argument after the code of pwsh -CommandWithArgs no longer hides a deny.

Refs #106

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

レビュー結果(読み取りのみ)

ブロッキングな指摘はありません(P0/P1: 0 件,P2/P3: 0 件).

確認した点:

  • foreign_scripts は is_foreign_shell の経路からしか呼ばれず,その呼び出しは常に unreviewed(名前で ask)になる.このため,PowerShell の -Command の語を飛ばさなくなった変更と,動的判定を words だけに絞った変更は,deny を増やすか deny を ask に落とすかのどちらかにしかならず,allow に緩むことはない.
  • fish のファイルを解析する fish_file_commands は UnsupportedSyntax を握りつぶすが,fish の呼び出し自体は名前で ask のまま残る.同じ行の別コマンドの deny も commands += layers で残る.再帰は depth > 8 で止まり,そこで出る例外も同じく握りつぶされるので,無限には続かない.
  • fish の長オプションの最短省略長(--c,--v,--h,--int,--no-e,--print-d)と,曖昧な省略(--i,--p)の扱いは,fish の getopt の挙動と合っている.短オプションの束で値を取る文字の位置と,-i が -n を打ち消す処理も正しい.
  • PowerShell の -cwa / -CommandWithArgs / -command の判別と,--,/ 形式の正規化も正しい.

補足: 本文の「未対応の指摘」にある pwsh -cwa '…' "$ARG" のケースは,差分ではすでに words だけに動的判定をかけていて,test_a_computed_argument_after_the_code_of_command_with_args_does_not_hide_a_deny でも検証されている.本文の記述が古いようです.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a7ea0591f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 419 to +423
return [
index
for index, argument in enumerate(arguments[1:], 1)
if FOREIGN_COMMAND_OPTION.fullmatch(option_form(arguments, argument)) or is_encoded_option(arguments, argument)
if FOREIGN_COMMAND_OPTION.fullmatch(powershell_options.form(shell, argument))
or powershell_options.is_encoded(shell, argument)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge -CommandWithArgs の引数でオプション走査を止めてください

pwsh -cwa 'Write-Output' -c 'gh repo delete x --yes' のように後続引数がオプション風の文字列である場合,この全引数走査が引数内の -c まで別のコード指定として検出し,実行されない文字列を foreign_scripts が解析して誤って deny します.公式 CLI リファレンスでは最初の文字列だけがコマンドで,残りは $args に渡す引数なので,-CommandWithArgs/-cwa を見つけた後は後続トークンをオプション候補として走査しないでください.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Valid, and on the safe side (ask becomes deny, never allow). Not fixed here: this is the final round, so the finding is recorded in #106 with the fix (stop scanning for options after -cwa) instead of looping.

@furedea

furedea commented Nov 9, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 6a7ea0591f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 2c652bb into main Nov 9, 2026
41 of 45 checks passed
@furedea
furedea deleted the fix/106-deny-precision branch November 9, 2026 11:58
furedea pushed a commit that referenced this pull request Nov 10, 2026
🤖 I have created a release *beep* *boop*
---


## 0.1.0 (2026-11-10)


### Features

* add devin provider to hooks.json with hook adapter
(furedea/dotfiles[#136](#136))
([5bc5550](5bc5550))
* add git-commit-split skill
([35f4e16](35f4e16))
* add Hermes Agent and pi hook providers
(furedea/dotfiles[#138](#138))
([ed3a774](ed3a774))
* add lock-settings, report-doc-conflict, and report-hook-block skills
([35b8585](35b8585))
* **agents:** add Rust style skill
([a82df41](a82df41))
* **agents:** allow cd, sed, awk, xargs, cp, and mv under the sandbox
(furedea/dotfiles[#165](#165))
([5783f87](5783f87))
* **agents:** bootstrap the harness on servers without Nix
([80a0f9b](80a0f9b))
* **agents:** chain git add, status, commit, and push outside the
sandbox
(furedea/dotfiles[#169](#169))
([dd5a05c](dd5a05c))
* **agents:** Codex implements, Claude reviews, and lanes clean up
opened workspaces
(furedea/dotfiles[#266](#266))
([c9a3fd9](c9a3fd9))
* **agents:** generate hook settings from nix
([b20d592](b20d592))
* **agents:** hand approved lanes to Herdr task worktree sessions
(furedea/dotfiles[#184](#184))
([58a591f](58a591f))
* **agents:** own personal agent source
(furedea/dotfiles[#52](#52))
([51060b1](51060b1))
* **agents:** permit commands by reversibility
(furedea/dotfiles[#124](#124))
([bb96256](bb96256))
* **agents:** run agent git inside the sandbox with unsigned commits
(furedea/dotfiles[#172](#172))
([1492f3e](1492f3e))
* **agents:** start Herdr Claude lanes on Sonnet at medium effort
(furedea/dotfiles[#257](#257))
([3caf8d5](3caf8d5))
* **agents:** write PR bodies inline and close lanes' parent workspaces
(furedea/dotfiles[#211](#211))
([8c6df4e](8c6df4e))
* **claude:** close the sandbox escape and reach the Nix daemon inside
(furedea/dotfiles[#191](#191))
([b61f2ac](b61f2ac))
* **claude:** let Go CLIs verify TLS inside the sandbox
(furedea/dotfiles[#167](#167))
([282b3d2](282b3d2))
* **claude:** let sandboxed commands listen on local ports
(furedea/dotfiles[#206](#206))
([36c09d2](36c09d2))
* **claude:** run the Codex plugin companion outside the sandbox
(furedea/dotfiles[#232](#232))
([0255159](0255159))
* **codex:** let Codex write, test, and deliver inside the sandbox
(furedea/dotfiles[#200](#200))
([33a0a82](33a0a82))
* compose Herdr and Moshi agent hooks
(furedea/dotfiles[#33](#33))
([4951ee8](4951ee8))
* **dsh:** add the dsh hook adapter
([#101](#101))
([db86f57](db86f57))
* **git-commit-split:** accept mode from slash-command argument
([10c3ef7](10c3ef7))
* **git-commit-split:** modularize commit splitting workflow with branch
([bab6f19](bab6f19))
* **github:** add repository creation script
([1a7910b](1a7910b))
* **hermes:** use Apple Mail for mail access
(furedea/dotfiles[#69](#69))
([94268fa](94268fa))
* **hooks:** add related test selection rules
([2aca101](2aca101))
* **hooks:** add shared audit and command guard hooks
([6ab33b5](6ab33b5))
* **hooks:** allow read-only local curl diagnostics and log syntax ask
kinds
(furedea/dotfiles[#287](#287))
([83cd643](83cd643))
* **hooks:** ask before an agent adds a lint suppression
(furedea/dotfiles[#214](#214))
([b767665](b767665))
* **hooks:** ask only for effects that escape the sandbox
(furedea/dotfiles[#163](#163))
([21409a5](21409a5))
* **hooks:** block destructive non-push git operations
([cc02cb4](cc02cb4))
* **hooks:** escalate unrecognized command forms to a prompt
(furedea/dotfiles[#159](#159))
([e30de17](e30de17))
* **hooks:** fast-forward main after cleaning up merged lanes
(furedea/dotfiles[#210](#210))
([f8a60af](f8a60af))
* **hooks:** honor project allow rules only from trusted owners
([#33](#33))
([305d391](305d391))
* **hooks:** improve lint-format feedback across providers
([8a512f6](8a512f6))
* **hooks:** judge heredocs, substitutions, loops, and redirections
structurally
(furedea/dotfiles[#175](#175))
([9276283](9276283))
* **hooks:** let sessions lock flake inputs and close their own lanes
(furedea/dotfiles[#208](#208))
([f109b49](f109b49))
* **hooks:** let the parent run cleanup_worktrees.py after merge
(furedea/dotfiles[#300](#300))
([fc44c74](fc44c74))
* **hooks:** remove merged task worktrees and branches at session start
(furedea/dotfiles[#185](#185))
([2701e0b](2701e0b))
* **hooks:** replay recent commands through the hooks
(furedea/dotfiles[#199](#199))
([2ed4984](2ed4984))
* **hooks:** report ast-grep rule findings after an edit
([#119](#119))
([ff91d8c](ff91d8c))
* **hooks:** review only commands that reach past the sandbox
(furedea/dotfiles[#178](#178))
([40c97da](40c97da))
* **hooks:** run zizmor offline after workflow edits
(furedea/dotfiles[#295](#295))
([79b66a6](79b66a6))
* **hooks:** scan with the shared ast-grep rules shipped beside the
hooks ([#121](#121))
([35a9270](35a9270))
* **hooks:** support Go projects in formatting, verification, and
permissions ([#57](#57))
([5506f3c](5506f3c))
* **hooks:** verification selection, unified patch input,
formatter/linter ordering
(furedea/dotfiles[#144](#144))
([99a825b](99a825b))
* **lint:** add the first ten ast-grep rules and drop the prose they
replace ([#117](#117))
([c235eb5](c235eb5))
* **nix:** expose the plain agents path as passthru.tree of agent-source
([#94](#94))
([63632e4](63632e4))
* **security:** add a program_path option that pins a rule's program to
one absolute path
([#61](#61))
([d629ca9](d629ca9))
* **security:** allow agent-browser and agent-desktop except named risky
forms ([#63](#63))
([8dc8da5](8dc8da5))
* **security:** allow cargo caches, crates.io, and OSV in the sandbox
([#60](#60))
([2f29423](2f29423))
* **security:** allow Go caches and module hosts in the sandbox
([#58](#58))
([4b3a35c](4b3a35c))
* **security:** ask for every docker form the allowlist does not list
([#54](#54))
([764374f](764374f))
* **security:** deny the 1Password CLI and keep the Codex login in the
keyring ([#52](#52))
([0580825](0580825))
* **skill-auditor:** support Codex audit workflow
([0d88c3f](0d88c3f))
* **skills:** add measurement-evidence and change-type evidence to tsdd
([#70](#70))
([85714b5](85714b5))
* **skills:** clarify names and add Herdr delegation
(furedea/dotfiles[#127](#127))
([e6576ba](e6576ba))
* **skill:** skill-auditor by nyosegawa/skills/skill-auditor
([f191132](f191132))
* **skills:** render provider-specific SKILL.md frontmatter
([44325e5](44325e5))
* **statusline:** render the status on one line
(furedea/dotfiles[#110](#110))
([03ad85e](03ad85e))
* update bash-style skill instructions
([9ab1d65](9ab1d65))
* update github-ci-init skill templates
([d238f51](d238f51))
* verify agent changes through native hooks
(furedea/dotfiles[#106](#106))
([923b0ae](923b0ae))


### Bug Fixes

* **agents:** accept generated command permissions
(furedea/dotfiles[#66](#66))
([0af9650](0af9650))
* **agents:** allow gh api reads that pass --allow-escape-sequences
(furedea/dotfiles[#265](#265))
([e732939](e732939))
* **agents:** apply harness review findings
(furedea/dotfiles[#149](#149))
([c8a51d7](c8a51d7))
* **agents:** cap Codex session-end timeout
([2f29a7e](2f29a7e))
* **agents:** deny codex-companion calls the sandbox exclusion cannot
match
(furedea/dotfiles[#269](#269))
([25518ab](25518ab))
* **agents:** harden hooks and separate workflow responsibilities
(furedea/dotfiles[#128](#128))
([7e508c4](7e508c4))
* **agents:** let pnpm fetch from the npm registry inside the sandbox
(furedea/dotfiles[#222](#222))
([ac114e8](ac114e8))
* **agents:** let the forbidden rule admit Sonnet lane arguments
(furedea/dotfiles[#259](#259))
([f1b29a9](f1b29a9))
* **agents:** make the bootstrap hint work for POSIX login shells
([c2667fa](c2667fa))
* **agents:** stop asking for commands the hooks can prove safe
(furedea/dotfiles[#242](#242))
([a93d241](a93d241))
* **agents:** wait for hook state locks instead of failing with EAGAIN
(furedea/dotfiles[#285](#285))
([673c108](673c108))
* allow secret scanner hook files
([bca4207](bca4207))
* **bootstrap:** give Codex the agent GitHub token settings and run the
bootstrap in CI
([#21](#21))
([25de080](25de080))
* **bootstrap:** keep Neovim's fallback nvim.log out of the working
directory ([#43](#43))
([3c9fc5c](3c9fc5c))
* **bootstrap:** make the server bootstrap behave like the Nix hosts
([#15](#15))
([4554dec](4554dec))
* **bootstrap:** print actionable profile and legacy-file messages only
when needed ([#49](#49))
([1918254](1918254))
* **bootstrap:** target the login profile bash actually reads
([#50](#50))
([0dae5bf](0dae5bf))
* **bootstrap:** verify downloaded tools against pinned checksums
([#111](#111))
([1744df3](1744df3))
* **ci:** install the locked agent-harness instead of reading it from
the flake
([bc2395b](bc2395b))
* **ci:** provide the shell format config and locked JavaScript tools
([dd59634](dd59634))
* **claude:** trust only the CA store bundled with Claude Code
(furedea/dotfiles[#284](#284))
([34be271](34be271))
* **codex:** fall back to auth.json when no keyring is available
([#62](#62))
([79b6ceb](79b6ceb))
* correct agent tooling and Hister activation
(furedea/dotfiles[#85](#85))
([4bab065](4bab065))
* honor pytest testpaths and bootstrap bats on servers
(furedea/dotfiles[#116](#116))
([b17b59e](b17b59e))
* **hooks:** allow double quoted commit messages
([fc4afd4](fc4afd4))
* **hooks:** bound curl -o, -d and -H in the localhost rule
(furedea/dotfiles[#291](#291))
([7c9db8a](7c9db8a))
* **hooks:** close shell-syntax bypasses of the guard hooks
([#11](#11))
([c6aacdf](c6aacdf))
* **hooks:** close the guard contract gaps from
[#11](#11) review
([#31](#31))
([db318db](db318db))
* **hooks:** deny codex-companion calls whose text holds a dollar sign
or backtick
(furedea/dotfiles[#290](#290))
([f37c317](f37c317))
* **hooks:** find GNU grep on PATH instead of the first grep
(furedea/dotfiles[#193](#193))
([99ba317](99ba317))
* **hooks:** format without dotfiles-installed dprint and prettier
configs ([#16](#16))
([db21f55](db21f55))
* **hooks:** ignore git-ignored sources when judging a project removed
([#22](#22))
([97c6b93](97c6b93))
* **hooks:** ignore prose arguments when matching forbidden patterns
(furedea/dotfiles[#189](#189))
([d2049d6](d2049d6))
* **hooks:** judge each command as one line with any grep
(furedea/dotfiles[#196](#196))
([202f937](202f937))
* **hooks:** keep merged worktrees holding non-regenerable ignored files
([#29](#29))
([ac03cfa](ac03cfa))
* **hooks:** keep the first grep when no GNU grep is on PATH
(furedea/dotfiles[#195](#195))
([a0e6a2f](a0e6a2f))
* **hooks:** keep the verification snapshot from locking out symlinked
or large worktrees
([#66](#66))
([7d13f0e](7d13f0e))
* **hooks:** let cleanup_worktrees remove Claude Code session files
([#36](#36))
([0a910bc](0a910bc))
* **hooks:** let cleanup_worktrees tests choose the untrusted locations
(furedea/dotfiles[#306](#306))
([e82980e](e82980e))
* **hooks:** let GitHub API reads take an unquoted jq filter
(furedea/dotfiles[#198](#198))
([5b6210a](5b6210a))
* **hooks:** make stop verification reliable
(furedea/dotfiles[#81](#81))
([04a33dd](04a33dd))
* **hooks:** preserve verification evidence
(furedea/dotfiles[#87](#87))
([4b5b9c2](4b5b9c2))
* **hooks:** redirect sandbox-failing Git forms and drop covered prompts
(furedea/dotfiles[#180](#180))
([34e39a7](34e39a7))
* **hooks:** resolve Rust integration test targets inside tests
subdirectories
(furedea/dotfiles[#304](#304))
([2ccf547](2ccf547))
* **hooks:** respect project formatters and bound diagnostics
(furedea/dotfiles[#131](#131))
([30e83cf](30e83cf))
* **hooks:** scope generic secret regex to quoted values
([fc09292](fc09292))
* **hooks:** silence successful hook execution
([795d8f0](795d8f0))
* **hooks:** skip JavaScript triggers in projects without JavaScript
tests
(furedea/dotfiles[#161](#161))
([dc80e28](dc80e28))
* **hooks:** skip verification for a language whose project was removed
([#6](#6))
([4a9f325](4a9f325))
* **hooks:** support relocated harness assets
(furedea/dotfiles[#82](#82))
([59057bc](59057bc))
* **hooks:** treat any gh api call without write flags as a read
(furedea/dotfiles[#201](#201))
([3ecb215](3ecb215))
* **hooks:** treat glob characters inside double quotes as literal for
literal_words rules
([#41](#41))
([174a7f9](174a7f9))
* **hooks:** use agent-neutral guidance
([37153ce](37153ce))
* improve agent notifications and session setup
(furedea/dotfiles[#92](#92))
([9bf2349](9bf2349))
* load secret patterns from hook directory
([ca465ef](ca465ef))
* migrate dotfiles path to ghq convention
([faff774](faff774))
* **nix:** build CPython 3.15.2 for the ssl eMudhra denylist
([#113](#113))
([faba045](faba045))
* **nix:** default editor to Neovim
(furedea/dotfiles[#105](#105))
([2a9a22a](2a9a22a))
* resolve hook directory from bash source
([c6ca454](c6ca454))
* restore SSH signing and reliable Bats verification
(furedea/dotfiles[#91](#91))
([891adce](891adce))
* **sandbox:** deny writes to every repository's git hooks and config
(furedea/dotfiles[#298](#298))
([1941513](1941513))
* **sandbox:** match the Codex plugin script under any numeric version
(furedea/dotfiles[#302](#302))
([a49ddc3](a49ddc3))
* **security:** allow the Go checksum tree head and vulnerability
database in the sandbox
([#59](#59))
([af6e158](af6e158))
* **security:** ask for every script a non-bash shell receives
([#99](#99))
([f88f8fd](f88f8fd))
* **security:** close quoted-argument and wrapper bypasses in the
command guard ([#76](#76))
([5f72757](5f72757))
* **security:** close the remaining command guard bypasses
([#83](#83))
([0387739](0387739))
* **security:** decide not-a-fork for project rules on hosts without gh
([#67](#67))
([acaa758](acaa758))
* **security:** keep agent-browser and agent-desktop calls inside the
sandbox ([#64](#64))
([3f2d578](3f2d578))
* **security:** read more of the scripts handed to fish and PowerShell
for deny rules
([#110](#110))
([2c652bb](2c652bb))
* **skills:** audit Codex skill observations
(furedea/dotfiles[#88](#88))
([f429967](f429967))
* **skills:** refine routing triggers from audit
([cef3b9c](cef3b9c))
* **tests:** make git test wrappers exec the real git binary
(furedea/dotfiles[#310](#310))
([893c405](893c405))
* **tests:** stop shifting past the codex wrapper arguments
([eb0f6d7](eb0f6d7))


### Performance Improvements

* **hooks:** evaluate policy regexes with one grep and run pytest in
parallel
(furedea/dotfiles[#125](#125))
([ce80ea3](ce80ea3))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
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.

1 participant