Skip to content

Commit a748bf7

Browse files
committed
Line edits
1 parent 08abd69 commit a748bf7

11 files changed

+40
-38
lines changed

learn-pr/github/code-scanning-with-github-codeql/includes/1-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Code scanning using CodeQL provides an extensible method to automate vulnerability scanning across your organizations GitHub repositories. It's important to understand how the tool works and what its features are so as to best implement code scanning to meet your code's security needs. You'll also need to understand the various configuration options and how to implement and maintain a code-scanning pipeline in order to configure and deploy code scanning correctly.
1+
Code scanning using CodeQL provides an extensible method to automate vulnerability scanning across your organization's GitHub repositories. It's important to understand how the tool works and what its features are so as to best implement code scanning to meet your code's security needs. You'll also need to understand the various configuration options and how to implement and maintain a code-scanning pipeline in order to configure and deploy code scanning correctly.
22

33
In this module, we review the CodeQL static-analysis tool and how the code-scanning feature in GitHub uses it to automate vulnerability scanning. We also learn how to customize a code scanning workflow that uses CodeQL, how to include additional queries, and how to adapt your workflow to repositories that have multiple languages.
44

learn-pr/github/code-scanning-with-github-codeql/includes/11-exercise-configure-language-matrix.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ This exercise is a challenge based on content covered in this module. It may tak
1717
When you've finished the exercise in GitHub, return here for:
1818
1919
> [!div class="checklist"]
20-
> * A summary of what you've learned
21-
> * A badge for completing this module
20+
> - A summary of what you've learned
21+
> - A badge for completing this module
2222
2323
2424
> [!div class="nextstepaction"]

learn-pr/github/code-scanning-with-github-codeql/includes/12-summary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
In this module, we learned:
22

3-
* Code scanning with CodeQL can be customized using the advanced setup workflow file that specifies the location of queries, which languages to analyze, and whether they should be built with autobuild, or manual build steps.
3+
* Code scanning with CodeQL can be customized using the advanced setup workflow file that specifies the location of queries, which languages to analyze, and whether they should be built with autobuild or manual build steps.
44
* GitHub supports integration of third party scanning and alerting tools in the code scanning process.
55
* CodeQL has a CLI that allows you to create and analyze databases offline and then upload the results to GitHub using a SARIF file.
66

7-
Without using GitHub code scanning with CodeQL, it would be difficult to automate both the scanning of your code, and generating pull requests to fix the vulnerable code. In addition, CodeQL provides an extensive, growing library of queries in multiple languages that help you create more secure code with little engineering effort.
7+
Without using GitHub code scanning with CodeQL, it would be difficult to automate both the scanning of your code and generating pull requests to fix the vulnerable code. In addition, CodeQL provides an extensive, growing library of queries in multiple languages that help you create more secure code with little engineering effort.
88

99
## References
1010

learn-pr/github/code-scanning-with-github-codeql/includes/2-what-is-codeql.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ In this unit, you'll learn about the CodeQL static analysis tool and how it uses
66

77
## Variant analysis
88

9-
Variant analysis is the process of using a known security vulnerability as a seed to find similar problems in your code. Its a technique that security engineers use to identify potential vulnerabilities and ensure these threats are properly fixed across multiple codebases.
9+
Variant analysis is the process of using a known security vulnerability as a seed to find similar problems in your code. It's a technique that security engineers use to identify potential vulnerabilities and ensure these threats are properly fixed across multiple codebases.
1010

1111
Querying code using CodeQL is the most efficient way to perform variant analysis. You can use the standard CodeQL queries to identify seed vulnerabilities, or find new vulnerabilities by writing your own custom CodeQL queries. Then, you can develop or iterate over the query to automatically find logical variants of the same bug that could be missed using traditional manual techniques.
1212

1313
## CodeQL databases
1414

15-
CodeQL databases contain queryable data extracted from a codebase, for a single language at a particular point in time. The database contains a full, hierarchical representation of the code, including a representation of the abstract syntax tree, the data-flow graph, and the control-flow graph.
15+
CodeQL databases contain queryable data extracted from a codebase for a single language at a particular point in time. The database contains a full, hierarchical representation of the code, including a representation of the abstract syntax tree, the data-flow graph, and the control-flow graph.
1616

1717
Each language has its own unique database schema that defines the relations used to create a database. The schema provides an interface between the initial lexical analysis performed during the extraction process and the actual complex analysis of the CodeQL query evaluator. The schema specifies, for instance, that there's a table for every language construct.
1818

@@ -27,7 +27,7 @@ The CodeQL library defines classes to provide a layer of abstraction over each o
2727

2828
## Query suites
2929

30-
CodeQL query suites provide a way of selecting queries, based on their filename, location on disk or in a QL pack, or metadata properties. Create query suites for the queries that you want to frequently use in your CodeQL analyses.
30+
CodeQL query suites provide a way of selecting queries based on their filename, metadata properties, or location on disk or in a QL pack. Create query suites for the queries that you want to frequently use in your CodeQL analyses.
3131

3232
Query suites allow you to pass multiple queries to CodeQL without having to specify the path to each query file individually. Query suite definitions are stored in YAML files with the extension `.qls`. A suite definition is a sequence of instructions where each instruction is a YAML mapping with (usually) a single key. The instructions are executed in the order they appear in the query suite definition. After all the instructions in the suite definition have been executed, the result is a set of selected queries.
3333

@@ -36,9 +36,9 @@ Query suites allow you to pass multiple queries to CodeQL without having to spec
3636
There are two built-in query suites for CodeQL:
3737

3838
* `default`: These are the queries run by default in CodeQL code scanning on GitHub, available with the default setup of code scanning. The queries in this query suite are highly precise and return few false positive code scanning results. Relative to the `security-extended` query suite, the default suite returns fewer low-confidence code scanning results.
39-
* `security-extended`: This suite contains all of the queries from the `default` suite, plus extra security queries with slightly lower precision and severity. It is available with the default setup of code scanning and is listed as the "Extended" option in the query suites dropdown. Relative to the `default` query suite, this suite may return a greater number of false positive code scanning results.
39+
* `security-extended`: This suite contains all of the queries from the `default` suite, plus extra security queries with slightly lower precision and severity. It's available with the default setup of code scanning and is listed as the "Extended" option in the query suites dropdown. Relative to the `default` query suite, this suite may return a greater number of false positive code scanning results.
4040

41-
The default setup of code scanning will use the `default` query suite. This can be changed by selecting the overflow icon to view the CodeQL configuration and then selecting to the edit button. Under "Scan settings" you may choose one of the above two options as the query suite.
41+
The default setup of code scanning will use the `default` query suite. This can be changed by selecting the overflow icon to view the CodeQL configuration, and then selecting to the edit button. Under "Scan settings," you may choose one of the above two options as the query suite.
4242

4343
## CodeQL packs
4444

@@ -52,11 +52,11 @@ There are three types of CodeQL packs: query packs, library packs, and model pac
5252

5353
### CodeQL pack structure
5454

55-
The CodeQL CLI can be used to being developing and publishing a pack using the `pack init` command. This command will create the directory structure and files required, including the main file called `qlpack.yml` in its root directory. The metadata in each `qlpack.yml` file tells CodeQL how to compile any queries in the pack, what libraries the pack depends on, and where to find query suite definitions.
55+
The CodeQL CLI can be used to develop and publish a pack using the `pack init` command. This command will create the directory structure and files required, including the main file called `qlpack.yml` in its root directory. The metadata in each `qlpack.yml` file tells CodeQL how to compile any queries in the pack, what libraries the pack depends on, and where to find query suite definitions.
5656

5757
The contents of the CodeQL pack (queries or libraries used in CodeQL analysis) is included in the same directory as `qlpack.yml`, or its subdirectories.
5858

59-
The directory containing the qlpack.yml file serves as the root directory for the content of the CodeQL pack. That is, for all `.ql` and `.qll`s files in the pack, CodeQL will resolve all import statements relative to the directory containing the qlpack.yml file at the packs root.
59+
The directory containing the qlpack.yml file serves as the root directory for the content of the CodeQL pack. That is, for all `.ql` and `.qll`s files in the pack, CodeQL will resolve all import statements relative to the directory containing the qlpack.yml file at the pack's root.
6060

6161
Here's an example `qlpack.yml` file:
6262

learn-pr/github/code-scanning-with-github-codeql/includes/3-how-does-codeql-analyze-code.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Implementing code scanning with CodeQL requires an understanding of how the tool
22

33
CodeQL analysis consists of three steps:
44

5-
1. Preparing the code, by creating a CodeQL database.
5+
1. Preparing the code by creating a CodeQL database.
66
2. Running CodeQL queries against the database.
77
3. Interpreting the query results.
88

@@ -22,16 +22,16 @@ After extraction, all the data required for analysis (relational data, copied so
2222

2323
## Query execution
2424

25-
After youve created a CodeQL database, one or more queries are executed against it. CodeQL queries are written in a specially designed object-oriented query language called QL.
25+
After you've created a CodeQL database, one or more queries are executed against it. CodeQL queries are written in a specially designed object-oriented query language called QL.
2626

27-
You can run the queries checked out from the CodeQL repo (or custom queries that youve written yourself) using the CodeQL for VS Code extension or the CodeQL CLI.
27+
You can run the queries checked out from the CodeQL repo (or custom queries that you've written yourself) using the CodeQL for VS Code extension or the CodeQL CLI.
2828

2929
## Query results
3030

3131
The final step converts results produced during query execution into a form that's more meaningful in the context of the source code, meaning that the results are interpreted in a way that highlights the potential issue that the queries are designed to find.
3232

3333
:::image type="content" source="../media/codeql-query-results.png" alt-text="Screenshot of CodeQL query results.":::
3434

35-
Queries contain metadata properties that indicate how the results should be interpreted. For instance, some queries display a simple message at a single location in the code. Others display a series of locations that represent steps along a data-flow or control-flow path, along with a message explaining the significance of the result. Queries that dont have metadata are not interpreted; their results are output as a table and not displayed in the source code.
35+
Queries contain metadata properties that indicate how the results should be interpreted. For instance, some queries display a simple message at a single location in the code. Others display a series of locations that represent steps along a data-flow or control-flow path, along with a message explaining the significance of the result. Queries that don't have metadata are not interpreted; their results are output as a table and not displayed in the source code.
3636

3737
Following interpretation, results are output for code review and triaging. In CodeQL for Visual Studio Code, interpreted query results are automatically displayed in the source code. You can output results generated by the CodeQL CLI into a number of different formats for use with different tools.

learn-pr/github/code-scanning-with-github-codeql/includes/4-what-is-ql.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ In this unit, you'll learn about the basic features of the QL programming langua
1212

1313
## The QL syntax
1414

15-
The syntax of QL is similar to SQL, but the semantics of QL are based on Datalog, a declarative logic programming language often used as a query language. This makes QL primarily a logic language, and all operations in QL are logical operations. Furthermore, QL inherits recursive predicates from Datalog and adds support for aggregates, making even complex queries concise and simple. For example, consider a database containing parent-child relationships for people. If you want to find the number of descendants of a person, typically you would:
15+
The syntax of QL is similar to SQL. However, the semantics of QL are based on Datalog, a declarative logic programming language often used as a query language. This makes QL primarily a logic language, and all operations in QL are logical operations. Furthermore, QL inherits recursive predicates from Datalog and adds support for aggregates, making even complex queries concise and simple. For example, consider a database containing parent-child relationships for people. If you want to find the number of descendants of a person, typically you'd:
1616

1717
1. Find a descendant of the given person; that is, a child or a descendant of a child.
1818
2. Count the number of descendants found using the previous step.
@@ -32,14 +32,14 @@ int getNumberOfDescendants(Person p) {
3232

3333
## Object orientation
3434

35-
Object orientation is an important feature of QL. The benefits of object orientation are well-known: it increases modularity, enables information hiding, and allows code reuse. QL offers all these benefits without compromising on its logical foundation. This is achieved by defining a simple object model where classes are modeled as predicates and inheritance as implication. The libraries made available for all supported languages make extensive use of classes and inheritance.
35+
Object orientation is an important feature of QL. The benefits of object orientation are well-known. It increases modularity, enables information hiding, and allows code reuse. QL offers all these benefits without compromising on its logical foundation. This is achieved by defining a simple object model where classes are modeled as predicates and inheritance as implication. The libraries made available for all supported languages make extensive use of classes and inheritance.
3636

3737
## QL and general purpose programming languages
3838

3939
Here are a few prominent conceptual and functional differences between general purpose programming languages and QL:
4040

4141
* QL does not have any imperative features such as assignments to variables or file system operations.
42-
* QL operates on sets of tuples and a query can be viewed as a complex sequence of set operations that defines the result of the query.
43-
* QLs set-based semantics makes it very natural to process collections of values without having to worry about efficiently storing, indexing and traversing them.
42+
* QL operates on sets of tuples, and a query can be viewed as a complex sequence of set operations that defines the result of the query.
43+
* QL's set-based semantics makes it very natural to process collections of values without having to worry about efficiently storing, indexing, and traversing them.
4444

4545
In object-oriented programming languages, instantiating a class involves creating an object by allocating physical memory to hold the state of that instance of the class. In QL, classes are just logical properties describing sets of already existing values.

learn-pr/github/code-scanning-with-github-codeql/includes/5-code-scanning-codeql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Depending on which tool you want to use for analysis and how you want to generat
44
* Use advanced setup to add the CodeQL workflow to your repository. This generates a customizable workflow file which uses the github/codeql-action to run the CodeQL CLI. For more information, see "Configuring advanced setup for code scanning."
55
* Run the CodeQL CLI directly in an external CI system and upload the results to GitHub. For more information, see "Using code scanning with your existing CI system."<sup>[2]</sup>
66

7-
Previously, we learned about getting started with the default setup and configurations. Now you'll learn how to set up code scanning with the advanced setup, as well as how to perform bulk setup of a code scanning workflow for multiple repositories.
7+
Previously, we learned about getting started with the default setup and configurations. Now, you'll learn how to set up code scanning with the advanced setup, as well as how to perform bulk setup of a code scanning workflow for multiple repositories.
88

99
## Code scanning with GitHub Actions and CodeQL
1010

learn-pr/github/code-scanning-with-github-codeql/includes/6-customize-your-scanning-workflow-with-codeql.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Code scanning workflows that use CodeQL have various configuration options you c
22

33
When you use CodeQL to scan code, the CodeQL analysis engine generates a database from the code and runs queries on it. CodeQL analysis uses a default set of queries, but you can specify more queries to run in addition to the default queries.
44

5-
You can run extra queries if they're part of a CodeQL pack (beta) published to the GitHub Container registry or a QL pack stored in a repository.
5+
You can run extra queries if they're part of a CodeQL pack (beta) published to the GitHub Container registry, or a QL pack stored in a repository.
66

77
There are two options for specifying which queries you want to run with CodeQL code scanning:
88

@@ -30,10 +30,10 @@ We don't recommend referencing query suites directly from the `github/codeql` re
3030
To add one or more CodeQL query packs (beta), add a `with: packs:` entry within the `uses: github/codeql-action/init@v1` section of the workflow. Within packs, you can specify one or more packages to use and, optionally, which version to download. Where you don't specify a version, the latest version is downloaded. If you want to use packages that aren't publicly available, you need to set the `GITHUB_TOKEN` environment variable to a secret that has access to the packages.
3131

3232
In the following example, scope is the organization or personal account that published the package. When the workflow runs, the three CodeQL query packs download from GitHub and the default queries or query suite for each pack run. In the below example, each of the packs in the list will download based on their specifications:
33-
* The latest version of `pack1` is downloaded and all default queries are run.
34-
* Version 1.2.3 of `pack2` is downloaded and all default queries are run.
35-
* The latest version of `pack3` that is compatible with version 3.2.1 is downloaded and all queries are run.
36-
* Version 4.5.6 of `pack4` is downloaded and only the queries found in path/to/queries are run.
33+
* The latest version of `pack1` is downloaded, and all default queries are run.
34+
* Version 1.2.3 of `pack2` is downloaded, and all default queries are run.
35+
* The latest version of `pack3` that is compatible with version 3.2.1 is downloaded, and all queries are run.
36+
* Version 4.5.6 of `pack4` is downloaded, and only the queries found in path/to/queries are run.
3737

3838
```yml
3939
- uses: github/codeql-action/init@v3

0 commit comments

Comments
 (0)