关于 代码扫描
代码扫描 是一项功能,可用于分析 GitHub 仓库中的代码,以查找安全漏洞和编码错误。 分析发现的任何问题都在 GitHub Enterprise Server 中显示。
下表概括了 代码扫描 的可用分析类型,并提供了为单个仓库启用功能的链接。
|
用于生成警报的选项 |
---|---|
CodeQL | Using GitHub Actions (see "Setting up 代码扫描 using actions") or using the CodeQL runner in a third-party continuous integration (CI) system (see "Running code scanning in your CI system"). |
第三方 | Using GitHub Actions (see "Setting up 代码扫描 using actions") or generated externally and uploaded to GitHub Enterprise Server (see "Uploading a SARIF file to GitHub"). |
为使用户 您的 GitHub Enterprise Server 实例 在仓库中启用 代码扫描,您需要作为站点管理员为整个设备启用此功能。
如何知道我的设备是否启用 代码扫描
- 从 GitHub Enterprise Server 上的管理帐户,点击任何页面右上角的 。
- 在左侧边栏中,单击 管理控制台。
- 检查左侧边栏中是否有 Advanced Security 条目。
If you can't see Advanced Security in the sidebar, it means that your license doesn't include support for Advanced Security features, including 代码扫描 and 秘密扫描. Advanced Security 的许可使您和您的用户能够访问那些有助于提高仓库和代码安全性的功能。 For more information, see "About GitHub Advanced Security" or contact GitHub' 销售团队.
启用 代码扫描
警告:更改此设置将导致 GitHub Enterprise Server 重启。 您应谨慎安排更改时间,以尽量减少停机时间。
- 从 GitHub Enterprise Server 上的管理帐户,点击任何页面右上角的 。
- 在左侧边栏中,单击 管理控制台。
- 在左侧边栏中,单击 Advanced Security。
- 在“
Advanced Security”下,单击 代码扫描。
- 在左侧边栏下,单击 Save settings(保存设置)。
- 等待配置运行完毕。
使用 GitHub Actions 运行 代码扫描
设置自托管运行器
GitHub Enterprise Server can run 代码扫描 using a GitHub Actions workflow. 首先,您需要在环境中预配一个或多个自托管的 GitHub Actions 运行器。 您可以在仓库、组织或企业帐户级别预配自托管运行器。 更多信息请参阅“关于自托管的运行器”和“添加自托管的运行器”。
您必须确保 Git 在用于运行 CodeQL 操作的任何自托管运行器上的 PATH 变量中。
Configuring CodeQL on a server without internet access
If the server on which you are running GitHub Enterprise Server is not connected to the internet, and you want to allow users to enable CodeQL 代码扫描 for their repositories, you must use the CodeQL Action sync tool to copy the CodeQL actions and query bundle from GitHub.com to your server. The tool, and details of how to use it, are available at https://github.com/github/codeql-action-sync-tool.
Enabling code scanning for individual repositories
After you configure a self-hosted runner, users can enable 代码扫描 for individual repositories on 您的 GitHub Enterprise Server 实例. For more information, see "Setting up 代码扫描 for a repository."
使用 CodeQL runner 运行 代码扫描
If you don't want to use GitHub Actions, you can run 代码扫描 using the CodeQL runner.
该 CodeQL runner 是一个命令行工具,您可以将其添加到第三方 CI/CD 系统中。 该工具在 GitHub 仓库检出时运行 CodeQL 分析。 更多信息请参阅“在 CI 系统中运行 代码扫描”。
禁用 代码扫描
警告:更改此设置将导致 GitHub Enterprise Server 重启。 您应谨慎安排更改时间,以尽量减少停机时间。
- 从 GitHub Enterprise Server 上的管理帐户,点击任何页面右上角的 。
- 在左侧边栏中,单击 管理控制台。
- 在左侧边栏中,单击 Advanced Security。
- 在“
Advanced Security”下,取消选择 代码扫描。
- 在左侧边栏下,单击 Save settings(保存设置)。
- 等待配置运行完毕。