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.
About alerts from code scanning
You can set up code scanning to check the code in a repository using the default CodeQL analysis, a third-party analysis, or multiple types of analysis. When the analysis is complete, the resulting alerts are displayed alongside each other in the security view of the repository. Results from third-party tools or from custom queries may not include all of the properties that you see for alerts detected by GitHub's default CodeQL analysis. For more information, see "Setting up code scanning for a repository."
By default, code scanning analyzes your code periodically on the default branch and during pull requests. For information about managing alerts on a pull request, see "Triaging code scanning alerts in pull requests."
Notes:
-
SARIF upload supports a maximum of 1000 results per upload. Any results over this limit are ignored. If a tool generates too many results, you should update the configuration to focus on results for the most important rules or queries.
-
For each upload, SARIF upload supports a maximum size of 10 MB for the
gzip
-compressed SARIF file. Any uploads over this limit will be rejected. If your SARIF file is too large because it contains too many results, you should update the configuration to focus on results for the most important rules or queries.
About alerts details
Each alert highlights a problem with the code and the name of the tool that identified it. You can see the line of code that triggered the alert, as well as properties of the alert, such as the severity and the nature of the problem. Alerts also tell you when the issue was first introduced. For alerts identified by CodeQL analysis, you will also see information on how to fix the problem.
If you set up code scanning using CodeQL, this can also detect data-flow problems in your code. Data-flow analysis finds potential security issues in code, such as: using data insecurely, passing dangerous arguments to functions, and leaking sensitive information.
When code scanning reports data-flow alerts, GitHub shows you how data moves through the code. Code scanning allows you to identify the areas of your code that leak sensitive information, and that could be the entry point for attacks by malicious users.
Viewing the alerts for a repository
Anyone with read permission for a repository can see code scanning annotations on pull requests. For more information, see "Triaging code scanning alerts in pull requests."
You need write permission to view a summary of all the alerts for a repository on the Security tab. By default, alerts are shown for the default branch.
- On your GitHub Enterprise Server instance, navigate to the main page of the repository.
- Under your repository name, click Security.
- In the left sidebar, click Code scanning alerts.
- Under "Code scanning," click the alert you'd like to explore.
- Optionally, if the alert highlights a problem with data flow, click Show paths to display the path from the data source to the sink where it's used.
- Alerts from CodeQL analysis include a description of the problem. Click Show more for guidance on how to fix your code.
Fixing an alert
Anyone with write permission for a repository can fix an alert by committing a correction to the code. If the repository has code scanning scheduled to run on pull requests, it's best to raise a pull request with your correction. This will trigger code scanning analysis of the changes and test that your fix doesn't introduce any new problems. For more information, see "Configuring code scanning" and "Triaging code scanning alerts in pull requests."
If you have write permission for a repository, you can view fixed alerts by viewing the summary of alerts and clicking Closed. For more information, see "Viewing the alerts for a repository." The "Closed" list shows fixed alerts and alerts that users have closed.
Alerts may be fixed in one branch but not in another. You can use the "Branch" drop-down menu, on the summary of alerts, to check whether an alert is fixed in a particular branch.
Closing an alert
Closing an alert is a way to resolve an alert that you don't think needs to be fixed. For example, an error in code that's used only for testing, or when the effort of fixing the error is greater than the potential benefit of improving the code.
-
On your GitHub Enterprise Server instance, navigate to the main page of the repository.
-
Under your repository name, click Security.
-
In the left sidebar, click Code scanning alerts.
-
Under "Code scanning," click the alert you'd like to explore.
-
Select the Close drop-down menu and click a reason for closing the alert.
If you close a CodeQL alert as a false positive result, for example because the code uses a sanitization library that isn't supported, consider contributing to the CodeQL repository and improving the analysis. For more information about CodeQL, see "Contributing to CodeQL."