Skip to content

feat(lint): 個人パス検出 lint rule (no-personal-paths) を追加#76

Merged
aloekun merged 1 commit intomasterfrom
feat/no-personal-paths-lint
Apr 25, 2026
Merged

feat(lint): 個人パス検出 lint rule (no-personal-paths) を追加#76
aloekun merged 1 commit intomasterfrom
feat/no-personal-paths-lint

Conversation

@aloekun
Copy link
Copy Markdown
Owner

@aloekun aloekun commented Apr 25, 2026

Summary

  • .claude/custom-lint-rules.tomlno-personal-paths ルールを追加
  • pattern: Windows (C:\Users\<実名>\) / Unix (/home/<実名>/) の絶対パスを検出
  • placeholder (<USER_NAME>, %USERPROFILE%, ~, $HOME) は character class で自動除外
  • extensions: md / txt 対象、severity: error
  • bad example はメタ的アイロニー回避のため fictional name (alice) を採用

Context

PR #75 (ADR-030 起案) の post-merge-feedback (ADR-014/030 dogfood) で得られた Tier 1 提案 を実装。

PR #75 では同種 PII 指摘が CodeRabbit Major で 3 箇所同時発生 (ADR-030 line 143、todo.md line 35/48)、PR #74 でも前例あり。頻出パターンとして Plankton Tier 1 (決定論的防止) で固定化する。

実装戦略: Rust regex 1.10 は lookahead 非対応のため、character class の開始位置 ([A-Za-z] / [a-z]) で placeholder を自動除外する。残る false positive は C:\Users\Public\ 等のシステム名のみで md docs では稀のため許容。

Validation

  • cargo test -p hooks-post-tool-linter: 45 件全 PASS (regex compile 妥当性確認)
  • pnpm push quality gate: lint / test / build / rust-test 全 PASS
  • pre-push-review: simplicity-review + security-review 両方 APPROVE (all("approved")、5m16s)
  • runtime ロード (std::fs::read_to_string at src/hooks-post-tool-linter/src/main.rs:316) のため exe rebuild 不要

References

Summary by CodeRabbit

リリースノート

  • 新機能
    • ドキュメント内の個人識別情報を含むファイルパスを検出する新しい検証ルールを追加しました。ユーザー名を含む絶対パスを自動で特定し、セキュアなプレースホルダー表記への置き換えを提案することで、ドキュメント共有時の個人情報保護を強化します。

PR #75 の post-merge-feedback で得られた Tier 1 提案を実装。

custom-lint-rules.toml に新規 rule を追加:
- pattern: 'C:\Users\[A-Za-z][A-Za-z0-9_-]+\|/home/[a-z][a-z0-9_-]+/'
- extensions: md / txt
- severity: error
- placeholder (<USER_NAME>, %USERPROFILE%, ~/, $HOME) は character class
  ([A-Za-z] / [a-z]) で開始位置を縛り自動除外

由来: PR #75 で同種 PII 指摘が 3 箇所同時発生 (ADR-030 line 143、
todo.md line 35/48)。PR #74 でも前例あり、CodeRabbit Major 指摘の
頻出パターンとして Plankton Tier 1 (決定論的防止) で固定化する。

カスタムリンタは std::fs::read_to_string で runtime ロードのため
exe rebuild 不要。既存 45 件のリンターテスト全 PASS で regex 妥当性確認済。
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

ウォークスルー

.claude/custom-lint-rules.tomlno-personal-pathsリントルールを追加。ドキュメントファイル(mdtxt)内のハードコードされた絶対パスと個人特定可能なパス(C:\Users\.../home/...)を検出し、プレースホルダー(%USERPROFILE%~など)への置換を提案するエラーレポート機能。

変更

コホート / ファイル 概要
カスタムリントルール追加
.claude/custom-lint-rules.toml
no-personal-pathsリントルールを新規追加。パターンマッチング、エラー重度度設定、メッセージ、修正手順、実装例を含む包括的な設定を定義。

推定コード審査工数

🎯 2 (Simple) | ⏱️ ~10 分

関連の可能性のあるPR

  • #6: 同じカスタムリントシステムを修正対象とする関連PR。このPRがno-personal-pathsルールを追加する一方、当該PRはno-console-logルールとそれをサポートするエンジン/ドキュメント/ロガーを追加しており、連携して機能する内容となっている。
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRのタイトルは日本語で記述されており、no-personal-paths lintルールの追加という実装内容を明確に表現しています。変更セットの主要な目的(個人パス検出ルールの追加)と一致しており、チームメンバーが歴史を確認する際に主要な変更を理解できます。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@aloekun
Copy link
Copy Markdown
Owner Author

aloekun commented Apr 25, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.claude/custom-lint-rules.toml (1)

56-62: 末尾セパレータ非依存のケースを検出できない点を考慮ください(任意)

pattern は末尾の \\ / / を必須としているため、文末や句読点の直前に現れるケースが見逃されます。

  • 検出されない例: ログは C:\Users\alice にあります。
  • 検出されない例: ~/work と /home/alice を比較
  • 検出されない例: 1 文字ユーザー名 C:\Users\a\...+ のため username 最低 2 文字)

why で「PII 流出防止」を目的としている以上、末尾セパレータの有無で取りこぼすのはルール意図とずれる可能性があります。lookahead が使えない制約下でも、末尾を任意化することで検出範囲を広げられます。

♻️ パターン拡張案(末尾セパレータを任意化+1 文字ユーザー名対応)
-pattern = 'C:\\Users\\[A-Za-z][A-Za-z0-9_-]+\\|/home/[a-z][a-z0-9_-]+/'
+pattern = 'C:\\Users\\[A-Za-z][A-Za-z0-9_-]*[\\/ \t.,;:)"`]|/home/[a-z][a-z0-9_-]*[/ \t.,;:)"`]'

ポイント:

  • +* で 1 文字ユーザー名も許容
  • 末尾を [\\/ ...] のいずれかにすることで、句読点・スペース・引用符終端も検出
  • プレースホルダ除外戦略(先頭 [A-Za-z] / [a-z])はそのまま維持

なお、コメント(Lines 50-54)にこの新たなトレードオフ(句読点パターンを末尾文字クラスに固定する設計)の説明を追記しておくと、将来のメンテナにとって意図が明確になります。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/custom-lint-rules.toml around lines 56 - 62, The "no-personal-paths"
rule's pattern currently requires a trailing separator and a username of at
least two chars, so paths like "C:\Users\a" or "~/alice" at sentence end are
missed; update the rule id "no-personal-paths" to make the username quantifier
permissive (use * instead of + to allow 1-char names) and make the trailing
separator optional (so matches whether the path ends with a slash/backslash or
terminates before punctuation/whitespace); also update the adjacent comment
explaining this tradeoff (previous comment lines describing the pattern) to
document why the trailing-separator class was chosen and the implications for
false positives.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.claude/custom-lint-rules.toml:
- Around line 56-62: The "no-personal-paths" rule's pattern currently requires a
trailing separator and a username of at least two chars, so paths like
"C:\Users\a" or "~/alice" at sentence end are missed; update the rule id
"no-personal-paths" to make the username quantifier permissive (use * instead of
+ to allow 1-char names) and make the trailing separator optional (so matches
whether the path ends with a slash/backslash or terminates before
punctuation/whitespace); also update the adjacent comment explaining this
tradeoff (previous comment lines describing the pattern) to document why the
trailing-separator class was chosen and the implications for false positives.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 716efc28-1c46-422f-960e-e4d46ba00fe1

📥 Commits

Reviewing files that changed from the base of the PR and between 8434c6a and 16d658a.

📒 Files selected for processing (1)
  • .claude/custom-lint-rules.toml

@aloekun aloekun merged commit 65008b9 into master Apr 25, 2026
1 check passed
@aloekun aloekun deleted the feat/no-personal-paths-lint branch April 25, 2026 10:42
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