chore(security): 🔒 gitleaks カスタムルール拡張による AI サービス (Groq等) APIキー検知の強化 - #486
Conversation
…eepSeek) APIキー混入検知の強化 - .gitleaks.toml の `monopo-ai-api-key` ルールに Groq, OpenRouter, DeepSeek のパターンを追加 - docs/security/leak-prevention.md のドキュメント更新 Co-authored-by: genzouw <29957+genzouw@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGitleaksの ChangesAI APIキー検知対象の拡張
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodogitleaksのAI APIキー検知をGroq/OpenRouter/DeepSeek対応で拡張
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
34 rules 1.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 89: Update the regex in the gitleaks configuration to match Groq keys as
gsk_ followed by exactly 52 alphanumeric characters, with a terminating word
boundary so longer tokens are not partially matched. Preserve the other
credential patterns 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: 25083531-d4d8-43be-8dd1-1d13bd6f8226
📒 Files selected for processing (2)
.gitleaks.tomldocs/security/leak-prevention.md
monopo-ai-api-key ルールの汎用 sk-[a-f0-9]{32} パターンは、先頭・末尾の境界指定がなく、
task-xxx や risk-xxx のような無関係な識別子内の32桁hex部分にも部分一致し、
Gitleaks CI を不要に失敗させる可能性があった。\bsk-[a-f0-9]{32}\b として
単語境界を追加し、独立したトークンとして出現する場合のみ検知するように修正。
レビューコメント: #486 (comment)
レビュアー: qodo-code-review
優先度: high
Groq の API キーは gsk_ + 52桁の英数字が正しい仕様だが、monopo-ai-api-key
ルールでは gsk_[a-zA-Z0-9]{33} と桁数が誤っており、かつ末尾の境界指定もなかった
ため、本来のキーより短い/長いトークンの一部にも部分一致し得た。
gsk_[a-zA-Z0-9]{52}\b に修正し、正しい桁数のキーのみを、末尾が独立した
トークンである場合に限り検知するようにした。
レビューコメント: #486 (comment)
レビュアー: coderabbitai
優先度: high
背景
事前調査により、本リポジトリは
gitleaks,trufflehog,trivy,secretlint等の多層的な漏洩防御策が既に導入されており、高いセキュリティ水準を維持していることを確認しました。一方で、近年の AI アプリケーション開発で利用が増加している一部の最新 AI サービス(Groq, OpenRouter, DeepSeek 等)の API キーに対する検知パターンが既存のmonopo-ai-api-keyルールに含まれておらず、カバレッジ拡張の余地があることがわかりました。現状認識(事前調査結果のサマリー)
gitleaks.yml,codeql.yml,trivy.yml,secretlint.ymlや、Husky によるpre-commitおよびpre-pushフックが重厚に導入済み。.gitleaks.tomlにおけるmonopo-ai-api-keyは OpenAI と Anthropic 程度に留まっており、Groq や OpenRouter, DeepSeek の API キーをハードコードしても検知をすり抜ける。.envの履歴への混入等も見られず、防御機構自体は正常に稼働している)。このPRで導入・強化するもの
.gitleaks.tomlのmonopo-ai-api-keyルールの拡張、およびdocs/security/leak-prevention.mdへの説明追記。検知漏れリスクと補完策
detect-secrets等)や有効性検証ベース(Trufflehog)、GitHub Secret Scanning との組み合わせにより多層的に防御する。マージ前に必要な手動作業(チェックリスト)
レビュアーは PR をマージする前に必ず以下を実施してください。
本 PR の CI は手動作業完了を前提に通る設計です。
マージ後の確認手順
gitleaks.ymlなどの CI が green になることを確認gsk_プレフィックスキーなどを追加しようとした際、ローカルの pre-commit 段階でブロックされることを確認ロールバック手順
本 PR は正規表現パターンの追加のみであるため、誤検知が多発した場合は
git revertにてコミットを打ち消すことで安全かつ即座に元の検知レベルに戻せます。参考情報
PR created automatically by Jules for task 4609932599233604344 started by @genzouw
Summary by CodeRabbit