Skip to content

chore(security): 🔒 gitleaks による インフラ構成・内部エンドポイント 強化 - #340

Merged
genzouw merged 5 commits into
mainfrom
security/gitleaks-internal-domain-10554591122347611058
Jul 5, 2026
Merged

genzouw merged 5 commits into
mainfrom
security/gitleaks-internal-domain-10554591122347611058

Conversation

@genzouw

@genzouw genzouw commented Jul 5, 2026

Copy link
Copy Markdown
Owner

背景

事前調査の結果、対象リポジトリには gitleaks, detect-secrets, trivy など多数の強力なシークレット検知ツールが導入されており、AI エージェントの作業跡等も適切にブロックされていることを確認しました。しかし、インフラ構成の過剰露出という観点において、内部IPはカバーされているものの、内部ドメインや社内エンドポイント(.internal, .local, .corp等)の不要な露出を防止するカスタムルールが .gitleaks.toml に不足していることが判明しました。

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

  • 既存防御策: gitleaks.yml, trivy.yml, codeql.yml, huskyによるローカルフック、pre-commit-config.yaml 導入済み。
  • 未カバー領域: 内部ネットワークのドメイン(.internal, .local 等)やステージング用エンドポイントのハードコード検知ルールが存在しない。
  • 直近の漏洩リスク兆候: 特になし(.env や認証情報のコミット痕跡は見当たらず、非常に堅牢)。

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

  • 対象: 既存の .gitleaks.toml へのカスタムルールの追記
  • ツール名とバージョン: gitleaks v8.x
  • 期待される効果: ソースコード内に .internal.local といった内部インフラ向けのエンドポイントがハードコードされた場合に、コミット前検知(ローカル)および CI(全履歴スキャン)で確実に検知して流出を防ぐ。

検知漏れリスクと補完策

  • 検知できないケース: 一般的なパブリックドメインを利用した社内向けサービスや、IPアドレス(既存のルールで一部カバー済み)以外の未知の内部FQDN。
  • 補完策: 既存の GitHub Secret Scanning および trivy の misconfig スキャンと組み合わせて二重化し、定期的な監査を行う。

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

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

  • 開発チーム全体へ、内部ドメインをハードコードする代わりに環境変数を利用するよう周知する。

マージ後の確認手順

  • 次の push / PR で導入した workflow が green になることを確認。
  • ローカルで .internal のような文字列を追加してコミットしようとした際、gitleaks がフックとして動作しブロックすることを確認。

ロールバック手順

問題が出た場合は、対象コミットを revert し、.gitleaks.toml から monopo-internal-domain ルールを削除して対応してください。

参考情報


実行サマリー

  • 対象リポジトリ: genzouw/monopo
  • 事前調査で把握した特徴: Node.js/TypeScript/Bunを用いた構成。既存の漏洩防止策(Gitleaks, Trivy, CodeQL等)が非常に強力に整備されており、既に多層防御が確立している。
  • 選定した観点: コミット前 / CI 検知(既存ルールのカバレッジ拡張)
  • 選定したツール(または強化対象): gitleaks (カスタムルールの追加)
  • 比較検討した他案: ReviewdogによるGitleaks結果のインラインコメント化(SARIFアップロードでカバー済みと判断)、TruffleHogフック追加(ローカルのネットワークアクセス遅延の観点で却下)。
  • 作成した PR: (自動生成されるためURL省略)
  • 重複防止チェックの結果: open/closed PRの中に内部ドメイン検知に関連するものは存在しないことを確認。
  • マージ前に手動が必要な作業の件数: 1 件
  • 次回(来週)以降に取り組むべき残課題: 依存関係のSBOM監査における対象エコシステム拡張の検討。

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

Summary by CodeRabbit

  • New Features
    • 内部ドメインや社内向けエンドポイントのハードコードを検知・ブロックするチェックが追加されました。
  • Documentation
    • 秘密情報・内部情報の漏えい防止ガイドに、インフラ構成や内部エンドポイントの露出防止に関する説明を追記しました。

Signed-off-by: Jules <jules@example.com>

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 →

@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 に新しいルール 'monopo-internal-domain' を追加し、内部ネットワークや社内エンドポイント(.internal, .local, .corp 等)のハードコードを検知・ブロックするようにしました。
  • ドキュメントの更新: 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.

@github-actions github-actions Bot added the docs label Jul 5, 2026
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0235e70b-bd53-4e48-b563-35b08c19c1b0

📥 Commits

Reviewing files that changed from the base of the PR and between e17bd0c and 25daddd.

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

Walkthrough

.gitleaks.toml に内部/社内ドメイン(internal、local、corp、staging.monopo.com など)のハードコードを検知する新規ルール monopo-internal-domain を追加し、docs/security/leak-prevention.md にその検知内容を説明する節を追記した。

Changes

内部ドメイン漏洩検知の追加

Layer / File(s) Summary
検知ルール追加とドキュメント更新
.gitleaks.toml, docs/security/leak-prevention.md
内部ドメインをハードコードから検知する正規表現ルール(タグ、secretGroup、entropy含む)を追加し、対応するドキュメント節を追記した。

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

  • genzouw/monopo#194: 同様に .gitleaks.toml にカスタムルールを追加し、docs/security/leak-prevention.md に対応するドキュメントを追記している。
  • genzouw/monopo#100: docs/security/leak-prevention.md を更新し、gitleaks運用について同様のドキュメント追記を行っている。
  • genzouw/monopo#223: pre-commitのgitleaksフックを導入しており、本PRの内部ドメイン検知ルールと連動する変更である。
🚥 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 タイトルは gitleaks で内部ドメインや内部エンドポイントの検知を強化する変更内容を適切に要約しています。
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch security/gitleaks-internal-domain-10554591122347611058

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.

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

@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

このプルリクエストでは、内部ネットワークや社内エンドポイントのハードコードを検知・ブロックするためのカスタムルール monopo-internal-domain.gitleaks.toml に追加し、セキュリティドキュメントを更新しています。レビューでは、現在の正規表現がサブドメインを必須としているため、サブドメインのない staging.monopo.com 自体が検知されないという問題が指摘されており、正規表現の修正が提案されています。

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

@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 60: The current Gitleaks regex in .gitleaks.toml matches .local too
broadly and can cause false positives for common mDNS/development hostnames.
Update the rule or the existing [rules.allowlist] to exempt known benign .local
patterns such as typical local hostnames, keeping the unique identifiers regex
and allowlist entries aligned with the intended secret-detection scope. Refine
the pattern or add a targeted allowlist entry so legitimate .local references
are not flagged while preserving detection for real secrets.
- Around line 56-63: The `monopo-internal-domain` rule’s regex currently only
matches `staging.monopo.com` as a subdomain suffix, so the standalone domain in
the documented examples is missed. Update the `regex` in this rule to split
`staging\.monopo\.com` into its own alternation branch, while keeping the
existing internal/local/corp matching behavior unchanged.
🪄 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: c746ddbe-2fde-4ff1-bdf2-7b92fc6622e5

📥 Commits

Reviewing files that changed from the base of the PR and between f8b76a4 and e17bd0c.

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

Comment thread .gitleaks.toml
Comment thread .gitleaks.toml Outdated
genzouw added 2 commits July 6, 2026 06:38
現在の正規表現では staging.monopo.com 単体がハードコードされている場合に
検知できなかった。正規表現の先頭部分でサブドメインが必須となっていたため。

staging.monopo.com を独立した alternation branch に分離することで、
サブドメインなしの単体ドメインも検知できるよう修正した。

レビューコメント: #340 (comment)
レビュアー: gemini-code-assist
レビューコメント: #340 (comment)
レビュアー: coderabbitai
優先度: high
.local サフィックスは mDNS プロトコルや開発環境で広く使用されるため、
localhost.local / raspberrypi.local / printer.local などの一般的な
開発用ホスト名での誤検知(false positive)が発生しうる。

これらをallowlistに追加して誤検知を防止する。

レビューコメント: #340 (comment)
レビュアー: coderabbitai
優先度: low
Comment thread docs/security/leak-prevention.md Fixed
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 5, 2026
…t に追加

セキュリティドキュメント (docs/security/) がルール説明のために内部ドメイン名
(staging.monopo.com 等) を例示しており、monopo-internal-domain ルールの
false positive が発生していた。

[rules.allowlist] に paths エントリを追加し、docs/security/ 配下の
ドキュメントファイルをスキャン対象から除外することで解消。

レビューコメント: #340 (comment)
レビュアー: github-advanced-security
優先度: medium
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.

2 participants