You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/github/codebase-representation-codeql/includes/2-how-prepare-database-codeql.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,3 @@
1
-
2
1
CodeQL treats code like data. You create a database by using queryable data that you extract from your codebase. Then you can run CodeQL queries on this database to identify security vulnerabilities, bugs, and other errors. You can write your own queries or run standard CodeQL queries written by GitHub researchers and community contributors.
3
2
4
3
In this unit, you learn how to create a database. This step is required before you can analyze your code. You need to create a CodeQL database that contains all the data necessary to run queries on your code.
Copy file name to clipboardExpand all lines: learn-pr/github/codebase-representation-codeql/includes/3-run-codeql-database.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Metadata information can include a description of the query, a unique ID, and th
36
36
37
37
GitHub has a recommended style guide for query metadata. You can find it in the [CodeQL documentation](https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md).
38
38
39
-
This is an example of metadata for one of the standard Java queries:
39
+
This example shows metadata for one of the standard Java queries:
@@ -46,9 +46,9 @@ CodeQL doesn't interpret queries that don't have metadata. It shows those result
46
46
47
47
QL is a declarative, object-oriented query language. It's optimized to enable efficient analysis of hierarchical data structures, and in particular, databases that represent software artifacts.
48
48
49
-
The syntax of QL is similar to SQL, but the semantics of QL are based on Datalog. Datalog is a declarative logic programming language that's often used as a query language. Because QL is primarily a logic language, all operations in QL are logical operations. QL also inherits recursive predicates from Datalog. QL adds support for aggregates to make even complex queries concise and simple.
49
+
The syntax of QL is similar to SQL, but the semantics of QL are based on Datalog. Datalog is a declarative logic programming language, which is often used as a query language. Because QL is primarily a logic language, all operations in QL are logical operations. QL also inherits recursive predicates from Datalog. QL adds support for aggregates to make even complex queries concise and simple.
50
50
51
-
The QL language consists of logical formulas. It uses common logical connectives such as `and`, `or`, and `not`, along with quantifiers such as `forall` and `exists`. Because QL inherits recursive predicates, you can also write complex recursive queries by using simple QL syntax and aggregates like `count`, `sum`, and `average`.
51
+
The QL language consists of logical formulas. It uses common logical connectives such as `and`, `or`, and `not`, along with quantifiers such as `forall` and `exists`. Because QL inherits recursive predicates, you can also write complex recursive queries by using basic QL syntax and aggregates like `count`, `sum`, and `average`.
52
52
53
53
For more information on the QL language, see the [CodeQL documentation](https://codeql.github.com/docs/ql-language-reference/about-the-ql-language/).
54
54
@@ -60,7 +60,7 @@ Creating path queries can help you visualize the flow of information through a c
60
60
61
61
The easiest way to start writing your own path query is to use one of the existing queries as a template. To get these queries for supported languages, see the [CodeQL documentation](https://codeql.github.com/codeql-query-help/).
62
62
63
-
Your path query requires certain metadata, query predicates, and `select` statement structures. Many of the built-in path queries in CodeQL follow a simple structure. The structure depends on how CodeQL models the language that you're analyzing.
63
+
Your path query requires certain metadata, query predicates, and `select` statement structures. Many of the built-in path queries in CodeQL follow a basic structure. The structure depends on how CodeQL models the language that you're analyzing.
64
64
65
65
Here's an example template for a path query:
66
66
@@ -91,7 +91,7 @@ In that template:
91
91
-`Flow` is the result of the data-flow computation based on `MyConfiguration`.
92
92
-`Flow::Pathgraph` is the resulting data-flow graph module that you need to import in order to include path explanations in the query.
93
93
-`source` and `sink` are nodes in the graph as defined in the configuration, and `Flow::PathNode` is their type.
94
-
-`DataFlow::Global<..>` is an invocation of data flow. You can use `TaintTracking::Global<..>` instead to include a default set of additional taint steps.
94
+
-`DataFlow::Global<..>` is an invocation of data flow. You can use `TaintTracking::Global<..>` instead to include a default set of taint steps.
95
95
96
96
### How to write a path query
97
97
@@ -105,9 +105,9 @@ Here's an example statement that imports the `pathgraph` module from the data-fl
105
105
106
106
`import DataFlow::PathGraph`
107
107
108
-
You can import many additional libraries included with CodeQL. You can also import libraries that are specifically designed to implement data-flow analysis in various common frameworks and environments.
108
+
You can import many other libraries included with CodeQL. You can also import libraries that are designed specifically to implement data-flow analysis in various common frameworks and environments.
109
109
110
-
The class `PathNode` is an example that's specifically designed to implement data-flow analysis. It's`Node` augmented with a call context (except for sinks), an access path, and a configuration. Only `PathNode` values that are reachable from a source are generated.
110
+
The class `PathNode` is designed to implement data-flow analysis. Its`Node` augmented with a call context (except for sinks), an access path, and a configuration. Only `PathNode` values that are reachable from a source are generated.
111
111
112
112
Here's an example of the import path:
113
113
@@ -117,7 +117,7 @@ You can optionally define a `nodes` query predicate, which specifies the nodes o
117
117
118
118
## Database analysis
119
119
120
-
When you use queries to analyze a CodeQL database, you receive meaningful results in the context of the source code. The results are styled as alerts or paths in SARIF or another interpreted format.
120
+
When you use queries to analyze a CodeQL database, you receive meaningful results in the context of the source code. The results are styled as alerts or paths in SARIF or another interpreted format.
121
121
122
122
Here's an example of a CodeQL database command that analyzes the database by running selected queries against it and interpreting the results:
123
123
@@ -154,7 +154,7 @@ You could potentially allow the CodeQL CLI to use the same token if CI servers a
154
154
155
155
For code scanning to display results from a non-Microsoft static analysis tool in your GitHub repository, your results must be stored in a SARIF file that supports a specific subset of the SARIF 2.1.0 JSON schema. You can upload the results by using the code-scanning API or the CodeQL CLI.
156
156
157
-
Each time you upload the results of a new code scan, CodeQL processes the results and adds alerts to the repository. To prevent duplicate alerts for the same problem, code scanning uses the SARIF `partialFingerprints` property to match results across various runs so that they appear only once in the latest run for the selected branch. This makes it possible to match alerts to the correct line of code when files are edited.
157
+
Each time you upload the results of a new code scan, CodeQL processes the results and adds alerts to the repository. To prevent duplicate alerts for the same problem, code scanning uses the SARIF `partialFingerprints` property to match results across various runs so that they appear only once in the latest run for the selected branch. Eliminating duplicates makes it possible to match alerts to the correct line of code when files are edited.
158
158
159
159
The rule ID for a result has to be the same across analyses. Fingerprint data is automatically included in SARIF files created through the CodeQL analysis workflow or the CodeQL runner.
Copy file name to clipboardExpand all lines: learn-pr/github/codebase-representation-codeql/includes/4-understand-results.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@ In previous units, you created a database and scanned the extracted file from yo
2
2
3
3
## View code-scanning results from CodeQL analysis
4
4
5
-
Interpreted query results are automatically displayed in the source code in the CodeQL extension for VS Code. Output results that the CodeQL CLI generates can be in many formats for use with various tools.
5
+
Interpreted query results are automatically displayed in the source code in the CodeQL extension for Visual Studio Code. Output results that the CodeQL CLI generates can be in many formats for use with various tools.
6
6
7
-
You can control how analysis results are displayed in source code by modifying a query's `select` statement. You can make the results clear and easy for other users to understand while developing the query. When you write your own queries in the query console or in the CodeQL extension for VS Code, there are no constraints on what can be selected.
7
+
You can control how analysis results are displayed in source code by modifying a query's `select` statement. You can make the results clear and easy for other users to understand while developing the query. When you write your own queries in the query console or in the CodeQL extension for Visual Studio Code, there are no constraints on what can be selected.
8
8
9
9
If you want to use a query to create alerts in GitHub code scanning or generate valid analysis results by using the CodeQL CLI, you need to make the `select` statement report results in the required format.
10
10
@@ -16,12 +16,12 @@ GitHub's default CodeQL analysis might include more properties for alerts than r
16
16
17
17
Each alert includes the following information:
18
18
19
-
- The problem with the code and the name of the tool that identified it
20
-
- The line of code that triggered the alert
21
-
-Properties of the alert, such as the severity
22
-
- The security severity
23
-
-When the problem was introduced
24
-
- The nature of the problem
19
+
- The problem with the code and the name of the tool that identified it.
20
+
- The line of code that triggered the alert.
21
+
-The properties of the alert, such as the severity.
22
+
- The security severity.
23
+
-The point when the problem was introduced.
24
+
- The nature of the problem.
25
25
26
26
Information also includes how to fix the problem when CodeQL analysis identifies an alert. Additionally, code scanning through CodeQL can detect data-flow problems in your code.
27
27
@@ -56,17 +56,17 @@ You have two ways to close an alert:
56
56
57
57
### Dismiss a code-scanning alert
58
58
59
-
Dismissing an alert is a way of closing an alert that you don't think needs to be fixed. One example is an error in code that's used only for testing. You might also dismiss an alert if the effort required to fix the error is greater than the potential benefit of improving the code.
59
+
Dismissing an alert is a way of closing an alert that you don't think needs to be fixed. For example, you might dismiss an alert for an error in code used only for testing. You might also dismiss an alert if the effort required to fix the error is greater than the potential benefit of improving the code.
60
60
61
61
You can dismiss alerts from code-scanning annotations in the code or from the summary list on the **Security** tab. To dismiss an alert from the list, select the **Dismiss alert** menu, select a reason for dismissal, and then select the **Dismiss alert** button.
62
62
63
63
:::image type="content" source="../media/code-scanning-alert-dismissal.gif" alt-text="Video that the dropdown menu and button for dismissing an alert." border="false":::
64
64
65
65
When you dismiss an alert:
66
66
67
-
-It's dismissed in all branches.
68
-
-It's removed from the number of current alerts for your project.
69
-
-It's moved to the **Closed** list in the summary of alerts. You can reopen it from here, if necessary.
67
+
-The alert is dismissed in all branches.
68
+
-The alert is removed from the number of current alerts for your project.
69
+
-The alert is moved to the **Closed** list in the summary of alerts. You can reopen it from here, if necessary.
70
70
- The reason why you closed the alert is recorded.
71
71
- The next time code scanning runs, the same code won't generate an alert.
72
72
@@ -83,7 +83,7 @@ You can delete alerts from the summary list on the **Security** tab.
83
83
84
84
When you delete an alert:
85
85
86
-
-It's deleted in all branches.
87
-
-It's removed from the number of current alerts for your project.
88
-
-It isn't added to the **Closed** list in the summary of alerts.
89
-
-If the code that generated the alert stays the same, and the same code-scanning tool runs again without any configuration changes, the alert appears again in your analysis results.
86
+
-The alert is deleted in all branches.
87
+
-The alert is removed from the number of current alerts for your project.
88
+
-The alert isn't added to the **Closed** list in the summary of alerts.
89
+
-The alert appears again in your analysis results, if the code that generated the alert stays the same, and the same code-scanning tool runs again without any configuration changes.
0 commit comments