Managing code scanning alerts for your repository

You can view, fix, and close alerts for potential vulnerabilities or errors in your project's code.

People with write permission to a repository can manage code scanning alerts for the repository.

In this article

Did this doc help you?

Note: Code scanning is currently in beta and subject to change. To request access to the beta, join the waitlist.

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 "Enabling 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."

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.

Example alert from code scanning

If you enable 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 an alert

Anyone with read permission for a repository can see code scanning alerts on pull requests. However, you need write permission to view a summary of alerts for repository on the Security tab. By default, alerts are shown for the default branch.

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Security.
    Security tab
  3. In the left sidebar, click Code scanning alerts. Optionally, select the code scanning tool you used.
    "Code scanning alerts" tab
  4. Under "Code scanning," click the alert you'd like to explore.
    List of alerts from code scanning
  5. 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.
    Example data-flow alert

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."

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.

  1. On GitHub, navigate to the main page of the repository.
  2. Under your repository name, click Security.
    Security tab
  3. In the left sidebar, click Code scanning alerts. Optionally, select the code scanning tool you used.
    "Code scanning alerts" tab
  4. Under "Code scanning," click the alert you'd like to explore.
    List of alerts from code scanning
  5. Select the Close drop-down menu and click a reason for closing the alert.
    Choosing reason for closing the alert via the Close drop-down

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."

Further reading

Did this doc help you?