<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Secret-Scanning on Tarragon</title><link>https://tarrragon.github.io/blog/tags/secret-scanning/</link><description>Recent content in Secret-Scanning on Tarragon</description><generator>Hugo -- gohugo.io</generator><language>zh-TW</language><copyright>Tarragon (CC BY 4.0)</copyright><lastBuildDate>Mon, 18 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://tarrragon.github.io/blog/tags/secret-scanning/index.xml" rel="self" type="application/rss+xml"/><item><title>GitGuardian</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/</guid><description>&lt;p>GitGuardian 是 &lt;em>secret scanning + remediation&lt;/em> SaaS、起家於 GitHub public repo scan、現延伸到 internal SCM、CI 系統與 collaboration / chat 工具。它跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 的根本差異不在「能不能抓到 secret」、而在 &lt;em>偵測邊界跟 remediation workflow 的 shape&lt;/em> — GHAS 是 GitHub-only、partner pattern 強但 push protection 鎖在 GitHub repo；GitGuardian 把 detection 邊界擴到跨 SCM 跟 SaaS workspace、然後用 &lt;em>Incident&lt;/em> 物件管整個生命週期。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>GitGuardian 的核心定位是 &lt;em>跨工具的 secret leak detection + incident workflow&lt;/em>、不只是「pre-commit grep」。底層是一組 &lt;em>Detector&lt;/em>（350+ specific detector、覆蓋 AWS / GCP / Stripe / Slack / 自家 token 等）+ &lt;em>Validation endpoint&lt;/em>（call 該 service 確認 secret live 中），上層是 &lt;em>Incident&lt;/em> 物件（assign / resolve / ignore / share with developer）跟 &lt;em>Source&lt;/em> 抽象（GitHub / GitLab / Bitbucket / Azure DevOps / Slack / Jira / Confluence / Notion）。本機側用 &lt;em>ggshield&lt;/em> CLI 做 pre-commit hook 跟 CI scan。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 比、GitGuardian 走 &lt;em>cross-tool detection + remediation workflow&lt;/em>、GHAS 走 &lt;em>deep integration in GitHub&lt;/em>：GHAS 的 push protection 在 GitHub server-side 直接攔 push、partner pattern（AWS / Stripe / Slack）廣度高；但只要組織有 GitLab self-hosted、Bitbucket、或 developer 習慣把 token 貼 Slack / Confluence，GHAS 看不到的就是 GitGuardian 的場域。跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &amp;#43; regex &amp;#43; entropy、SARIF output、跨 SCM、pre-commit &amp;#43; CI 友善">Gitleaks&lt;/a> / TruffleHog OSS 比、GitGuardian 走 &lt;em>managed SaaS + validation + workflow&lt;/em>、OSS 走 &lt;em>self-hosted + 你自己接 incident pipeline&lt;/em>；OSS 適合預算敏感 + 已有 SOC / IR tooling、GitGuardian 適合直接買 incident workflow 不想自建。&lt;/p></description><content:encoded><![CDATA[<p>GitGuardian 是 <em>secret scanning + remediation</em> SaaS、起家於 GitHub public repo scan、現延伸到 internal SCM、CI 系統與 collaboration / chat 工具。它跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 的根本差異不在「能不能抓到 secret」、而在 <em>偵測邊界跟 remediation workflow 的 shape</em> — GHAS 是 GitHub-only、partner pattern 強但 push protection 鎖在 GitHub repo；GitGuardian 把 detection 邊界擴到跨 SCM 跟 SaaS workspace、然後用 <em>Incident</em> 物件管整個生命週期。</p>
<h2 id="服務定位">服務定位</h2>
<p>GitGuardian 的核心定位是 <em>跨工具的 secret leak detection + incident workflow</em>、不只是「pre-commit grep」。底層是一組 <em>Detector</em>（350+ specific detector、覆蓋 AWS / GCP / Stripe / Slack / 自家 token 等）+ <em>Validation endpoint</em>（call 該 service 確認 secret live 中），上層是 <em>Incident</em> 物件（assign / resolve / ignore / share with developer）跟 <em>Source</em> 抽象（GitHub / GitLab / Bitbucket / Azure DevOps / Slack / Jira / Confluence / Notion）。本機側用 <em>ggshield</em> CLI 做 pre-commit hook 跟 CI scan。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 比、GitGuardian 走 <em>cross-tool detection + remediation workflow</em>、GHAS 走 <em>deep integration in GitHub</em>：GHAS 的 push protection 在 GitHub server-side 直接攔 push、partner pattern（AWS / Stripe / Slack）廣度高；但只要組織有 GitLab self-hosted、Bitbucket、或 developer 習慣把 token 貼 Slack / Confluence，GHAS 看不到的就是 GitGuardian 的場域。跟 <a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> / TruffleHog OSS 比、GitGuardian 走 <em>managed SaaS + validation + workflow</em>、OSS 走 <em>self-hosted + 你自己接 incident pipeline</em>；OSS 適合預算敏感 + 已有 SOC / IR tooling、GitGuardian 適合直接買 incident workflow 不想自建。</p>
<p>關鍵張力：<em>validation endpoint 是 FP 降噪核心</em>、但也是 <em>vendor 風險點</em>。Detector 抓到字串後 GitGuardian <em>call 該 service API live verify</em>（AWS access key 試 <code>sts:GetCallerIdentity</code>、Stripe key 試 retrieve event）、活躍 secret 才升 Incident。意義是 noise 從 OSS gitleaks 的 70-80% FP 降到 個位數 FP；風險是 GitGuardian <em>本身會 call 你的 cloud account</em> — vendor trust 跟 <a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a> 的 scope map 需要在 onboarding 就釐清。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>GitGuardian 在 secret scanning stack 中承擔哪一段（pre-commit / SCM scan / SaaS scan / honeytoken）、哪些要外接（<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 管 rotation、IR tool 接 incident）</li>
<li>Detector / Validation / Incident / Source 的 ownership 設計（誰 assign、誰 resolve、developer 怎麼參與）</li>
<li>跨 SCM + SaaS coverage 該開哪些 source、historical scan 多久跑一次</li>
<li>何時用 GitGuardian、何時走 GHAS / Gitleaks / TruffleHog 的取捨</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 GitGuardian deployment 是否健康、最少看四件事：</p>
<ul>
<li><strong>Source coverage 廣度</strong>：除 GitHub / GitLab 外、Slack / Jira / Confluence / Notion 是否也納入掃 — developer 把 token 貼 Slack DM 是常見 leak vector</li>
<li><strong>Validation endpoint 是否開</strong>：FP 降噪靠 live verify、未開等於回到 OSS gitleaks 的 noise 水位</li>
<li><strong>Incident remediation SLA</strong>：valid incident 從偵測到 rotation 完成的時間、是否串 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 自動 rotation、是否進 PagerDuty / Slack alert</li>
<li><strong>ggshield 在 CI 跟 pre-commit 的覆蓋率</strong>：是否所有 repo 走 pre-commit hook、CI step 是否阻擋 commit-with-secret merge</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">Secrets Management at Scale</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Detector library</strong>：350+ specific detector（AWS Access Key / Stripe Live Key / Slack Bot Token / GitHub PAT / 自家 API key pattern 等）+ generic high-entropy detector。Specific detector 走 vendor-specific pattern + validation endpoint、FP 個位數；generic detector 抓 unknown pattern、FP 較高、通常 routing 到 manual triage queue。Production tenant 應該全開 specific、generic 視 noise budget 開。</p>
<p><strong>Validation endpoint</strong>：detector 抓到字串後、GitGuardian backend <em>call 該 service API live verify</em>。AWS key 試 <code>sts:GetCallerIdentity</code>、Stripe key 試 retrieve test event、GitHub PAT 試 <code>GET /user</code>。verify 結果 <em>Valid</em> / <em>Invalid</em> / <em>Unknown</em> 三態、決定 incident severity。意義是 <em>只有 active secret 升 incident</em>、已 revoke 的舊 commit history 不再 noise。</p>
<p><strong>Incident workflow</strong>：偵測命中後會建 <em>Incident</em> 物件（而非直接 alert）、含 source location / detector / validation status / suggested remediation。Incident 可 <em>assign 給 developer</em>（developer 在 GitGuardian dashboard 自助 acknowledge / rotate / mark FP）、SecOps 只 review escalated case。對應 <a href="/blog/backend/07-security-data-protection/security-as-risk-routing-system/" data-link-title="7.15 資安作為風險路由系統" data-link-desc="建立資安作為風險路由系統的導讀大綱，串接問題節點、控制面與跨模組交接">Security Workflow as Code</a> 的 shift-left 模式 — developer 是 first responder、不是 SecOps 全包。</p>
<p><strong>Source coverage</strong>：GitGuardian 預設掃 SCM（GitHub / GitLab / Bitbucket / Azure DevOps / 自管 Git），但 <em>差異化價值在 SaaS scan</em> — Slack workspace（message / DM / file upload）、Jira issue / comment、Confluence page、Notion workspace、Microsoft Teams 都可接 source connector。Developer 在 Slack 貼 prod DB password 是真實常見 case、SCM-only 工具看不到。</p>
<p><strong>ggshield CLI</strong>：本地 / CI 端的 detection engine。<em>pre-commit hook</em> 攔住 push 前 leak（developer 機器、可被 bypass 但成本提高）、<em>CI step</em> 在 PR 跑 historical scan（不可 bypass、阻擋 merge）。跟 GHAS Push Protection 同類、但跨 SCM、且 detector pool 來自同一個 GitGuardian backend、跟 dashboard incident 走同一條 lineage。</p>
<p><strong>Historical scan</strong>：onboarding 第一次跑 <em>full git history scan</em>、回填過去所有 commit 的 leak。意義是 <em>已 leaked 多年的 secret 被找出來、強制 rotation</em>。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a> 的場景：CI 環境 compromise 後、historical scan 在數小時內找出 CI 環境曾接觸過的所有 secret、配合 secret store API 自動 rotation。</p>
<p><strong>Honeytokens</strong>：散佈假 AWS / Stripe / GitHub token 到 repo 角落 / Confluence page / internal doc、attacker 拿到後試用會觸發 alert。是 <em>早期偵測 unauthorized access</em> 的工程化做法、不依賴 detection model 抓 attacker behavior、而是讓 attacker 自己 trigger 自己。對應 <a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a> — attacker 拿到 OAuth token 後試 GitHub API、honeytoken 在 attacker map 環境時就 trigger。</p>
<p><strong>Rotation 整合</strong>：detect 完不是工作結束、要 <em>rotate the secret</em>。GitGuardian 自身不存 secret，rotation 走 webhook / API 拉 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> / AWS Secrets Manager / Azure Key Vault 觸發 rotation workflow。意義是 <em>偵測跟 remediation 解耦</em>、但需要組織側先把 secret store 接好、否則 incident 只能 manual rotation。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>GitGuardian</th>
          <th>GHAS Secret Scanning</th>
          <th>Gitleaks (OSS)</th>
          <th>TruffleHog</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>部署模型</td>
          <td>SaaS（self-hosted 有 enterprise tier）</td>
          <td>GitHub-only（SaaS / GHES）</td>
          <td>Self-hosted CLI / CI</td>
          <td>Self-hosted CLI / CI / SaaS tier</td>
      </tr>
      <tr>
          <td>Source 範圍</td>
          <td>GitHub / GitLab / Bitbucket / ADO / SaaS</td>
          <td>GitHub repo only</td>
          <td>Git repo（任何 host）</td>
          <td>Git / S3 / Docker / 多 source</td>
      </tr>
      <tr>
          <td>Validation</td>
          <td>內建、350+ detector live verify</td>
          <td>Partner pattern validation（部分）</td>
          <td>無（regex match only）</td>
          <td>有（verified mode）</td>
      </tr>
      <tr>
          <td>Push 攔截</td>
          <td>ggshield pre-commit + CI</td>
          <td>Push Protection（server-side、強制）</td>
          <td>pre-commit hook</td>
          <td>pre-commit hook</td>
      </tr>
      <tr>
          <td>Incident workflow</td>
          <td>內建 Incident + assign + dashboard</td>
          <td>GitHub Alert + Dependabot-like UI</td>
          <td>無（自接 SIEM）</td>
          <td>SaaS tier 有、OSS 無</td>
      </tr>
      <tr>
          <td>Honeytokens</td>
          <td>內建</td>
          <td>無</td>
          <td>無</td>
          <td>無</td>
      </tr>
      <tr>
          <td>計費</td>
          <td>Per developer / contributor（年訂）</td>
          <td>Per active committer（GitHub Enterprise）</td>
          <td>免費</td>
          <td>OSS 免費、SaaS 按 contributor</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>跨 SCM + SaaS、要 workflow + honeytoken</td>
          <td>GitHub-only + 已買 GHAS</td>
          <td>預算敏感 + 自建 IR pipeline</td>
          <td>多 source（含 S3 / Docker）、OSS-friendly</td>
      </tr>
      <tr>
          <td>退場成本</td>
          <td>中 — Incident 歷史在 vendor、detector 通用</td>
          <td>中 — 綁 GitHub UI、export 有限</td>
          <td>低 — 規則自有</td>
          <td>低 — 規則自有</td>
      </tr>
  </tbody>
</table>
<p>選 GitGuardian 的核心訴求：<em>跨 SCM + SaaS coverage + 內建 incident workflow + honeytoken</em>、且能投入 per-developer 訂閱（大型公司 contributor 數會放大成本）+ 有 SecOps 跟 developer 分工承接 incident。GitHub-only 環境且已買 GHAS、重疊不必要、直接用 GHAS；預算敏感且自家有 IR pipeline、走 <a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> 或 TruffleHog OSS。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Honeytokens 散佈策略</strong>：honeytoken 的效果取決於 <em>放在哪裡 + 看起來多真</em>。放 repo README、Confluence runbook、Slack <code>#engineering</code> 過期附件、舊 backup script — attacker reconnaissance 會優先看的地方。token 的命名要跟組織 naming convention 一致（<code>prod-db-readonly-2024</code>）、避免一看就是假的。每個 honeytoken 配 unique ID、trigger 時能定位 <em>attacker 從哪個位置拿到</em>、反推 leak surface。</p>
<p><strong>Validation endpoint 的 trade-off</strong>：validation 是 FP 降噪核心、但代價是 <em>GitGuardian 會 call 你的 cloud account</em>。AWS key 命中時 GitGuardian 從自家 IP call <code>sts:GetCallerIdentity</code>、log 留在你的 CloudTrail。Onboarding 要 <em>把 GitGuardian IP range allowlist 進 SIEM whitelist</em>、避免被自家 detection 誤判為 unauthorized access；同時要評估 vendor trust — 2020 年 GitGuardian 自家 source code 透過第三方 SaaS leak、提醒 vendor 不是 detection-only 的零信任邊界。</p>
<p><strong>IR workflow 整合</strong>：Incident 不應該停在 GitGuardian dashboard、要 routing 到組織既有 IR tooling — PagerDuty for on-call、Slack channel for SecOps、Jira ticket for tracking。Webhook 是標準做法、payload 含 incident metadata + validation status、由組織側決定升級邏輯（valid + prod scope → PagerDuty page；invalid + dev scope → Slack info）。</p>
<p><strong>Historical scan + scope map</strong>：偵測到 leaked secret 後、要回答 <em>這個 secret 還在哪裡用</em>。GitGuardian 的 historical scan 找出 <em>所有 commit 提到該 pattern 的位置</em>、配合組織側 secret store 的 <em>who uses this secret</em> metadata、形成 scope map。對應 <a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a> — rotation 不能只換一個地方、要全 scope 一起換、否則舊 secret 還在某個 service 用、rotation 沒生效。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>Incident volume 爆炸 / developer 看不完</strong>：generic high-entropy detector 全開 + 沒 assign 到 developer — 縮 generic detector scope、incident 走 assign-to-author、SecOps 只 review escalated</li>
<li><strong>Valid incident rotation 慢 / SLA 跑掉</strong>：沒接 secret store rotation API、停在 manual rotation — 接 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> / Secrets Manager webhook、自動觸發 rotation workflow</li>
<li><strong>Slack / Confluence 沒掃進來</strong>：以為 SCM-only 就夠 — 接 SaaS source connector、developer 貼 token 在 Slack DM 是常見 leak vector</li>
<li><strong>ggshield 被 bypass</strong>：pre-commit 在 developer 機器、可 <code>--no-verify</code> — 同步在 CI step 跑 ggshield、CI 不可 bypass、阻擋 merge</li>
<li><strong>Validation FP 不降</strong>：validation endpoint 沒開、或被 firewall 擋 — 確認 GitGuardian IP range 在 cloud account allowlist、validation status 是 <em>Valid</em> 不是 <em>Unknown</em></li>
<li><strong>Honeytoken 沒 trigger / 假警報</strong>：token 放錯位置（attacker 不會看的 deep nested folder）或命名一看就假 — 散佈到 reconnaissance hot spot、命名跟組織 convention 一致</li>
<li><strong>Per-developer 計費暴衝</strong>：contractor / bot account 也算 developer — review billing report、排除 service account / read-only viewer、跟 vendor 談 contributor 定義</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>GitHub-only + 已買 GHAS</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a></td>
      </tr>
      <tr>
          <td>預算敏感 + 自建 IR pipeline</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a> OSS / TruffleHog OSS</td>
      </tr>
      <tr>
          <td>多 source（S3 / Docker image）</td>
          <td>TruffleHog（覆蓋更多 non-Git source）</td>
      </tr>
      <tr>
          <td>Secret store / rotation</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a> / AWS Secrets Manager / Azure Key Vault</td>
      </tr>
      <tr>
          <td>SIEM correlation / cross-source</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a> / <a href="/blog/backend/07-security-data-protection/vendors/elastic-security/" data-link-title="Elastic Security" data-link-desc="Elastic Stack 上的 SIEM &#43; EDR &#43; Cloud Security 套件、OSS 起源、KQL/EQL/Lucene/ES|QL 多查詢語言、resource-based pricing">Elastic Security</a></td>
      </tr>
      <tr>
          <td>Supply chain build provenance</td>
          <td><a href="https://docs.sigstore.dev/">Sigstore / SLSA vendor 群</a>（同 vendor 章）</td>
      </tr>
      <tr>
          <td>Incident routing</td>
          <td><a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a></td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>ggshield 完整 CLI flag reference 跟 custom detector YAML schema</li>
<li>GitGuardian Internal Monitoring (self-hosted enterprise) 的部署架構細節</li>
<li>Honeytoken 在 active deception / canary token 廣義生態的位置（屬 deception engineering、不在本頁）</li>
<li>Detector pattern 的 regex / entropy 細節（屬 detection engineering）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>GitGuardian 在 07 案例庫沒有直接 vendor-level 事件、但所有 secret leak / supply chain case 都是它的偵測對照：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 GitGuardian 的關係（對照啟示）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a></td>
          <td>Historical scan 在 CI compromise 後數小時內找出 CI 環境曾接觸過的所有 secret、配合 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 自動 rotation、不是 console manual rotation</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a></td>
          <td>Honeytokens 散佈在 repo 跟 Confluence、attacker 拿到 OAuth token 後試 GitHub API 時 trigger、不靠 detection model 抓 attacker behavior</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a></td>
          <td>GitGuardian historical scan 找出 leaked secret 的 <em>scope map</em>（哪些 service 共用同一個 secret）、配合 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 分域 rotation 才完整</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/solarwinds-2020-sunburst/" data-link-title="7.R7.2.1 SolarWinds 2020：更新鏈被濫用" data-link-desc="合法更新流程遭植入後，攻擊者如何長期潛伏與橫向擴散">SolarWinds 2020 Sunburst</a></td>
          <td>secret scanning 抓不到 build pipeline 內 malicious code 注入、要靠 <a href="https://docs.sigstore.dev/">Sigstore / SLSA</a> provenance；secret scanning 是覆蓋一段、不是全部</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">7.x Secrets Management at Scale</a>、<a href="/blog/backend/07-security-data-protection/security-as-risk-routing-system/" data-link-title="7.15 資安作為風險路由系統" data-link-desc="建立資安作為風險路由系統的導讀大綱，串接問題節點、控制面與跨模組交接">Security Workflow as Code</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a>、<a href="/blog/backend/07-security-data-protection/vendors/gitleaks/" data-link-title="Gitleaks" data-link-desc="OSS CLI secret scanner、Go 寫、Rule TOML &#43; regex &#43; entropy、SARIF output、跨 SCM、pre-commit &#43; CI 友善">Gitleaks</a>、TruffleHog</li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a>（rotation 接點）、<a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a> / <a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a></li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a>（Incident webhook → SIEM）、<a href="https://docs.sigstore.dev/">Sigstore</a>（build provenance 覆蓋 secret scanning 抓不到的段）</li>
<li>跨模組：<a href="/blog/backend/08-incident-response/vendors/" data-link-title="事故處理 Vendor 清單" data-link-desc="規劃 on-call、incident response、status page 與 postmortem 工具的服務頁撰寫順序與判準">8 事故處理 vendor 清單</a>（Incident → IR routing）</li>
<li>官方：<a href="https://docs.gitguardian.com/">GitGuardian Documentation</a></li>
</ul>
]]></content:encoded></item><item><title>Gitleaks</title><link>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitleaks/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitleaks/</guid><description>&lt;p>Gitleaks 是 &lt;em>純 CLI 的 OSS secret scanner&lt;/em>、MIT License、Go 寫、單一 binary 跑遍 macOS / Linux / Windows。它只做一件事 — 對 git history、working tree 或 staged changes 跑 regex + entropy + path filter 找 secret、輸出 JSON / SARIF / CSV 給下游消化。它沒有 dashboard、沒有 SaaS、沒有 cross-platform scan、也沒有 incident workflow — 這些刻意拿掉的東西是它跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &amp;#43; remediation SaaS、350&amp;#43; Detector &amp;#43; Validation endpoint、跨 SCM &amp;#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian&lt;/a> / &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 的核心分界。&lt;/p>
&lt;h2 id="服務定位">服務定位&lt;/h2>
&lt;p>Gitleaks 的核心定位是 &lt;em>git-aware secret scan 的 CLI 原語&lt;/em>、不是 secret 治理平台。Rule 寫在 &lt;code>.gitleaks.toml&lt;/code>、輸出走標準格式（SARIF / JSON / CSV）、跟下游 pipeline（CI、SIEM、GHAS Code Scanning）解耦。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &amp;#43; remediation SaaS、350&amp;#43; Detector &amp;#43; Validation endpoint、跨 SCM &amp;#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian&lt;/a> 比、GitGuardian 是 SaaS + dashboard + remediation workflow + validation endpoint（呼叫真實 API 驗證 secret 是否有效降 FP）+ honeytoken decoy、Gitleaks 沒有任一項 — 它只回答「這個 string 看起來像不像 secret」。GitGuardian 適合大型組織 + 預算允許 + 要跨 Slack / Jira / Notion 等 SaaS scan；Gitleaks 適合預算敏感 + 只需要 git scope + 內部已有 CI / SIEM 接 SARIF 的場景。&lt;/p>
&lt;p>跟 &lt;a href="https://tarrragon.github.io/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &amp;#43; Secret Scanning &amp;#43; Dependency Review &amp;#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning&lt;/a> 比、GHAS 限 GitHub 平台、提供 push protection（partner pattern 在 push 前直接擋）跟 partner 自動 revoke 等深度整合、但只覆蓋 GitHub repo；Gitleaks 跨 GitHub / GitLab / Bitbucket / 自架 Gitea、CLI 跑哪都行、缺點是沒有 partner revoke 跟 push protection 要自己用 hook 接。&lt;/p></description><content:encoded><![CDATA[<p>Gitleaks 是 <em>純 CLI 的 OSS secret scanner</em>、MIT License、Go 寫、單一 binary 跑遍 macOS / Linux / Windows。它只做一件事 — 對 git history、working tree 或 staged changes 跑 regex + entropy + path filter 找 secret、輸出 JSON / SARIF / CSV 給下游消化。它沒有 dashboard、沒有 SaaS、沒有 cross-platform scan、也沒有 incident workflow — 這些刻意拿掉的東西是它跟 <a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a> / <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 的核心分界。</p>
<h2 id="服務定位">服務定位</h2>
<p>Gitleaks 的核心定位是 <em>git-aware secret scan 的 CLI 原語</em>、不是 secret 治理平台。Rule 寫在 <code>.gitleaks.toml</code>、輸出走標準格式（SARIF / JSON / CSV）、跟下游 pipeline（CI、SIEM、GHAS Code Scanning）解耦。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a> 比、GitGuardian 是 SaaS + dashboard + remediation workflow + validation endpoint（呼叫真實 API 驗證 secret 是否有效降 FP）+ honeytoken decoy、Gitleaks 沒有任一項 — 它只回答「這個 string 看起來像不像 secret」。GitGuardian 適合大型組織 + 預算允許 + 要跨 Slack / Jira / Notion 等 SaaS scan；Gitleaks 適合預算敏感 + 只需要 git scope + 內部已有 CI / SIEM 接 SARIF 的場景。</p>
<p>跟 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 比、GHAS 限 GitHub 平台、提供 push protection（partner pattern 在 push 前直接擋）跟 partner 自動 revoke 等深度整合、但只覆蓋 GitHub repo；Gitleaks 跨 GitHub / GitLab / Bitbucket / 自架 Gitea、CLI 跑哪都行、缺點是沒有 partner revoke 跟 push protection 要自己用 hook 接。</p>
<p>跟 TruffleHog OSS 比、兩者都是 OSS CLI secret scanner、TruffleHog 強在 <em>verifier</em>（對 200+ secret type 呼叫對應 API 驗證真偽）、Gitleaks 強在 <em>rule TOML 表達力跟 SARIF output 成熟度</em>。實務上很多組織兩個一起跑、用不同的 rule 覆蓋面互補。</p>
<p>關鍵張力：<em>Allowlist 治理</em> ↔ <em>FP 噪音</em> 是 Gitleaks 客戶最大的長期問題。OSS 沒有 validation endpoint、entropy + path filter 一定會誤判 test fixture / mock token / sample config、allowlist 不持續 review 會膨脹成「全部都白名單」最後 rule 失效。</p>
<h2 id="本章目標">本章目標</h2>
<p>讀完本頁、讀者能判斷：</p>
<ol>
<li>Gitleaks 在 secret scan stack 中承擔哪一段（pre-commit / CI scan / historical audit）、哪些要外接（<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> rotate、<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Code Scanning</a> 收 SARIF dashboard）</li>
<li>Custom rule 跟 allowlist 的 ownership 設計（誰寫 rule、誰核准 allowlist、定期 review 週期）</li>
<li><code>detect</code> vs <code>protect</code> 兩個子命令的職責切分、跟 pre-commit framework / CI 整合的位置</li>
<li>何時用 Gitleaks、何時升級到 <a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a> / <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a> 的取捨</li>
</ol>
<h2 id="最短判讀路徑">最短判讀路徑</h2>
<p>判斷 Gitleaks 部署是否健康、最少看四件事：</p>
<ul>
<li><strong>誰能改 <code>.gitleaks.toml</code></strong>：rule 跟 allowlist 是否走 Git PR review、commit message 是否帶 allowlist 原因、是否有 owner 簽核</li>
<li><strong><code>detect</code> vs <code>protect</code> 是否都接</strong>：CI 跑 <code>gitleaks detect</code>（掃 history + working tree）、pre-commit hook 跑 <code>gitleaks protect</code>（只掃 staged changes）— 缺 protect 等於 leak 進 history 才知道、缺 detect 等於既有 leak 永遠不發現</li>
<li><strong>SARIF 是否上傳 dashboard</strong>：CI output 是否 upload 到 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Code Scanning</a> 或內部 SIEM、不然 finding 散在 CI log 沒人看</li>
<li><strong>Allowlist 是否定期 review</strong>：allowlist entry 是否帶 expire date / reason / owner、每季是否 revisit 把過期項目刪掉、不然 allowlist 會膨脹到掩蓋真實 leak</li>
</ul>
<p>四件事任一缺失、就是 <a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">Detection Coverage and Signal Governance</a> 邊界的待補項目。</p>
<h2 id="日常操作與決策形狀">日常操作與決策形狀</h2>
<p><strong>Rule TOML / JSON</strong>：rule 結構是 <code>id</code> + <code>regex pattern</code> + 可選 <code>entropy threshold</code>（高熵字串通常是 secret、避開 lorem ipsum FP）+ 可選 <code>path filter</code>（限定 / 排除路徑）。預設 rule library 涵蓋 AWS / GCP / Azure / Stripe / Slack token 等 100+ pattern；organization 通常 <em>先 import 預設、再加自家 token format custom rule</em>。Custom rule 必須給 valid + invalid sample 跑 unit test、不然 regex 寫錯會大量 FP。</p>
<p><strong><code>gitleaks detect</code>（historical scan）</strong>：掃整個 git history + working tree、CI 跑、適合 <em>發現既有 leak</em>。預設掃 HEAD 到根、可用 <code>--log-opts</code> 限定 commit range 加速。實務上 PR scan 限定 <code>--log-opts=&quot;--since=...$(git merge-base origin/main HEAD)&quot;</code> 只看本 PR 新增 commit、避免每次跑整個 history 慢死。</p>
<p><strong><code>gitleaks protect</code>（pre-commit）</strong>：只掃 staged changes、pre-commit hook 跑、適合 <em>攔住未來 leak</em>。它不掃 history、意義是 <em>commit 前的最後一道閘</em>；配合 pre-commit framework（<code>pre-commit-hooks</code> 或 <a href="https://pre-commit.com/">pre-commit.com</a>）的 <code>repos: gitleaks</code> 配置直接接入。</p>
<p><strong>Report 格式（JSON / SARIF / CSV）</strong>：JSON 是 raw 結構、適合 script 處理；SARIF 是 OASIS 標準、跟 GHAS Code Scanning / 商業 SAST dashboard 共用；CSV 適合人讀 / Excel 二次處理。Production 通常 <em>CI 輸出 SARIF + 上傳 GHAS Code Scanning</em>、把 OSS scanner 的 finding 跟商業 SAST 同 dashboard、SOC 不用切多工具。</p>
<p><strong>跟 CI 整合</strong>：GitHub Actions 用 <code>gitleaks/gitleaks-action</code>、GitLab CI 用 official Docker image、Jenkins 用 binary download + shell step。CI 失敗策略要決定 — <em>block PR</em> 還是 <em>warn only</em>：嚴格組織 block PR、寬鬆組織 warn + 上 SARIF 讓 SOC 自行 triage、避免初期高 FP 阻塞所有 merge。</p>
<p><strong>跟 pre-commit framework 整合</strong>：<code>.pre-commit-config.yaml</code> 加 <code>- repo: https://github.com/gitleaks/gitleaks</code> 條目、<code>pre-commit install</code> 後每次 commit 自動跑。注意 <em>pre-commit 只在開發者 machine 跑</em>、繞過很簡單（<code>git commit --no-verify</code>）、所以一定要配 CI scan 兜底、不能只信 pre-commit。</p>
<p><strong>Allowlist 治理</strong>：<code>.gitleaks.toml</code> 裡 <code>[allowlist]</code> section 寫 <code>paths</code> / <code>regexes</code> / <code>commits</code> / <code>stopwords</code>。每個 entry 應該帶 reason（<code># allowlist reason: test fixture for OAuth flow, expire 2026-Q4</code>）、PR review 時要問「為什麼這個是 FP、什麼時候會過期」。Quarterly 跑 audit 把過期項目刪掉、避免 allowlist 變成「全部都白名單」。</p>
<h2 id="核心取捨表">核心取捨表</h2>
<table>
  <thead>
      <tr>
          <th>取捨維度</th>
          <th>Gitleaks</th>
          <th>GitGuardian</th>
          <th>GHAS Secret Scanning</th>
          <th>TruffleHog OSS</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>License</td>
          <td>MIT OSS</td>
          <td>Proprietary SaaS（free tier 限個人）</td>
          <td>GitHub Enterprise add-on</td>
          <td>AGPL OSS（Enterprise 商業）</td>
      </tr>
      <tr>
          <td>Scope</td>
          <td>Git only（history + tree + staged）</td>
          <td>Git + Slack + Jira + Notion + 自訂 source</td>
          <td>GitHub repo only</td>
          <td>Git + S3 + filesystem + more</td>
      </tr>
      <tr>
          <td>Dashboard</td>
          <td>無、輸出 SARIF / JSON 自己接</td>
          <td>內建 incident workflow + remediation</td>
          <td>GitHub Security tab</td>
          <td>無（CLI / API）</td>
      </tr>
      <tr>
          <td>Validation</td>
          <td>無（只看 regex + entropy）</td>
          <td>有（呼叫 API 驗證真偽）</td>
          <td>Partner pattern 自動 revoke</td>
          <td>有（200+ verifier）</td>
      </tr>
      <tr>
          <td>Push protection</td>
          <td>無、要自己 wire pre-commit</td>
          <td>有（透過 ggshield）</td>
          <td>有（partner pattern、push 前擋）</td>
          <td>無</td>
      </tr>
      <tr>
          <td>部署模型</td>
          <td>CLI binary、跑哪都行</td>
          <td>SaaS only</td>
          <td>GitHub SaaS / Enterprise Server</td>
          <td>CLI binary</td>
      </tr>
      <tr>
          <td>計費</td>
          <td>免費</td>
          <td>Per-developer / per-repo</td>
          <td>Per-committer</td>
          <td>免費（OSS） / 商業另計</td>
      </tr>
      <tr>
          <td>適合場景</td>
          <td>OSS-friendly、預算敏感、CI / SARIF 已有</td>
          <td>跨 SaaS scan + remediation workflow</td>
          <td>GitHub-only + push protection 為主</td>
          <td>多 source + verifier 為主</td>
      </tr>
      <tr>
          <td>退場成本</td>
          <td>低 — rule TOML 可移植到 GitGuardian</td>
          <td>高 — incident history / workflow 綁定</td>
          <td>中 — SARIF 可移植但 push protection 限 GHAS</td>
          <td>低</td>
      </tr>
  </tbody>
</table>
<p>選 Gitleaks 的核心訴求：<em>OSS + 預算敏感 + 只需要 git scope + 內部 CI / SIEM 已能消化 SARIF</em>、且願意自己投入 rule / allowlist 治理。要跨 SaaS scan + incident workflow 升 GitGuardian、要 push protection + partner revoke 走 GHAS Secret Scanning。</p>
<h2 id="進階主題">進階主題</h2>
<p><strong>Custom rule 寫法（regex + entropy + path）</strong>：自家 internal token 通常有特定 prefix（<code>xy_live_</code> / <code>int_token_</code>）、寫 custom rule 就是 <code>regex = '''xy_live_[A-Za-z0-9]{32}'''</code> + <code>entropy = 4.0</code> + <code>path = '''.*\.go$'''</code>。Entropy threshold 越高 FP 越少但 FN 越多、實務值 3.5–4.5 之間 tune。每個 rule 一定要在 repo 加 unit test fixture（valid + invalid sample）、CI 跑 rule 自我驗證、避免 regex 寫錯後 silent break。</p>
<p><strong>跟 SARIF + GHAS Code Scanning 整合補位</strong>：Gitleaks CI 跑完輸出 SARIF、用 <code>github/codeql-action/upload-sarif</code> 上傳到 GHAS Code Scanning。GHAS Code Scanning 不限 CodeQL 來源、任何 SARIF tool 都收。意義是 <em>OSS scanner + GHAS dashboard</em> 是預算友善組合 — 不買 GHAS Secret Scanning license、但 finding 集中在 Security tab 跟 SAST 共看。對應 <a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Advanced Security</a> 的 Code Scanning section。</p>
<p><strong>跟 Vault 自動 rotation pipeline</strong>：Gitleaks 找到 leak 不是終點、是 <em>rotation trigger</em>。CI 把 finding 推 SOAR（或自家 webhook）、SOAR 呼叫 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> API 對該 credential type rotate（dynamic credential 直接 revoke、static secret 換新版本）、再 broadcast 給依賴該 secret 的 service rolling restart。沒這條 pipeline、Gitleaks 只是 finding 列表沒實際治理價值。</p>
<p><strong>Allowlist 治理（FP 不能無限）</strong>：OSS 沒 validation endpoint、test fixture / mock token / sample config 一定觸發 FP。allowlist 治理三原則 — <em>每個 entry 帶 reason + owner + expire date</em>、<em>PR review 必問「為什麼 FP」</em>、<em>quarterly audit 刪過期項目</em>。沒這個治理 allowlist 會在 6–12 個月內膨脹到「半個 repo 都在白名單」、那時候 rule 已經沒用、refactor 成本比一開始嚴格更高。</p>
<p><strong>跟 Trivy secret scan 重疊</strong>：<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a> 內建 secret scanner（用同樣的 regex pattern）、container image / filesystem 都掃。Gitleaks 跟 Trivy secret scan 在 <em>container build pipeline</em> 階段會重疊 — 實務分工：Gitleaks 掃 source repo（git history + working tree）、Trivy 掃 built artifact（image layer + filesystem）。兩者覆蓋不同階段、不衝突。</p>
<h2 id="排錯與失敗快速判讀">排錯與失敗快速判讀</h2>
<ul>
<li><strong>FP 太多、開發者開始忽略 Gitleaks finding</strong>：rule 沒 tune entropy threshold 或 path filter — 對 high-FP rule 加 <code>entropy = 4.0</code> 跟 <code>paths = ['''!test/.*''']</code>、staging branch 跑 1 週統計 FP 再 promote</li>
<li><strong>Pre-commit 被繞過（<code>--no-verify</code>）</strong>：開發者本機跑不過直接 bypass — pre-commit 不能當唯一防線、CI <code>gitleaks detect</code> block PR 才是真實 gate</li>
<li><strong>Historical scan 太慢、CI timeout</strong>：每次掃整個 git history — PR scan 限定 <code>--log-opts=&quot;$(git merge-base origin/main HEAD)..HEAD&quot;</code> 只看本 PR commit、nightly job 才跑 full history</li>
<li><strong>SARIF 上傳失敗 / GHAS dashboard 沒 finding</strong>：<code>github/codeql-action/upload-sarif</code> 權限不足或 <code>security-events: write</code> permission 沒給 — 補 GitHub Actions permission、或改 upload 內部 SIEM</li>
<li><strong>Allowlist 膨脹、規則失效</strong>：FP 全部塞 allowlist、沒 reason 沒 expire — quarterly audit、刪過期項目、把高 FP rule 改寫成更窄的 regex 而不是 allowlist 蓋過</li>
<li><strong>既有 leak 沒被發現、新 commit 攔得很乾淨</strong>：只接 <code>protect</code> 沒接 <code>detect</code> — CI 加 <code>detect</code> job、找出 history 中已 leak 的 secret 一次性 rotate（<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> 自動化）</li>
<li><strong>Custom rule 寫錯、silent skip 真 leak</strong>：rule regex 沒 unit test fixture、production 才發現 — 強制 custom rule 加 valid + invalid sample、CI 跑 rule 自驗</li>
</ul>
<h2 id="何時改走其他服務">何時改走其他服務</h2>
<table>
  <thead>
      <tr>
          <th>需求形狀</th>
          <th>改走</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>跨 Slack / Jira / Notion / 自架 SaaS scan</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a></td>
      </tr>
      <tr>
          <td>Push protection + partner auto-revoke</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a></td>
      </tr>
      <tr>
          <td>Validation endpoint（驗證 secret 真偽）</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a> 或 TruffleHog Enterprise</td>
      </tr>
      <tr>
          <td>Honeytoken decoy 主動防禦</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a>（內建 honeytoken）</td>
      </tr>
      <tr>
          <td>Container image secret scan</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a>（內建 secret scanner）</td>
      </tr>
      <tr>
          <td>Secret 找到後自動 rotate</td>
          <td>配 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a> dynamic credential</td>
      </tr>
      <tr>
          <td>SAST / SCA dashboard 整合</td>
          <td><a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Code Scanning</a>（收 SARIF）</td>
      </tr>
  </tbody>
</table>
<h2 id="不在本頁內的主題">不在本頁內的主題</h2>
<ul>
<li>Gitleaks v8 跟 v7 的 rule 格式遷移細節</li>
<li>Gitleaks 內部 git odb 解析跟性能 tuning（large monorepo 加速）</li>
<li>Pre-commit framework 本身的安裝跟治理（屬開發者工作流、不在資安範圍）</li>
<li>Rotation playbook 完整實作（屬 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> / <a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a> 章節）</li>
<li>Secret 治理整體政策（屬 <a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">Secrets Management section</a> 上層原則）</li>
</ul>
<h2 id="案例回寫">案例回寫</h2>
<p>Gitleaks 在 07 案例庫沒有直接 vendor-level 事件、所有 secret leak case 都是 git history scan + rotation pipeline 的對照：</p>
<table>
  <thead>
      <tr>
          <th>案例</th>
          <th>跟 Gitleaks 的關係（對照啟示）</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/circleci-2023-secrets-rotation/" data-link-title="7.R7.2.3 CircleCI 2023：CI secrets 輪替壓力" data-link-desc="工程端點入侵後，CI 平台 secrets 如何成為高風險擴散點">CircleCI 2023 Secrets Rotation</a></td>
          <td>Gitleaks <code>detect</code> 跑整個 git history 找出已 leaked secret、配合 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> rotation 流程清乾淨</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/red-team/cases/supply-chain/github-oauth-2022-token-supply-chain/" data-link-title="7.R7.2.2 GitHub OAuth 2022：第三方 token 供應鏈風險" data-link-desc="第三方整合 token 被竊後，如何形成跨組織存取風險">GitHub OAuth 2022 Token Supply Chain</a></td>
          <td>Pre-commit <code>protect</code> 攔未來 leak、但對既有 leak 要 historical scan 補位、單一防線不夠</td>
      </tr>
      <tr>
          <td><a href="/blog/backend/07-security-data-protection/cases/failure-credential-rotation-without-scope/" data-link-title="7.C9 反例：憑證輪替未分 Scope" data-link-desc="憑證輪替若未分域分批，容易造成跨系統連鎖中斷。">Failure: Credential Rotation Without Scope</a></td>
          <td>Gitleaks 找出 leaked static secret 是第一步、長期解是 <a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">Vault</a> dynamic credential 取代 long-lived secret</td>
      </tr>
  </tbody>
</table>
<h2 id="下一步路由">下一步路由</h2>
<ul>
<li>上游：<a href="/blog/backend/07-security-data-protection/secrets-and-machine-credential-governance/" data-link-title="7.6 秘密管理與機器憑證治理" data-link-desc="以問題驅動方式整理 secret、token、key 與機器身份治理">7 章 Secrets Management section</a>、<a href="/blog/backend/07-security-data-protection/detection-coverage-and-signal-governance/" data-link-title="7.13 偵測覆蓋率與訊號治理" data-link-desc="定義偵測覆蓋、訊號品質與誤報成本的治理問題">Detection Coverage and Signal Governance</a></li>
<li>平行：<a href="/blog/backend/07-security-data-protection/vendors/gitguardian/" data-link-title="GitGuardian" data-link-desc="Secret scanning &#43; remediation SaaS、350&#43; Detector &#43; Validation endpoint、跨 SCM &#43; SaaS（Slack / Notion）、Honeytokens decoy">GitGuardian</a>、<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Secret Scanning</a>、<a href="/blog/backend/07-security-data-protection/vendors/trivy/" data-link-title="Trivy" data-link-desc="Aqua Security 開源 all-in-one scanner：Container / Filesystem / K8s / IaC &#43; Secret &#43; License &#43; SBOM、Apache 2.0、CI 友善">Trivy</a></li>
<li>下游：<a href="/blog/backend/07-security-data-protection/vendors/hashicorp-vault/" data-link-title="HashiCorp Vault" data-link-desc="Self-hosted secret management 與 dynamic credential / encryption-as-a-service / PKI engine、跨雲跨環境的 secret 控制面">HashiCorp Vault</a>（找到 leak 後 rotate）、<a href="/blog/backend/07-security-data-protection/vendors/aws-secrets-manager/" data-link-title="AWS Secrets Manager" data-link-desc="AWS 原生 secret store &#43; 內建 RDS / Redshift rotation Lambda、Resource Policy 跨帳號共享、KMS 加密">AWS Secrets Manager</a> / <a href="/blog/backend/07-security-data-protection/vendors/google-secret-manager/" data-link-title="Google Secret Manager" data-link-desc="GCP 原生 secret store、CMEK &#43; Workload Identity Federation 整合、rotation 走自寫 Cloud Function 而非 built-in Lambda">Google Secret Manager</a> / <a href="/blog/backend/07-security-data-protection/vendors/azure-key-vault/" data-link-title="Azure Key Vault" data-link-desc="Azure 三合一 service（Secret &#43; Key &#43; Certificate）、整合 Managed Identity &#43; Entra ID RBAC、Premium tier 走 HSM">Azure Key Vault</a></li>
<li>跨類：<a href="/blog/backend/07-security-data-protection/vendors/github-advanced-security/" data-link-title="GitHub Advanced Security" data-link-desc="GitHub 內建 4 大模組：Code Scanning (CodeQL) &#43; Secret Scanning &#43; Dependency Review &#43; Dependabot、跟 PR / Security tab 深度整合">GHAS Code Scanning</a>（收 SARIF dashboard）、<a href="/blog/backend/07-security-data-protection/vendors/splunk/" data-link-title="Splunk" data-link-desc="業界 SIEM 標準、forwarder &#43; indexer &#43; search head 架構、SPL 為核心查詢語言、ingestion-based 計費跟偵測覆蓋率的 trade-off">Splunk</a> / <a href="/blog/backend/07-security-data-protection/vendors/elastic-security/" data-link-title="Elastic Security" data-link-desc="Elastic Stack 上的 SIEM &#43; EDR &#43; Cloud Security 套件、OSS 起源、KQL/EQL/Lucene/ES|QL 多查詢語言、resource-based pricing">Elastic Security</a>（finding 進 SIEM）</li>
<li>官方：<a href="https://github.com/gitleaks/gitleaks">Gitleaks GitHub</a>、<a href="https://github.com/gitleaks/gitleaks/blob/master/README.md">Gitleaks Documentation</a></li>
</ul>
]]></content:encoded></item></channel></rss>