Skip to content

fix(hooks): judge a ~user path by the secret-path rules of the own home - #129

Merged
furedea merged 2 commits into
mainfrom
fix/126-tilde-user-secret-path
Nov 10, 2026
Merged

furedea merged 2 commits into
mainfrom
fix/126-tilde-user-secret-path

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

概要

cat ~root/.aws/credentials のように glob を含まない ~user のパスが,展開されないまま ~/.aws/** などの規則と文字で照合され,通っていた抜けを塞ぐ.

設計

層 変更 理由
secret_path_policy.normalize ~user/... を ~/... として照合する 規則は .aws や .ssh など名前で秘密を指す.他人のホームでも同じ名前は同じ秘密なので,規則を複製せず自分のホーム基準のまま安全側に倒せる.展開後の絶対パスを照合する案は,ホームの場所(/var/root など)ごとに規則を持つ必要があり採らない
shell_paths.checked_home glob 以外の語でも先頭の ~user を確認し,ホームが不明なら UnexpandableGlob(確認に回す) #125 の known_home(旧 glob 内の展開)を共有
shell_paths.expanded_paths ~user の glob の一致結果を ~user/... の名前で返す 上の normalize が同じ規則で扱えるようにする

guard_file の確認

Edit/Write の対象は provider_adapter.check_paths から同じ blocked_rule を通るので,normalize の修正で ~root/.aws/credentials も止まる.guard_file.protected_reason は自分の harness ファイルの一致を見るもので,home_expanded が既に ~user を展開し,不明なユーザーは文字のまま(どの保護パスにも一致しない).他人のホームの harness ファイルは境界の対象外なので変更しない.

検証

  • ruff check / ruff format --check / ty check / pytest(4538 passed, 1 skipped)
  • 追加したテスト:~root/.aws/credentials が止まる,~no-such-user/... が確認に回る,~root/notes.txt は通る,~root の glob の一致が ~root/... で返る

Closes #126

🤖 Generated with Claude Code

A non-glob word such as ~root/.aws/credentials was matched literally
against rules written for ~/.aws/**, so it passed. The policy now reads
~user/... as ~/..., and shell_paths refuses a leading ~user the system
does not know, as it already did for globs. Glob matches under ~user keep
the ~user prefix so the same rules apply to them.

Closes #126

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

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T13:48:51.066187Z
We couldn’t complete this review. Comment @codex review to try again.
6563611 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

レビュー結果

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

確認した点:

  • normalize: ~user/... は ~/... として照合される.~/...,$HOME/...,絶対パスの扱いは変わらない(正規表現は / の前に最低1文字を要求するので,~/ には一致しない).
  • expanded_paths: 自分のホームの glob の一致は,絶対パスではなく ~/... で返るようになった.normalize は両方の形を同じように扱うので,判定は変わらない.
  • checked_home は glob 以外の語でも UnexpandableGlob を投げるようになった.唯一の呼び出し元である provider_adapter.check_paths は,command_paths 全体をこの例外の try で囲み,確認に回す.なので,呼び出し元が捕まえない例外は起きない.
  • 引用符付き(静的)の '~root/.aws/credentials' も新しい normalize で止まるようになった.これは安全側に倒す変更で問題ない.
  • 追加されたテストは,変更した振る舞い(不明なユーザー,他人のホームの秘密,害のないファイル,glob の一致の名前)を網羅している.

補足:このレビュー環境では pytest を実行できなかった(実行の承認が得られなかった)ので,CI の結果に頼っている.

Relabeling a match as ~user/... alone dropped the real path, so a rule
written for an absolute path could be missed, and a home of / produced a
broken label. Return both forms and relabel only matches inside the home.

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

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

レビュー結果

指摘事項はありません(P0〜P3 なし).

確認した点:

  • normalize の正規表現は自分のホームの ~/... には一致せず,他ユーザーのホーム(~user/...)だけを ~/... に書き換える.~+ / ~- も同様に扱われるが,安全側に倒れるだけ.
  • checked_home はリダイレクト先や代入値を含む展開対象の語すべてに適用され,不明なユーザーは既存の UnexpandableGlob 経路で確認に回る.
  • expanded_paths は実パスに加えて ~user/... の形も返すので,どちらの形向けに書かれた規則も適用される.
  • 引用符付き(静的引数)の ~root/... も normalize で止まる.展開されない文字列としては誤検知寄りだが,安全側の挙動.

なお,この環境ではテストを実行できなかったため,上記はコードを読んでの確認です.

@furedea
furedea merged commit 64221f6 into main Nov 10, 2026
22 of 24 checks passed
@furedea
furedea deleted the fix/126-tilde-user-secret-path branch November 10, 2026 14:10
furedea pushed a commit that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.1](v0.1.0...v0.1.1)
(2026-11-11)


### Features

* **hooks:** judge session changes with jev-lint model rules at Stop
([#150](#150))
([946e976](946e976))


### Bug Fixes

* **hooks:** ask for zsh's $=name and $~name expansions
([#152](#152))
([9255c87](9255c87))
* **hooks:** judge a ~user path by the secret-path rules of the own home
([#129](#129))
([64221f6](64221f6))
* **hooks:** match static words by their single-quoted form in precise
command rules
([#147](#147))
([c432a20](c432a20))
* **hooks:** run verification tools through the flake dev shell
([#132](#132))
([63dd2f5](63dd2f5))
* **hooks:** start trusted model-rule programs and send only
in-repository regular files
([#156](#156))
([183496b](183496b))

---
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.

fix(hooks): a non-glob ~user path skips the secret-path policy

1 participant