Skip to content

chore(security): 🔒 カスタム .gitleaks.toml による PII (個人情報) 検知強化 - #194

Merged
genzouw merged 5 commits into
mainfrom
chore/security-gitleaks-pii-email-601686326237424699
Jun 5, 2026
Merged

genzouw merged 5 commits into
mainfrom
chore/security-gitleaks-pii-email-601686326237424699

Conversation

@genzouw

@genzouw genzouw commented Jun 4, 2026

Copy link
Copy Markdown
Owner

背景

本リポジトリではすでに gitleaks を利用してローカルの pre-commit や CI でシークレットの流出を防いでいますが、デフォルトの gitleaks ルールでは高エントロピーのAPIキーなどは効果的に検知できるものの、一般的なメールアドレス等の個人情報(PII)のハードコードはデフォルトでは対象外となっています。

現状認識(事前調査結果のサマリー)

  • 既存防御策: gitleaks.yml, codeql.yml, trivy.yml, trufflehog.yml および .husky/pre-commit 導入済み
  • 未カバー領域: カスタムルールが定義されておらず、PII(メールアドレス)やドメイン特有のシークレット検知がデフォルトルール任せになっている
  • 直近の漏洩リスク兆候: 特になし(クリーンな状態)

このPRで導入・強化するもの

  • 対象: 新規 .gitleaks.toml 追加、docs/security/leak-prevention.md の更新
  • ツール名とバージョン: gitleaks (既存のバージョンを利用)
  • 期待される効果: ソースコード等に意図せず実在のメールアドレス等の個人情報(PII)がハードコードされ、公開リポジトリへコミットされるのを事前にブロックします。

検知漏れリスクと補完策

  • 検知できないケース: 一般的な文字列や、allowlist に指定されたダミードメイン(example.com など)
  • 補完策: 既存の GitHub Secret Scanning や、プルリクエストのレビューによる目視確認を併用

マージ前に必要な手動作業(チェックリスト)

レビュアーは PR をマージする前に必ず以下を実施してください。
本 PR の CI は手動作業完了を前提に通る設計です。

  • (特になし) 設定の追加のみのため、手動作業は不要です

マージ後の確認手順

  • 次の push / PR で gitleaks ワークフローが正常に green になることを確認
  • ローカルで gitleaks detect がカスタムルールを含めて動作することを確認

ロールバック手順

本 PR による変更(.gitleaks.toml)を削除(revert)することで、元のデフォルトルールのみの検知に即座に戻ります。

参考情報


PR created automatically by Jules for task 601686326237424699 started by @genzouw

Summary by CodeRabbit

  • セキュリティ向上

    • 個人情報(メールアドレス)のハードコード検知ルールを追加し、セキュリティスキャンの検知精度を強化しました。除外リストで特定ドメインからの検知を制御できるようになりました。
  • ドキュメント

    • セキュリティ検知のカスタムルール適用についてのドキュメントを更新しました。

- リポジトリ直下に `.gitleaks.toml` を作成し、デフォルトのルールに加えてハードコードされたメールアドレス(個人情報)を検知するカスタムルールを追加しました
- 誤検知を防ぐため `example.com`, `test.com`, `dummy.com`, `genzouw@gmail.com` の allowlist を設定しました
- セキュリティガイドライン (`docs/security/leak-prevention.md`) に、カスタムルールの適用に関する記述を追記しました

Co-authored-by: genzouw <29957+genzouw@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@genzouw, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 3 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b1163b38-62a9-4836-b491-1af17352654e

📥 Commits

Reviewing files that changed from the base of the PR and between 00a236f and b350a54.

📒 Files selected for processing (1)
  • .gitleaks.toml
📝 Walkthrough

Walkthrough

.gitleaks.toml に Gitleaks デフォルトルール保持とメールアドレスハードコード検知ルール(monopo-pii-email)を追加し、許可リストで特定ドメインや指定メールアドレスを除外対象に設定しました。これとあわせてセキュリティドキュメントを更新し、カスタムルール適用の説明を追加しました。

Changes

Gitleaksカスタムメール検知設定

Layer / File(s) Summary
Gitleaksメール検知ルール設定
.gitleaks.toml
デフォルトルール保持下で、メール形式の正規表現を用いた検知ルール(ID: monopo-pii-email、タグ: pii/email)を追加し、特定ドメインと genzouw@gmail.com を許可リストに設定しました。
セキュリティドキュメント更新
docs/security/leak-prevention.md
Gitleaks CI スキャンで .gitleaks.toml のカスタムルールを使用し、デフォルトに加えて PII 検知ルールも適用する旨を記載しました。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 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 タイトルはカスタム .gitleaks.toml によるセキュリティ強化と PII 検知の導入という、PR の主要な目的を明確に反映しており、ファイル変更の概要とも一致しています。
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/security-gitleaks-pii-email-601686326237424699

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.

@github-actions github-actions Bot added the docs label Jun 4, 2026

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.gitleaks.toml:
- Line 9: Replace the current regex value in the "regex = '''...'''" entry with
an improved pattern that enforces: local and domain parts start and end with
alphanumeric characters, no consecutive dots (..), domain labels cannot start or
end with a hyphen, and a word boundary to avoid partial matches; keep the
case-insensitive flag (?i) and the multiline/triple-quoted string format when
updating the value so gitleaks still reads it correctly.
- Around line 13-19: Update the allowlist regexes under [rules.allowlist] so
they only match email-domain endings instead of substrings: change entries like
"example\.(com|org|net)" and "test\.(com|org|net)" to anchor with an email
local-part prefix and end-of-string (e.g., prepend "@" and append "$") so they
match "`@example`\.(com|org|net)$", "`@test`\.(com|org|net)$",
"`@dummy`\.(com|org|net)$"; additionally add a rule for invalid TLD emails such as
"@.*\.invalid$" if you want to allow "*.invalid" addresses; ensure the patterns
remain properly escaped and placed in the regexes array in .gitleaks.toml under
rules.allowlist.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 771e7f6c-3de9-4191-827d-c624d5560255

📥 Commits

Reviewing files that changed from the base of the PR and between 54340b9 and 00a236f.

📒 Files selected for processing (2)
  • .gitleaks.toml
  • docs/security/leak-prevention.md

Comment thread .gitleaks.toml Outdated
Comment thread .gitleaks.toml
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

本プルリクエストは、Gitleaksによるシークレット検知機能を強化し、ソースコードへの個人情報(メールアドレス)の混入を未然に防ぐことを目的としています。既存のデフォルトルールを拡張する形でカスタム設定を導入し、開発プロセスにおけるセキュリティの堅牢性を向上させます。

Highlights

  • カスタムGitleaksルールの導入: リポジトリ直下に .gitleaks.toml を追加し、デフォルトの検知ルールに加えてメールアドレス等の個人情報(PII)のハードコードを検知するカスタムルールを定義しました。
  • ドキュメントの更新: セキュリティ対策ドキュメント(docs/security/leak-prevention.md)を更新し、カスタムルールの適用について追記しました。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

このプルリクエストでは、メールアドレス(PII)のハードコードを検知するためのカスタムGitleaksルール(.gitleaks.toml)が追加され、関連するセキュリティドキュメントが更新されました。レビューでは、特定の個人メールアドレスが allowlist にハードコードされているセキュリティおよびプライバシー上の問題と、広範な正規表現によるロックファイル等での誤検知を防ぐための除外設定(グローバル allowlist)の検討が指摘されています。

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread .gitleaks.toml Outdated
Comment thread .gitleaks.toml
genzouw added 3 commits June 5, 2026 06:50
連続ドット(..)、ドメインラベルの不正なハイフン位置、単語境界なしのマッチを防ぐ
改善版正規表現に変更。誤検知・検知漏れリスクを軽減する。

レビューコメント: #194 (comment)
レビュアー: coderabbitai
優先度: high
allowlist の正規表現をサブストリングマッチから @Domain$ 形式に変更し過剰許可を防ぐ。
個人メールアドレス genzouw@gmail.com をリポジトリ共通設定から削除し、
*.invalid ドメインの除外ルールを追加した。

レビューコメント: #194 (comment)
レビューコメント: #194 (comment)
レビュアー: gemini-code-assist, coderabbitai
優先度: high, medium
package-lock.json・pnpm-lock.yaml・yarn.lock 等のロックファイルは
メールアドレスに見える文字列を多く含むため、グローバル allowlist で
スキャン対象から除外し誤検知(False Positive)を防ぐ。

レビューコメント: #194 (comment)
レビュアー: gemini-code-assist
優先度: low
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 4, 2026
SECURITY.md は脆弱性報告の連絡先として意図的にメールアドレスを公開する
慣例的な場所であり、新規追加された monopo-pii-email ルールの対象から除外する。
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant