Note: Code scanning is in beta in GitHub Enterprise Server 2.22. For the generally available release of code scanning, upgrade to the latest release of GitHub Enterprise Server.
code scanning について
Code scanning is a feature that you use to analyze the code in a GitHub repository to find security vulnerabilities and coding errors. Any problems identified by the analysis are shown in GitHub Enterprise Server.
以下の表は、code scanning で利用可能な分析タイプをまとめたもので、個々のリポジトリで機能を有効化するためのリンクを示しています。
|
Options for generating alerts |
---|---|
CodeQL | Using GitHub Actions (see "Setting up code scanning using actions") or using the CodeQL runner in a third-party continuous integration (CI) system (see "Running code scanning in your CI system"). |
Third‑party | Using GitHub Actions (see "Setting up code scanning using actions") or generated externally and uploaded to GitHub Enterprise Server (see "Uploading a SARIF file to GitHub"). |
your GitHub Enterprise Server instance のユーザがリポジトリで code scanning を有効化して使用できるようにするには、サイト管理者として、アプライアンス全体でこの機能を有効にする必要があります。
アプライアンスで code scanning が有効かどうかを確認する方法
- From an administrative account on GitHub Enterprise Server, click in the upper-right corner of any page.
- 左のサイドバーでManagement Consoleをクリックしてください。
- 左のサイドバーに 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 code scanning and secret scanning. Advanced Security ライセンスを使用すると、リポジトリとコードのセキュリティを強化するのに役立つ機能にアクセスできます。
code scanning の有効化
Warning: Changing this setting will cause GitHub Enterprise Server to restart. You should time this change carefully, to minimize downtime.
- From an administrative account on GitHub Enterprise Server, click in the upper-right corner of any page.
- 左のサイドバーでManagement Consoleをクリックしてください。
- 左のサイドバーでAdvanced Securityをクリックしてください。
- [
Advanced Security] の下にある [Code scanning] をクリックします。
- 左のサイドバーの下でSave settings(設定の保存)をクリックしてください。
- 設定が完了するのを待ってください。
GitHub Actions を使用して code scanning を実行する
セルフホストランナーを設定する
GitHub Enterprise Server can run code scanning using a GitHub Actions workflow. まず、環境内に 1 つ以上のセルフホスト GitHub Actions ランナーをプロビジョニングする必要があります。 セルフホストランナーは、リポジトリ、Organization、または Enterprise アカウントレベルでプロビジョニングできます。 詳しい情報については、「セルフホストランナーについて」および「セルフホストランナーを追加する」を参照してください。
CodeQL アクションを実行するために使用するセルフホストランナーの PATH 変数に Git が含まれていることを確認する必要があります。
Provisioning the actions
To run code scanning on GitHub Enterprise Server with GitHub Actions, the appropriate actions must be available locally. You can make the actions available in three ways.
- Recommended: You can use GitHub Connect to automatically download actions from GitHub.com. インスタンスをホストするマシンは、GitHub.com にアクセス可能である必要があります。 この方法で、最新のソフトウェアを自動的に入手できます。 詳しい情報については、「GitHub Actions を同期するために GitHub Connect を設定する」を参照してください。
- CodeQL analysis workflow を使用する場合は、https://github.com/github/codeql-action-sync-tool にある CodeQL Action 同期ツールを使用して、リポジトリを GitHub.com から GitHub Enterprise Server に同期できます。 コンピューターで your GitHub Enterprise Server instance と GitHub.com の両方に同時にアクセスできる限り、your GitHub Enterprise Server instance または GitHub Actions ランナーがインターネットにアクセスできるかどうかに関係なく、このツールを使用できます。
- You can create a local copy of an action's repository on your server, by cloning the GitHub.com repository that contains the action. For example, if you want to use the actions for CodeQL code scanning, you can create a repository in your instance called
github/codeql-action
, then clone the repository from GitHub.com, and then push that repository to your instance'sgithub/codeql-action
repository. また、GitHub.com のリポジトリからリリースをダウンロードし、リリースとしてインスタンスのgithub/codeql-action
リポジトリにアップロードする必要があります。
GitHub Actions を同期するために GitHub Connect を設定する
- GitHub.com からオンデマンドでアクションワークフローをダウンロードする場合は、GitHub Connect を有効にする必要があります。 詳しい情報については、「GitHub Connect を有効化する」を参照してください。
- また、your GitHub Enterprise Server instance に対して GitHub Actions を有効化する必要があります。 For more information, see "Getting started with GitHub Actions for GitHub Enterprise Server."
- 次のステップは、GitHub Connect を使用して、GitHub.com に対するアクションへのアクセスを設定することです。 詳しい情報については、「GitHub Connect を使用した GitHub.com アクションへの自動アクセスを有効化する」を参照してください。
- セルフホストランナーをリポジトリ、Organization、または Enterprise アカウントに追加します。 詳しい情報については「セルフホストランナーの追加」を参照してください。
Enabling code scanning for individual repositories
After you configure a self-hosted runner, and provision the actions, users can enable code scanning for individual repositories on your GitHub Enterprise Server instance. For more information, see "Setting up code scanning for a repository."
CodeQL runner を使用して code scanning を実行する
If you don't want to use GitHub Actions, you can run code scanning using the CodeQL runner.
CodeQL runner は、サードパーティの CI/CD システムに追加できるコマンドラインツールです。 このツールは、GitHub リポジトリのチェックアウトに対して CodeQL 分析を実行します。 詳しい情報については、「code scanning を CI システムで実行する」を参照してください。
code scanning を無効にする
Warning: Changing this setting will cause GitHub Enterprise Server to restart. You should time this change carefully, to minimize downtime.
- From an administrative account on GitHub Enterprise Server, click in the upper-right corner of any page.
- 左のサイドバーでManagement Consoleをクリックしてください。
- 左のサイドバーでAdvanced Securityをクリックしてください。
- [
[Advanced Security] の下にある [Code scanning] を選択解除します。
- 左のサイドバーの下でSave settings(設定の保存)をクリックしてください。
- 設定が完了するのを待ってください。