如果你熟悉 GitHub 的安全产品,并且具有 GitHub-recommended security configuration 无法满足的特定安全需求,则可以创建并应用 custom security configurations。 有关详细信息,请参阅“为存储库选择安全配置”。
重要
某些设置的顺序和名称可能会因你使用的许可证不同而有所差异,这取决于使用的是最初的 GitHub Advanced Security 产品的许可证,还是两个新产品(GitHub Code Security 和 GitHub Secret Protection)的许可证。 请参阅创建 GitHub Advanced Security 配置或创建 Secret Protection and Code Security 配置。
创建 Secret Protection and Code Security 配置
-
在 GitHub 的右上角,单击个人资料图片,然后单击“ Your organizations”****。
-
在组织名称下,单击 “Settings”****。 如果看不到“设置”选项卡,请选择“”下拉菜单,然后单击“设置”********。

-
在边栏的“Security”部分中,选择“ Advanced Security”下拉菜单,然后单击“Configurations”********。
-
在“ 并在“Security configurations”页面上明确其用途,请为配置命名并创建一段说明。
-
(可选)启用“Secret Protection”,这是一个针对专用和内部存储库的付费功能。 启用 Secret Protection 将启用 secret scanning 的警报。 此外,你可以选择是启用、禁用还是保持以下 secret scanning 功能的现有设置:
-
**有效性检查**。 若要详细了解合作伙伴模式的验证检查,请参阅 [AUTOTITLE](/code-security/secret-scanning/managing-alerts-from-secret-scanning/evaluating-alerts#checking-a-secrets-validity). -
**非提供商模式**。 要了解有关扫描非提供者模式的更多信息,请参见“[AUTOTITLE](/code-security/secret-scanning/introduction/supported-secret-scanning-patterns#non-provider-patterns)”和“[AUTOTITLE](/code-security/secret-scanning/managing-alerts-from-secret-scanning/viewing-alerts)”。 -
**扫描泛型密码**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/secret-scanning/copilot-secret-scanning/responsible-ai-generic-secrets)”。 -
**推送保护**。 要了解推送保护,请参阅“[AUTOTITLE](/code-security/secret-scanning/introduction/about-push-protection)”。 -
**绕过权限**。 通过分配绕过特权,选定的组织成员可以绕过推送保护,并且所有其他参与者都有评审和审批过程。 请参阅“[AUTOTITLE](/code-security/secret-scanning/using-advanced-secret-scanning-and-push-protection-features/delegated-bypass-for-push-protection/about-delegated-bypass-for-push-protection)”。 -
**防止直接关闭警报**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/secret-scanning/using-advanced-secret-scanning-and-push-protection-features/enabling-delegated-alert-dismissal-for-secret-scanning)”。
-
-
(可选)启用“Code Security”,这是一个针对专用和内部仓库的付费功能。 此外,你可以选择是启用、禁用还是保持以下 code scanning 功能的现有设置:
-
**默认设置**。 有关默认设置的详细信息,请参阅 [AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning#about-default-setup)。注意
要创建可应用于所有仓库(无论当前 code scanning 设置如何)的配置,请选择“Enabled with advanced setup allowed”。 此设置仅在未积极运行 CodeQL 分析的仓库中启用默认设置。 GitHub Enterprise Server 3.19 中提供的选项。
-
**运行程序类型**。 如果要将 code scanning 的特定运行程序作为目标,可以在此步骤选择使用自定义标签的运行程序。 请参阅“[AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning#assigning-labels-to-runners)”。 -
**防止直接关闭警报**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/code-scanning/managing-your-code-scanning-configuration/enabling-delegated-alert-dismissal-for-code-scanning)”。
-
-
仍然在“Code Security”下,在“Dependency scanning”表格中,选择是启用、禁用还是保持以下依赖扫描功能的现有设置:
-
**依赖项关系图**。 若要了解依赖项关系图,请参阅“[AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph)”。提示
启用“Code Security”和依赖项关系图时,这将启用依赖项检查,请参阅“关于依赖项评审”。
-
**自动依赖项提交**。 若要了解自动依赖项提交,请参阅 [AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/configuring-automatic-dependency-submission-for-your-repository)。 -
**Dependabot 警报**。 若要详细了解 Dependabot,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-alerts/about-dependabot-alerts)。 -
**安全更新**。 若要了解安全更新,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates)。 -
**防止直接关闭警报**。 若要了解详细信息,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-alerts/enable-delegated-alert-dismissal)。
-
-
(可选)在“Policy”部分,可以使用其他选项来控制配置的应用方式:
-
**用作新创建的存储库的默认值**。 选择“None”<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-triangle-down" aria-label="triangle-down" role="img"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg> 下拉菜单,然后单击“Public”、“Private and internal”或“All repositories”****************。注意
组织的默认 security configuration 仅自动应用到组织内新创建的存储库。 如果将存储库传输到组织,则仍需将适当的 security configuration 手动应用到存储库。
-
**强制执行配置**。 阻止存储库所有者更改通过配置启用或禁用的功能(不会强制执行未设置的功能)。 从下拉菜单中选择“Enforce”****。
-
-
若要完成 custom security configuration 的创建,请单击“保存配置”。
注意
如果你企业中的用户尝试使用 REST API 更改强制配置中某个功能的启用状态,则 API 调用将似乎会成功,但启用状态不会发生更改。
在某些情况下,可能会中断存储库的 security configurations 强制实施。 例如,在以下情况下,code scanning 的启用将不适用于存储库:
- GitHub Actions 最初在存储库上启用,但在存储库中禁用。
- code scanning 配置所需的 GitHub Actions 在存储库中不可用。
- 不应使用 code scanning 默认设置分析语言的定义已更改。
创建 GitHub Advanced Security 配置
-
在 GitHub 的右上角,单击个人资料图片,然后单击“ Your organizations”****。
-
在组织名称下,单击 “Settings”****。 如果看不到“设置”选项卡,请选择“”下拉菜单,然后单击“设置”********。

-
在边栏的“Security”部分中,选择“ Advanced Security”下拉菜单,然后单击“Configurations”********。
-
在“安全配置”部分,单击“新配置”****。
-
为帮助识别 custom security configuration 并在“新配置”页面上明确其用途,请为配置命名并创建一段说明。
-
在“GitHub Advanced Security features”行中,选择是包含还是排除 GitHub Advanced Security (GHAS) 功能。
-
在“Secret scanning”表中,选择是要启用、禁用还是保留以下安全功能的现有设置:
-
**有效性检查**。 若要详细了解合作伙伴模式的验证检查,请参阅 [AUTOTITLE](/code-security/secret-scanning/managing-alerts-from-secret-scanning/evaluating-alerts#checking-a-secrets-validity). -
**非提供商模式**。 要了解有关扫描非提供者模式的更多信息,请参见“[AUTOTITLE](/code-security/secret-scanning/introduction/supported-secret-scanning-patterns#non-provider-patterns)”和“[AUTOTITLE](/code-security/secret-scanning/managing-alerts-from-secret-scanning/viewing-alerts)”。 -
**扫描泛型密码**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/secret-scanning/copilot-secret-scanning/responsible-ai-generic-secrets)”。 -
**推送保护**。 要了解推送保护,请参阅“[AUTOTITLE](/code-security/secret-scanning/introduction/about-push-protection)”。 -
**绕过权限**。 通过分配绕过特权,选定的组织成员可以绕过推送保护,并且所有其他参与者都有评审和审批过程。 请参阅“[AUTOTITLE](/code-security/secret-scanning/using-advanced-secret-scanning-and-push-protection-features/delegated-bypass-for-push-protection/about-delegated-bypass-for-push-protection)”。 -
**防止直接关闭警报**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/secret-scanning/using-advanced-secret-scanning-and-push-protection-features/enabling-delegated-alert-dismissal-for-secret-scanning)”。
-
-
在“Code scanning”表中,选择是要启用、禁用还是保留 code scanning 默认设置的现有设置。
-
**默认设置**。 有关默认设置的详细信息,请参阅 [AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning#about-default-setup)。注意
要创建可应用于所有仓库(无论当前 code scanning 设置如何)的配置,请选择“Enabled with advanced setup allowed”。 此设置仅在未积极运行 CodeQL 分析的仓库中启用默认设置。 GitHub Enterprise Server 3.19 中提供的选项。
-
**运行程序类型**。 如果要将 code scanning 的特定运行程序作为目标,可以在此步骤选择使用自定义标签的运行程序。 请参阅“[AUTOTITLE](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning#assigning-labels-to-runners)”。 -
**防止直接关闭警报**。 要了解详细信息,请参阅“[AUTOTITLE](/code-security/code-scanning/managing-your-code-scanning-configuration/enabling-delegated-alert-dismissal-for-code-scanning)”。
-
-
在“依赖项扫描”表中,选择是要启用、禁用还是保留以下依赖项扫描功能的现有设置:
-
**依赖项关系图**。 若要了解依赖项关系图,请参阅“[AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph)”。提示
同时启用“GitHub Advanced Security”和“依赖项关系图”时,这将启用依赖项检查,请参阅 关于依赖项评审。
-
**自动依赖项提交**。 若要了解自动依赖项提交,请参阅 [AUTOTITLE](/code-security/supply-chain-security/understanding-your-software-supply-chain/configuring-automatic-dependency-submission-for-your-repository)。 -
**Dependabot 警报**。 若要详细了解 Dependabot,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-alerts/about-dependabot-alerts)。 -
**安全更新**。 若要了解安全更新,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-security-updates/about-dependabot-security-updates)。 -
**防止直接关闭警报**。 若要了解详细信息,请参阅 [AUTOTITLE](/code-security/dependabot/dependabot-alerts/enable-delegated-alert-dismissal)。
-
-
(可选)在“Policy”部分,可以使用其他选项来控制配置的应用方式:
-
**用作新创建的存储库的默认值**。 选择“None”<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-triangle-down" aria-label="triangle-down" role="img"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg> 下拉菜单,然后单击“Public”、“Private and internal”或“All repositories”****************。注意
组织的默认 security configuration 仅自动应用到组织内新创建的存储库。 如果将存储库传输到组织,则仍需将适当的 security configuration 手动应用到存储库。
-
**强制执行配置**。 阻止存储库所有者更改通过配置启用或禁用的功能(不会强制执行未设置的功能)。 从下拉菜单中选择“Enforce”****。
-
-
若要完成 custom security configuration 的创建,请单击“保存配置”。
后续步骤
如需了解如何将 custom security configuration 应用到组织中的存储库,请参阅 删除自定义安全配置。
若要了解如何编辑 custom security configuration,请参阅 编辑自定义安全配置。