# 与代码扫描集成

您可以在外部执行 code scanning，然后在 GitHub 中显示结果，或者配置 Webhook 以侦听仓库中的 code scanning 活动。

## 关于与代码扫描的集成

> \[!NOTE]
> 网站管理员必须先启用 code scanning 才能使用此功能。 有关详细信息，请参阅“[为设备配置代码扫描](/zh/enterprise-server@3.22/code-security/how-tos/secure-at-scale/configure-enterprise-security/configure-specific-tools/configuring-code-scanning-for-your-appliance)”。
>
> 如果企业所有者在企业级别设置了code scanning策略，则可能无法启用或禁用GitHub Code Security。 有关详细信息，请参阅“[强制实施企业的代码安全性和分析策略](/zh/enterprise-server@3.22/admin/enforcing-policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-code-security-and-analysis-for-your-enterprise)”。

作为在 code scanning 中运行 GitHub 的替代方案，您可以使用 CodeQL CLI 或其他静态分析工具在其他环境中进行分析，然后上传结果。 有关详细信息，请参阅“[在现有 CI 系统上使用代码扫描](/zh/enterprise-server@3.22/code-security/how-tos/find-and-fix-code-vulnerabilities/integrate-with-existing-tools/use-with-existing-ci-system)”。

如果使用多个配置运行代码扫描，则警报有时会有多个分析源。 如果警报有多个分析源，你可在警报页上查看每个分析源的警报状态。 有关详细信息，请参阅“[代码扫描警报](/zh/enterprise-server@3.22/code-security/concepts/code-scanning/code-scanning-alerts#about-alerts-from-multiple-configurations)”。

## 与 web 挂钩集成

您可以使用 code scanning webhook 来构建或配置集成（例如 [GitHub Apps](/zh/enterprise-server@3.22/apps/creating-github-apps/registering-a-github-app) 或 [OAuth apps](/zh/enterprise-server@3.22/apps/oauth-apps/building-oauth-apps)），以订阅您仓库中的 code scanning 事件。 例如，你可以构建一个集成，在 GitHub 上创建问题，或者在你的代码库中新增 code scanning 警报时向你发送 Slack 通知。 有关详细信息，请参阅 [Webhooks 文档](/zh/enterprise-server@3.22/webhooks) 和 [Webhook 事件和有效负载](/zh/enterprise-server@3.22/webhooks/webhook-events-and-payloads#code_scanning_alert)。

## 延伸阅读

* [代码扫描](/zh/enterprise-server@3.22/code-security/concepts/code-scanning/code-scanning)
* [在现有 CI 系统上使用代码扫描](/zh/enterprise-server@3.22/code-security/how-tos/find-and-fix-code-vulnerabilities/integrate-with-existing-tools/use-with-existing-ci-system)
* [对代码扫描的 SARIF 支持](/zh/enterprise-server@3.22/code-security/reference/code-scanning/sarif-files/sarif-support)