Skip to content

Commit ee2f756

Browse files
authored
CodeQL ML-powered JavaScript queries (public beta) (github#24363)
1 parent 52f0a06 commit ee2f756

26 files changed

+177
-78
lines changed
40.4 KB
Loading
215 KB
Loading
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
title: About code scanning alerts
3+
intro: 'Learn about the different types of code scanning alerts and the information that helps you understand the problem each alert highlights.'
4+
product: '{% data reusables.gated-features.code-scanning %}'
5+
versions:
6+
fpt: '*'
7+
ghes: '*'
8+
ghae: '*'
9+
ghec: '*'
10+
type: overview
11+
topics:
12+
- Advanced Security
13+
- Code scanning
14+
- CodeQL
15+
---
16+
17+
{% data reusables.code-scanning.beta %}
18+
{% data reusables.code-scanning.enterprise-enable-code-scanning %}
19+
20+
## About alerts from {% data variables.product.prodname_code_scanning %}
21+
22+
You can set up {% data variables.product.prodname_code_scanning %} to check the code in a repository using the default {% data variables.product.prodname_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 {% data variables.product.company_short %}'s default {% data variables.product.prodname_codeql %} analysis. For more information, see "[Setting up {% data variables.product.prodname_code_scanning %} for a repository](/code-security/secure-coding/setting-up-code-scanning-for-a-repository)."
23+
24+
By default, {% data variables.product.prodname_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 {% data variables.product.prodname_code_scanning %} alerts in pull requests](/code-security/secure-coding/triaging-code-scanning-alerts-in-pull-requests)."
25+
26+
## About alert details
27+
28+
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 alert severity{% ifversion fpt or ghes > 3.1 or ghae or ghec %}, security severity,{% endif %} and the nature of the problem. Alerts also tell you when the issue was first introduced. For alerts identified by {% data variables.product.prodname_codeql %} analysis, you will also see information on how to fix the problem.
29+
30+
![Example alert from {% data variables.product.prodname_code_scanning %}](/assets/images/help/repository/code-scanning-alert.png)
31+
32+
If you set up {% data variables.product.prodname_code_scanning %} using {% data variables.product.prodname_codeql %}, you can also find 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.
33+
34+
When {% data variables.product.prodname_code_scanning %} reports data-flow alerts, {% data variables.product.prodname_dotcom %} shows you how data moves through the code. {% data variables.product.prodname_code_scanning_capc %} 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.
35+
36+
### About severity levels
37+
38+
Alert severity levels may be `Error`, `Warning`, or `Note`.
39+
40+
If {% data variables.product.prodname_code_scanning %} is enabled as a pull request check, the check will fail if it detects any results with a severity of `error`. {% ifversion fpt or ghes > 3.1 or ghae or ghec %}You can specify which severity level of code scanning alerts causes a check failure. For more information, see "[Defining the severities causing pull request check failure](/code-security/secure-coding/configuring-code-scanning#defining-the-severities-causing-pull-request-check-failure)."{% endif %}
41+
42+
{% ifversion fpt or ghes > 3.1 or ghae or ghec %}
43+
### About security severity levels
44+
45+
{% data variables.product.prodname_code_scanning_capc %} displays security severity levels for alerts that are generated by security queries. Security severity levels can be `Critical`, `High`, `Medium`, or `Low`.
46+
47+
To calculate the security severity of an alert, we use Common Vulnerability Scoring System (CVSS) data. CVSS is an open framework for communicating the characteristics and severity of software vulnerabilities, and is commonly used by other security products to score alerts. For more information about how severity levels are calculated, see [this blog post](https://github.blog/changelog/2021-07-19-codeql-code-scanning-new-severity-levels-for-security-alerts/).
48+
49+
By default, any {% data variables.product.prodname_code_scanning %} results with a security severity of `Critical` or `High` will cause a check failure. You can specify which security severity level for {% data variables.product.prodname_code_scanning %} results should cause a check failure. For more information, see "[Defining the severities causing pull request check failure](/code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#defining-the-severities-causing-pull-request-check-failure)."{% endif %}
50+
51+
### About labels for alerts that are not found in application code
52+
53+
{% data variables.product.product_name %} assigns a category label to alerts that are not found in application code. The label relates to the location of the alert.
54+
55+
- **Generated**: Code generated by the build process
56+
- **Test**: Test code
57+
- **Library**: Library or third-party code
58+
- **Documentation**: Documentation
59+
60+
{% data variables.product.prodname_code_scanning_capc %} categorizes files by file path. You cannot manually categorize source files.
61+
62+
Here is an example from the {% data variables.product.prodname_code_scanning %} alert list of an alert marked as occurring in library code.
63+
64+
![Code scanning library alert in list](/assets/images/help/repository/code-scanning-library-alert-index.png)
65+
66+
On the alert page, you can see that the filepath is marked as library code (`Library` label).
67+
68+
![Code scanning library alert details](/assets/images/help/repository/code-scanning-library-alert-show.png)
69+
70+
{% if codeql-ml-queries %}
71+
72+
## About experimental alerts
73+
74+
{% data reusables.code-scanning.beta-codeql-ml-queries %}
75+
76+
In repositories that run {% data variables.product.prodname_code_scanning %} using the {% data variables.product.prodname_codeql %} action, you may see some alerts that are marked as experimental. These are alerts that were found using a machine learning model to extend the capabilities of an existing {% data variables.product.prodname_codeql %} query.
77+
78+
![Code scanning experimental alert in list](/assets/images/help/repository/code-scanning-experimental-alert-list.png)
79+
80+
### Benefits of using machine learning models to extend queries
81+
82+
Queries that use machine learning models are capable of finding vulnerabilities in code that was written using frameworks and libraries that the original query writer did not include.
83+
84+
Each of the security queries for {% data variables.product.prodname_codeql %} identifies code that's vulnerable to a specific type of attack. Security researchers write the queries and include the most common frameworks and libraries. So each existing query finds vulnerable uses of common frameworks and libraries. However, developers use many different frameworks and libraries, and a manually maintained query cannot include them all. Consequently, manually maintained queries do not provide coverage for all frameworks and libraries.
85+
86+
{% data variables.product.prodname_codeql %} uses a machine learning model to extend an existing security query to cover a wider range of frameworks and libraries. The machine learning model is trained to detect problems in code it's never seen before. Queries that use the model will find results for frameworks and libraries that are not described in the original query.
87+
88+
### Alerts identified using machine learning
89+
90+
Alerts found using a machine learning model are tagged as "Experimental alerts" to show that the technology is under active development. These alerts have a higher rate of false positive results than the queries they are based on. The machine learning model will improve based on user actions such as marking a poor result as a false positive or fixing a good result.
91+
92+
![Code scanning experimental alert details](/assets/images/help/repository/code-scanning-experimental-alert-show.png)
93+
94+
## Enabling experimental alerts
95+
96+
The default {% data variables.product.prodname_codeql %} query suites do not include any queries that use machine learning to generate experimental alerts. To run machine learning queries during {% data variables.product.prodname_code_scanning %} you need to run the additional queries contained in one of the following query suites.
97+
98+
{% data reusables.code-scanning.codeql-query-suites %}
99+
100+
When you update your workflow to run an additional query suite this will increase the analysis time.
101+
102+
``` yaml
103+
- uses: github/codeql-action/init@v1
104+
with:
105+
# Run extended queries including queries using machine learning
106+
queries: security-extended
107+
```
108+
109+
For more information, see "[Configuring code scanning](/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs)."
110+
111+
## Disabling experimental alerts
112+
113+
The simplest way to disable queries that use machine learning to generate experimental alerts is to stop running the `security-extended` or `security-and-quality` query suite. In the example above, you would comment out the `queries` line. If you need to continue to run the `security-extended` or `security-and-quality` suite and the machine learning queries are causing problems, then you can open a ticket with [{% data variables.product.company_short %} support](https://support.github.com/contact) with the following details.
114+
115+
- Ticket title: "{% data variables.product.prodname_code_scanning %}: removal from experimental alerts beta"
116+
- Specify details of the repositories or organizations that are affected
117+
- Request an escalation to engineering
118+
119+
{% endif %}

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-with-codeql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ There are two main ways to use {% data variables.product.prodname_codeql %} anal
4343

4444
## About {% data variables.product.prodname_codeql %} queries
4545

46-
{% data variables.product.company_short %} experts, security researchers, and community contributors write and maintain the default {% data variables.product.prodname_codeql %} queries used for {% data variables.product.prodname_code_scanning %}. The queries are regularly updated to improve analysis and reduce any false positive results. The queries are open source, so you can view and contribute to the queries in the [`github/codeql`](https://github.com/github/codeql) repository. For more information, see [{% data variables.product.prodname_codeql %}](https://securitylab.github.com/tools/codeql) on the GitHub Security Lab website. You can also write your own queries. For more information, see "[About {% data variables.product.prodname_codeql %} queries](https://codeql.github.com/docs/writing-codeql-queries/about-codeql-queries/)" in the {% data variables.product.prodname_codeql %} documentation.
46+
{% data variables.product.company_short %} experts, security researchers, and community contributors write and maintain the default {% data variables.product.prodname_codeql %} queries used for {% data variables.product.prodname_code_scanning %}. The queries are regularly updated to improve analysis and reduce any false positive results. The queries are open source, so you can view and contribute to the queries in the [`github/codeql`](https://github.com/github/codeql) repository. For more information, see [{% data variables.product.prodname_codeql %}](https://codeql.github.com/) on the {% data variables.product.prodname_codeql %} website. You can also write your own queries. For more information, see "[About {% data variables.product.prodname_codeql %} queries](https://codeql.github.com/docs/writing-codeql-queries/about-codeql-queries/)" in the {% data variables.product.prodname_codeql %} documentation.
4747

4848
You can run additional queries as part of your code scanning analysis.
4949

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ topics:
1717
- Advanced Security
1818
- Code scanning
1919
---
20-
<!--For this article in earlier GHES versions, see /content/github/finding-security-vulnerabilities-and-errors-in-your-code-->
20+
2121

2222
{% data reusables.code-scanning.beta %}
2323
{% data reusables.code-scanning.enterprise-enable-code-scanning %}

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ topics:
2424
- Python
2525
shortTitle: Configure code scanning
2626
---
27-
<!--For this article in earlier GHES versions, see /content/github/finding-security-vulnerabilities-and-errors-in-your-code-->
27+
2828

2929
{% data reusables.code-scanning.beta %}
3030
{% data reusables.code-scanning.enterprise-enable-code-scanning-actions %}
@@ -89,7 +89,7 @@ If you scan pull requests, then the results appear as alerts in a pull request c
8989
{% ifversion fpt or ghes > 3.1 or ghae or ghec %}
9090
### Defining the severities causing pull request check failure
9191

92-
By default, only alerts with the severity level of `Error`{% ifversion fpt or ghes > 3.1 or ghae or ghec %} or security severity level of `Critical` or `High`{% endif %} will cause a pull request check failure, and a check will still succeed with alerts of lower severities. You can change the levels of alert severities{% ifversion fpt or ghes > 3.1 or ghae or ghec %} and of security severities{% endif %} that will cause a pull request check failure in your repository settings. For more information about severity levels, see "[Managing code scanning alerts for your repository](/code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/managing-code-scanning-alerts-for-your-repository#about-alerts-details)."
92+
By default, only alerts with the severity level of `Error`{% ifversion fpt or ghes > 3.1 or ghae or ghec %} or security severity level of `Critical` or `High`{% endif %} will cause a pull request check failure, and a check will still succeed with alerts of lower severities. You can change the levels of alert severities{% ifversion fpt or ghes > 3.1 or ghae or ghec %} and of security severities{% endif %} that will cause a pull request check failure in your repository settings. For more information about severity levels, see "[About code scanning alerts](/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/about-code-scanning-alerts#about-alert-details)."
9393

9494
{% data reusables.repositories.navigate-to-repo %}
9595
{% data reusables.repositories.sidebar-settings %}
@@ -351,7 +351,7 @@ To add one or more queries, add a `with: queries:` entry within the `uses: githu
351351

352352
You can also specify query suites in the value of `queries`. Query suites are collections of queries, usually grouped by purpose or language.
353353

354-
{% data reusables.code-scanning.codeql-query-suites %}
354+
{% data reusables.code-scanning.codeql-query-suites-explanation %}
355355

356356
{% if codeql-packs %}
357357
### Working with custom configuration files

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ topics:
2626
- C#
2727
- Java
2828
---
29-
<!--For this article in earlier GHES versions, see /content/github/finding-security-vulnerabilities-and-errors-in-your-code-->
29+
3030

3131
{% data reusables.code-scanning.beta %}
3232
{% data reusables.code-scanning.enterprise-enable-code-scanning-actions %}

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ topics:
1616
- Code scanning
1717
children:
1818
- /about-code-scanning
19+
- /about-code-scanning-alerts
1920
- /triaging-code-scanning-alerts-in-pull-requests
2021
- /setting-up-code-scanning-for-a-repository
2122
- /managing-code-scanning-alerts-for-your-repository
@@ -28,4 +29,4 @@ children:
2829
- /running-codeql-code-scanning-in-a-container
2930
- /viewing-code-scanning-logs
3031
---
31-
<!--For this article in earlier GHES versions, see /content/github/finding-security-vulnerabilities-and-errors-in-your-code-->
32+

0 commit comments

Comments
 (0)