Note: 秘密扫描 as a protection push is currently in beta and subject to change. To request access to the beta release, contact your account management team.
关于机密的推送保护
到目前为止,> - 秘密扫描,用于高级安全 在推送后检查机密,并向用户提醒暴露的机密。 When you enable push protection, 秘密扫描 also checks pushes for high-confidence secrets (those identified with a low false positive rate). 秘密扫描 lists any secrets it detects so the author can review the secrets and remove them or, if needed, allow those secrets to be pushed.
秘密扫描 作为推送保护,当前会扫描存储库中查找由以下服务提供商颁发的机密。
提供者 | 支持的密钥 | 密钥类型 |
---|---|---|
Adafruit IO | Adafruit IO 密钥 | adafruit_io_key |
Alibaba Cloud | Alibaba 云访问密钥 ID | alibaba_cloud_access_key_id |
Alibaba Cloud | Alibaba 云访问密钥机密 | alibaba_cloud_access_key_secret |
Amazon | Amazon OAuth Client ID | amazon_oauth_client_id |
Amazon | Amazon OAuth Client Secret | amazon_oauth_client_secret |
Amazon Web Services (AWS) | Amazon AWS 访问密钥 ID | aws_access_key_id |
Amazon Web Services (AWS) | Amazon AWS 机密访问密钥 | aws_secret_access_key |
Amazon Web Services (AWS) | Amazon AWS Session Token | aws_session_token |
Amazon Web Services (AWS) | Amazon AWS Temporary Access Key ID | aws_temporary_access_key_id |
Asana | Asana 个人访问令牌 | asana_personal_access_token |
Atlassian | Bitbucket 服务器个人访问令牌 | bitbucket_server_personal_access_token |
Azure | Azure Active Directory 应用程序密钥 | azure_active_directory_application_secret |
Azure | Azure Cache for Redis Access Key | azure_cache_for_redis_access_key |
Azure | Azure DevOps 个人访问令牌 | azure_devops_personal_access_token |
Checkout.com | Checkout.com 生产密钥 | checkout_production_secret_key |
Clojars | Clojars 部署令牌 | clojars_deploy_token |
Databricks | Databricks 访问令牌 | databricks_access_token |
DigitalOcean | DigitalOcean 个人访问令牌 | digitalocean_personal_access_token |
DigitalOcean | DigitalOcean OAuth 令牌 | digitalocean_oauth_token |
DigitalOcean | DigitalOcean 刷新令牌 | digitalocean_refresh_token |
DigitalOcean | DigitalOcean 系统令牌 | digitalocean_system_token |
Discord | Discord 自动程序令牌 | discord_bot_token |
Doppler | Doppler 个人令牌 | doppler_personal_token |
Doppler | Doppler 服务令牌 | doppler_service_token |
Doppler | Doppler CLI 令牌 | doppler_cli_token |
Doppler | Doppler SCIM 令牌 | doppler_scim_token |
Doppler | Doppler Audit 令牌 | doppler_audit_token |
Dropbox | Dropbox 短暂访问令牌 | dropbox_short_lived_access_token |
Duffel | Duffel Live Access Token | duffel_live_access_token |
EasyPost | EasyPost Production API Key | easypost_production_api_key |
Flutterwave | Flutterwave Live API Secret Key | flutterwave_live_api_secret_key |
Fullstory | FullStory API 密钥 | fullstory_api_key |
GitHub | GitHub 个人访问令牌 | github_personal_access_token |
GitHub | GitHub OAuth 访问令牌 | github_oauth_access_token |
GitHub | GitHub 刷新令牌 | github_refresh_token |
GitHub | GitHub App 安装访问令牌 | github_app_installation_access_token |
GitHub | GitHub SSH 私钥 | github_ssh_private_key |
Google Cloud Storage Access Key Secret | google_cloud_storage_access_key_secret | |
Google Cloud Storage Service Account Access Key ID | google_cloud_storage_service_account_access_key_id | |
Google Cloud Storage User Access Key ID | google_cloud_storage_user_access_key_id | |
Grafana | Grafana API 密钥 | grafana_api_key |
Hubspot | Hubspot API 密钥 | hubspot_api_key |
Intercom | Intercom 访问令牌 | intercom_access_token |
Ionic | Ionic 个人访问令牌 | ionic_personal_access_token |
Ionic | Ionic 刷新令牌 | ionic_refresh_token |
线性 | 线性 API 密钥 | linear_api_key |
线性 | 线性 OAuth 访问令牌 | linear_oauth_access_token |
Midtrans | Midtrans Production Server Key | midtrans_production_server_key |
New Relic | New Relic Personal API Key | new_relic_personal_api_key |
New Relic | New Relic REST API Key | new_relic_rest_api_key |
New Relic | New Relic Insights Query Key | new_relic_insights_query_key |
npm | npm 访问令牌 | npm_access_token |
NuGet | NuGet API 密钥 | nuget_api_key |
Onfido | Onfido Live API Token | onfido_live_api_token |
OpenAI | OpenAI API 密钥 | openai_api_key |
PlanetScale | Planetscale 数据库密码 | planetscale_database_password |
PlanetScale | Planetscale OAuth 令牌 | planetscale_oauth_token |
PlanetScale | PlanetScale 服务令牌 | planetscale_service_token |
Postman | Postman API 密钥 | postman_api_key |
Proctorio | Proctorio 密钥 | proctorio_secret_key |
redirect.pizza | redirect.pizza API Token | redirect_pizza_api_token Samsara |
启用 秘密扫描 作为推送保护
要将 秘密扫描 用作推送保护,组织或存储库需要同时启用 GitHub Advanced Security 和 秘密扫描。 更多信息请参阅“管理组织的安全性和分析设置”、“管理存储库的安全和分析设置”和“关于 GitHub Advanced Security”。
组织所有者、安全管理员和存储库管理员可以通过 UI 和 API 为 秘密扫描 启用推送保护。 更多信息请参阅“存储库”,并展开 REST API 文档中的“security_and_analysis
对象的属性”部分。
启用 秘密扫描 作为组织的推送保护
- 在 GitHub.com 上,导航到组织的主页面。
- 在组织名称下,单击
设置.
-
在边栏的“Security(安全性)”部分中,单击 Code security and analysis(代码安全性和分析)。
-
在“Code security and analysis(代码安全性和分析)”下,找到“GitHub Advanced Security”。
-
Under "秘密扫描", under "Push protection", click Enable all.
-
Optionally, click "Automatically enable for private repositories added to 秘密扫描."
启用 秘密扫描 作为存储库的推送保护
-
在 GitHub.com 上,导航到仓库的主页面。
-
在仓库名称下,单击 Settings(设置)。
-
In the "Security" section of the sidebar, click Code security and analysis.
-
在“Code security and analysis(代码安全性和分析)”下,找到“GitHub Advanced Security”。
-
Under "秘密扫描", under "Push protection", click Enable.
从命令行使用 秘密扫描 作为推送保护
当您尝试将受支持的密钥推送到启用了 秘密扫描 作为推送保护的存储库或组织时,GitHub 将阻止推送。 您可以从提交中删除机密,也可以按照提供的 URL 进行推送。
在命令行上一次最多会显示五个检测到的机密。 如果已在存储库中检测到特定机密,并且警报已存在,GitHub 不会阻止该机密。
如果需要从正在推送的分支上的最新提交(即 HEAD
)以及包含该机密的任何早期提交中删除机密,您可以从 HEAD
中删除机密,然后在引入提交和已删除机密的 HEAD
的第一个版本之间压缩提交。
注意:
- 如果您的 git 配置支持推送到多个分支,而不仅仅是到默认分支,则您的推送可能会由于推送了其他和意外的引用而被阻止。 更多信息请参阅 Git 文档中的
push.default
选项。 - 如果在推送时 秘密扫描 超时,GitHub 仍将在推送后运行扫描。
允许推送被阻止的机密
如果 GitHub 阻止了您认为可以安全推送的机密,则可以允许该机密并说明应允许该机密的原因。
如果确认某个机密是真实的,并且打算稍后修复它,则应尽快修复。 例如,您可以撤销密钥,并从存储库的提交历史记录中删除密钥。 更多信息请参阅“从仓库中删除敏感数据”。
当您允许推送密钥时,将在“Security(安全)”选项卡中创建警报。 GitHub closes the alert and doesn't send a notification if you specify that the secret is a false positive or used only in tests. If you specify that the secret is real and that you will fix it later, GitHub keeps the security alert open and sends notifications to the author of the commit, as well as to repository administrators. 更多信息请参阅“管理来自密码扫描的警报”。
- 访问 GitHub 在推送被阻止时返回的 URL。
- 选择最准确描述为什么您应该能够推送密钥的选项。
- 如果机密仅在测试中使用,并且不构成威胁,请单击 It's used in tests(它在测试中使用)。
- 如果检测到的字符串不是机密,请单击 It's a false positive(这是误报)。
- 如果密钥是真实的,但您打算稍后修复它,请单击 I'll fix it later(稍后修复)。
- 单击 Allow me to push this secret(允许我推送此机密)。
- 在三小时内重新尝试在命令行上推送。 如果您在三小时内没有推送,则需要重复此过程。
使用密钥扫描作为 Web UI 的推送保护
当您使用 Web UI 尝试将受支持的密钥提交到启用了机密扫描作为推送保护的存储库或组织时,GitHub 将阻止提交。 您将在页面顶部看到一个横幅,其中包含有关密钥位置的信息,并且密钥也将在文件中加下划线,以便您可以轻松找到它。
GitHub 将在 Web UI 中一次仅显示一个检测到的机密。 如果已在存储库中检测到特定机密,并且警报已存在,GitHub 不会阻止该机密。
可以使用 Web UI 从文件中删除机密。 删除机密后,页面顶部的横幅将更改,并告诉您现在可以提交更改。
绕过密钥的推送保护
如果 GitHub 阻止了您认为可以安全推送的机密,则可以允许该机密并说明应允许该机密的原因。 如果确认某个机密是真实的,并且打算稍后修复它,则应尽快修复。
当您允许推送密钥时,将在“Security(安全)”选项卡中创建警报。 GitHub closes the alert and doesn't send a notification if you specify that the secret is a false positive or used only in tests. If you specify that the secret is real and that you will fix it later, GitHub keeps the security alert open and sends notifications to the author of the commit, as well as to repository administrators. 更多信息请参阅“管理来自密码扫描的警报”。
如果确认某个机密是真实的,并且打算稍后修复它,则应尽快修复。
-
在 GitHub 阻止提交时显示在页面顶部的横幅中,单击 Bypass protection(绕过保护)。
-
选择最准确描述为什么您应该能够推送密钥的选项。
- 如果机密仅在测试中使用,并且不构成威胁,请单击 It's used in tests(它在测试中使用)。
- 如果检测到的字符串不是机密,请单击 It's a false positive(这是误报)。
- 如果密钥是真实的,但您打算稍后修复它,请单击 I'll fix it later(稍后修复)。
-
单击 Allow secret(允许密钥)。