---
title: "GitGuardian：防止公開暴露敏感信息"
description: "\\\"無數黑客會用自動腳本掃描Github上面的信息，偷取資料，盜取信用卡，直接訪問數據庫，插入挖礦代碼，或者加入後門。\\\""
slug: "gitguardian-prevent-public-exposure-of-secrets-in-github"
date: 2018-09-08T00:00:00.000Z
url: https://calpa.me/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/
tags: ["Tools"]
---

## 介紹

無數黑客會用自動腳本掃描 Github 上面的信息，偷取資料，盜取信用卡，直接訪問數據庫，插入挖礦代碼，或者加入後門。

![GitGuardian](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-nnB1vCn.jpg)

GitGuardian 是首個實時，自動掃描開源項目代碼的平台。當發佈敏感資料到 Github 開源項目時，它就會自動提醒我們，比如說發送電子郵件。

> The first platform scanning all GitHub public activity in real time for **API secret tokens**, **database credentials** or **vault keys**. Be alerted in seconds. Integrate in minutes.

它也提供很多 API 來提示用戶問題，不過免費版本就只會發送電子郵件。

![Methods](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-aU3mF9t.jpg)

當然，你也可以設置多個郵件地址。

隨帶一提，發送電郵到 ifttt 就可以更多變化了。

## 統計

### 安全隱患數

![Secrets Found Last Day](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-5JO5XCw.jpg)

![Commits analyzed last week](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-O4lzz5A.jpg)

在 2018 年 9 月 8 日之前的一周，它每天掃描的代碼行數超過兩百萬，每小時發現洩露的秘鑰超過四十個。

### 發送電郵數量

![Imgur](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-uvkdclb.jpg)

直到現在，GitGuardian 已經發出超過十萬封關於安全問題預警的電郵。

## 使用方法

1. [訪問 GitGuardian 官網](https://www.gitguardian.com/)

1. 點擊右上角 SIGN IN WITH GITHUB

1. 點擊授權按鈕

授權成功後，你會收到來自 Github 的授權通知電郵

如果你不需要這個服務的話，你可以隨時取消授權。

![Imgur](/images/blog/gitguardian-prevent-public-exposure-of-secrets-in-github/unsplash-c5249f4df085-iiD7flU.jpg)

## 後記

作為一個熱愛開源項目的前端工程師，不可避免地寫很多代碼上傳到 Github。要防範這一類的敏感信息暴露，除了加入自動提示外，還需要從源頭入手，避免上傳過多信息到 Github 上面。有機會我們再說如何從檢查代碼提交入手。
