Skip to content

Commit 8b64b81

Browse files
authored
Apply suggestions from code review
1 parent 33d859e commit 8b64b81

5 files changed

+40
-67
lines changed

docs/codeql/codeql-cli/about-codeql-packs.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ CodeQL packs are used to create, share, depend on, and run CodeQL queries and li
1313

1414
There are two types of CodeQL packs: query packs and library packs.
1515

16-
* Query packs are designed to be run. They are bundled with all transitive dependencies. Also included in the tarball is a compilation cache which is used to ensure the packs' efficient execution.
17-
* Library packs are designed to be used by query packs (or other library packs) and do not contain queries themselves. The libraries are not compiled and there is no compilation cache included in the final pack.
16+
* Query packs are designed to be run. When a query pack is published, the bundle includes all the transitive dependencies and a compilation cache. This ensures consistent and efficient execution of the queries in the pack.
17+
* Library packs are designed to be used by query packs (or other library packs) and do not contain queries themselves. The libraries are not compiled and there is no compilation cache included when the pack is published.
1818

1919
You can use the CodeQL package manger in the CodeQL CLI to create CodeQL packs, add dependencies to packs, and install or update dependencies. For more information, see ":ref:`Creating and working with CodeQL packs <creating-and-working-with-codeql-packs>`." You can also publish and download CodeQL packs using the CodeQL package manager. For more information, see ":doc:`Publishing and using CodeQL packs <publishing-and-using-codeql-packs>`."
2020

@@ -31,11 +31,11 @@ files and directories within the pack should be logically organized. For example
3131
About ``qlpack.yml`` files
3232
--------------------------
3333

34-
When executing query-related commands, CodeQL first looks in the package cache for CodeQL packs which have already been downloaded. If a suitable pack cannot be found, then CodeQL scans siblings of the installation directory (and their subdirectories) for ``qlpack.yml`` files. The metadata in the file tells
35-
CodeQL how to compile queries, what libraries the pack depends on, and where to
34+
When executing query-related commands, CodeQL first looks in the package cache for CodeQL packs which have already been downloaded. If a suitable pack cannot be found, then CodeQL scans siblings of the installation directory (and their subdirectories) for ``qlpack.yml`` files. The metadata in each `qlpack.yml`` file tells
35+
CodeQL how to compile any queries in the pack, what libraries the pack depends on, and where to
3636
find query suite definitions.
3737

38-
The content of the CodeQL pack (queries and libraries used in CodeQL analysis) is
38+
The contents of the CodeQL pack (queries or libraries used in CodeQL analysis) is
3939
included in the same directory as ``qlpack.yml``, or its subdirectories.
4040

4141
The location of ``qlpack.yml`` defines the library path for the content
@@ -61,15 +61,15 @@ The following properties are supported in ``qlpack.yml`` files.
6161
* - ``name``
6262
- ``octo-org/security-queries``
6363
- All packs
64-
- The scope, where the CodeQL pack is published, and the name of the pack defined using alphanumeric characters, hyphens, and periods. It must be unique as CodeQL cannot differentiate between CodeQL packs with identical names. Name components cannot start or end with a hyphen. Additionally, a period is not allowed in pack names at all. Use the pack name to specify queries to run using ``database analyze`` and to define dependencies between QL packs (see examples below).
64+
- The scope, where the CodeQL pack is published, and the name of the pack defined using alphanumeric characters and hyphens. It must be unique as CodeQL cannot differentiate between CodeQL packs with identical names. Name components cannot start or end with a hyphen. Additionally, a period is not allowed in pack names at all. Use the pack name to specify queries to run using ``database analyze`` and to define dependencies between QL packs (see examples below).
6565
* - ``version``
6666
- ``0.0.0``
6767
- All packs
6868
- A version number for this CodeQL pack. This must be a valid semantic version that meets the `SemVer v2.0.0 specification <https://semver.org/spec/v2.0.0.html>`__.
6969
* - ``dependencies``
7070
- ``codeql/javascript-all: 1.2.3``
7171
- Optional
72-
- The names of any CodeQL packs that this pack depends on, as a sequence. This gives the pack access to any libraries, database schema, and query suites defined in the dependency.
72+
- The names of any CodeQL packs that this pack depends on, as a sequence. This gives the pack access to any libraries, database schema, and query suites defined in the dependency. Optionally a version for the dependency is specified.
7373
* - ``suites``
7474
- ``octo-org-query-suites``
7575
- Optional
@@ -84,7 +84,7 @@ The following properties are supported in ``qlpack.yml`` files.
8484
- The path to a directory within the pack that contains tests, defined relative to the pack directory. Use ``.`` to specify the whole pack. Any queries in this directory are run as tests when ``test run`` is run with the ``--strict-test-discovery`` option. These queries are ignored by query suite definitions that use ``queries`` or ``qlpack`` instructions to ask for all queries in a particular pack.
8585
* - ``dbscheme``
8686
- ``semmlecode.python.dbscheme``
87-
- Core language pack only
87+
- Core language packs only
8888
- The path to the :ref:`database schema <codeql-database-schema>` for all libraries and queries written for this CodeQL language (see example below).
8989
* - ``upgrades``
9090
- ``.``

docs/codeql/codeql-cli/analyzing-databases-with-the-codeql-cli.rst

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ Running a CodeQL pack
115115

116116
Note
117117

118-
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only in GitHub Packages - the GitHub Container Registry (GHCR). You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
118+
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only using GitHub Packages - the GitHub Container registry. You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
119119

120-
To run an existing CodeQl pack from GitHub Packages - the GitHub Container Registry (GHCR), you need to download it first:
120+
To run an existing CodeQL query pack from the GitHub Container registry, you need to download it first::
121121

122122
codeql pack download microsoft/[email protected]
123123

124-
Afterwards, you can run the pack on a specific database:
124+
Afterwards, you can run the pack on a specific database::
125125

126126
codeql database analyze <database> microsoft/[email protected] <scope>/<other-pack> --format=sarifv2.1.0 --output=query-results.sarif
127127

@@ -137,13 +137,13 @@ you could use the following command from the directory containing your database:
137137
codeql database analyze <cpp-database> cpp-code-scanning.qls --format=sarifv2.1.0 --output=cpp-results.sarif
138138

139139
The analysis generates a file in the v2.1.0 SARIF format that is supported by all versions of GitHub.
140-
This file can be uploaded to GitHub executing ``codeql github upload-results`` or the code scanning API.
140+
This file can be uploaded to GitHub by executing ``codeql github upload-results`` or the code scanning API.
141141
For more information, see `Analyzing a CodeQL database <https://docs.github.com/en/code-security/secure-coding/configuring-codeql-cli-in-your-ci-system#analyzing-a-codeql-database>`__
142142
or `Code scanning API <https://docs.github.com/en/rest/reference/code-scanning>`__ in the GitHub documentation.
143143

144144
CodeQL query suites are ``.qls`` files that use directives to select queries to run
145145
based on certain metadata properties. The standard QL packs have metadata that specify
146-
the location of the query suites, so the CodeQL CLI knows where to find these
146+
the location of the query suites used by code scanning, so the CodeQL CLI knows where to find these
147147
suite files automatically, and you don't have to specify the full path on the command line.
148148
For more information, see ":ref:`About QL packs <standard-ql-packs>`."
149149

@@ -157,7 +157,7 @@ and at the following path in the CodeQL for Go repository::
157157
ql/src/codeql-suites/go-code-scanning.qls
158158

159159
The repository also includes the query suites used by `LGTM.com <https://lgtm.com>`__.
160-
These are stored alongside the query suites with names of the form: ``<language>-lgtm.qls``.
160+
These are stored alongside the query suites for code scanning with names of the form: ``<language>-lgtm.qls``.
161161

162162
For information about creating custom query suites, see ":doc:`Creating
163163
CodeQL query suites <creating-codeql-query-suites>`."
@@ -169,46 +169,18 @@ When you create a CodeQL database, the extractor stores diagnostic data in the d
169169

170170
If the analysis found fewer results for standard queries than you expected, review the results of the diagnostic and summary queries to check whether the CodeQL database is likely to be a good representation of the codebase that you want to analyze.
171171

172-
Integrating a CodeQL pack into a Code Scanning workflow
172+
Integrating a CodeQL pack into a code scanning workflow in GitHub
173173
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174174

175175
.. pull-quote::
176176

177177
Note
178178

179-
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only in GitHub Packages - the GitHub Container Registry (GHCR). You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
179+
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only using GitHub Packages - the GitHub Container registry. You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
180180

181-
Using packs inside your Code Scanning setup allows selecting query packs from various sources.
181+
You can use CodeQL query packs in your Code Scanning setup. This allows you to select query packs published by various sources and use them to analyze your code.
182+
For more information, see "`Using CodeQL query packs in the CodeQL action <https://docs.github.com/en/code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-codeql-query-packs/>`_" or "`Downloading and using CodeQL query packs in your CI system <https://docs.github.com/en/code-security/secure-coding/using-codeql-code-scanning-with-your-existing-ci-system/configuring-codeql-cli-in-your-ci-system#downloading-and-using-codeql-query-packs>`_."
182183

183-
In the CodeQL configuration file, the section called ``packs`` holds a list of CodeQL package references. Each package listed there will be downloaded by the action and the its default suite will be run.
184-
185-
queries:
186-
- queries/query1.ql
187-
- queries/suite1.qls
188-
packs:
189-
- codeql/pack1@~1.2.3 # latest version compatible with 1.2.3
190-
- codeql/pack2 # latest version
191-
192-
For multi-language runs, you can specify a nested map of packs:
193-
194-
packs:
195-
javascript:
196-
- codeql/js-pack1@~1.2.3
197-
- codeql/js-pack2
198-
java:
199-
- codeql/java-pack1@~1.2.3
200-
- codeql/java-pack2
201-
202-
In the CodeQL workflow file, you can add ``packs`` as input for the ``init`` action by using a comma-separated list of CodeQL packages and optional versions.
203-
204-
.. code-block:: none
205-
206-
uses: github/codeql-action@v1
207-
with:
208-
packs: codeql/pack1@~1.2.3, +codeql/pack2
209-
210-
This format does not support multi-language analyses.
211-
You can prefix a package reference with a plus sign, resulting in the input being combined with the config file. Without it, the input overwrites the config file.
212184

213185
Running all queries in a directory
214186
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/codeql/codeql-cli/creating-and-working-with-codeql-packs.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ You can use CodeQL packs to create, share, depend on, and run CodeQL queries and
99

1010
Note
1111

12-
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only in the GitHub Package Registry (GHPR). You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
12+
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only using GitHub Packages - the GitHub Container registry. You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
1313

1414
About CodeQL packs and the CodeQL CLI package manager
1515
-----------------------------------------------------
1616

17-
With CodeQL packs and the CodeQL CLI package manager, you can publish your custom queries and integrate them into your CodeQL code scanning workflow to run and analyze your codebase.
17+
With CodeQL packs and the CodeQL CLI package manager, you can publish your custom queries and integrate them into your codebase analysis.
1818

1919
There are two types of CodeQL packs: query packs and library packs.
2020

21-
* Query packs are designed to be run. The query packs are bundled with all transitive dependencies and a compilation cache is included in the tarball.
22-
* Library packs are designed to be used by query packs (or other library packs) and do not contain queries themselves. The libraries are not compiled and there is no compilation cache included in the final pack.
21+
* Query packs are designed to be run. When a query pack is published, the bundle includes all the transitive dependencies and a compilation cache. This ensures consistent and efficient execution of the queries in the pack.
22+
* Library packs are designed to be used by query packs (or other library packs) and do not contain queries themselves. The libraries are not compiled and there is no compilation cache included when the pack is published.
2323

2424
You can use the CodeQL package manger in the CodeQL CLI to create CodeQL packs, add dependencies to packs, and install or update dependencies. You can also publish and download CodeQL packs using the CodeQL package manager. For more information, see ":doc:`Publishing and using CodeQL packs <publishing-and-using-codeql-packs>`."
2525

26-
Running ``codeql pack init``
26+
Creating a CodeQL pack
2727
----------------------------
28-
You can create CodeQL packs are by running the following command from the checkout root of your project:
28+
You can create a CodeQL pack by running the following command from the checkout root of your project:
2929

3030
::
3131

@@ -40,10 +40,12 @@ The ``codeql pack init`` command creates the directory structure and configurati
4040

4141
Modifying an existing QL pack to create a CodeQL pack
4242
-----------------------------------------------------
43-
If you already have a ``qlpack.yml`` file, you can edit it manually to be a CodeQL pack.
43+
If you already have a ``qlpack.yml`` file, you can edit it manually to convert it into a CodeQL pack.
4444

45-
#. Edit the name so that it matches the format ``<scope>/<name>``, where ``<scope>`` is the name of the GitHub organization that you will publish to.
46-
#. In the ``qlpack.yml`` file, include a version property with a semver identifier, as well as an optional dependencies block.
45+
#. Edit the ``name`` property so that it matches the format ``<scope>/<name>``, where ``<scope>`` is the name of the GitHub organization that you will publish to.
46+
#. In the ``qlpack.yml`` file, include a ``version`` property with a semver identifier, as well as an optional ``dependencies`` block.
47+
48+
For more information about the properties, see ":ref:`About CodeQL packs <about-codeql-packs>`."
4749

4850
Adding and installing dependencies to a CodeQL pack
4951
---------------------------------------------------
@@ -69,4 +71,4 @@ This command downloads all dependencies to the shared cache on the local disk.
6971

7072
Note
7173

72-
Running the ``codeql pack add`` and ``codeql pack install`` commands will generate or update the ``qlpack.lock.yml`` file. This file should be checked-in to version control. ``qlpack.lock.yml`` contains the precise version numbers used by the pack.
74+
Running the ``codeql pack add`` and ``codeql pack install`` commands will generate or update the ``qlpack.lock.yml`` file. This file should be checked-in to version control. The ``qlpack.lock.yml`` file contains the precise version numbers used by the pack.

docs/codeql/codeql-cli/publishing-and-using-codeql-packs.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can publish your own CodeQL packs and use packs published by other people.
99

1010
Note
1111

12-
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only in GitHub Packages - the GitHub Container Registry (GHCR). You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
12+
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only using GitHub Packages - the GitHub Container registry. You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
1313

1414
Configuring the ``qlpack.yml`` file before publishing
1515
-----------------------------------------------------
@@ -20,27 +20,27 @@ You can check and modify the configuration details of your CodeQL pack prior to
2020
2121
library: # set to true if the pack is a library. Set to false or omit for a query pack
2222
name: <scope>/<pack>
23-
version: x.x.x
24-
description:
23+
version: <x.x.x>
24+
description: <Description to publish with the package>
2525
default-suite: # a query-suite file that has been inlined
2626
- query:
2727
default-suite-file: default-queries.qls # a pointer to a query-suite in this pack
28-
license:
28+
license: # optional, the license under which the pack is published
2929
dependencies:
3030
3131
- ``name:`` must follow the <scope>/<pack> format, where <scope> is the GitHub organization that you will publish to and <pack> is the name for the pack.
32-
- Only one of ``default-suite`` or ``default-suite-file`` is allowed. Both options define a default query suite to be run.
32+
- Only one of ``default-suite`` or ``default-suite-file`` is allowed. Both options define a default query suite to be run, the first by specifying queries directly in the `qlpack.yml` file and the second by specifying a query suite in the pack.
3333

3434
Running ``codeql pack publish``
3535
-------------------------------
3636

37-
When you are ready to upload a pack to a shared repository, you can run the following command in the root of the pack directory:
37+
When you are ready to publish a pack to the GitHub Container registry, you can run the following command in the root of the pack directory:
3838

3939
::
4040

4141
codeql pack publish
4242

43-
The published package will appear in the packages section of your GitHub organization.
43+
The published package will be displayed in the packages section of GitHub organization specified by the scope in the ``qlpack.yml`` file.
4444

4545
Running ``codeql pack download <scope>/<pack>``
4646
-----------------------------------------------

docs/codeql/codeql-cli/using-custom-queries-with-the-codeql-cli.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ Packaging custom QL queries
5656

5757
Note
5858

59-
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packages are available only in GitHub Packages - the GitHub Container Registry (GHCR). You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
59+
The CodeQL package manager is currently in beta and subject to change. During the beta, CodeQL packs are available only using GitHub Packages - the GitHub Container registry. You must use version 2.5.8 or later of the CodeQL CLI to use the CodeQL package manager.
6060

6161

62-
When writing your own queries, you can either just save them in a custom QL pack
63-
directory or subsequently include the pack in a CodeQL package which you can
64-
then upload to GitHub Packages - the GitHub Container Registry (GHCR).
62+
When you write your own queries, you should save them in a custom QL pack
63+
directory. When you are ready to share your queries with other users, you can publish the pack as a CodeQL pack to GitHub Packages - the GitHub Container registry.
6564

6665
QL packs organize the files used in CodeQL analysis and can store queries,
6766
library files, query suites, and important metadata. Their root directory must

0 commit comments

Comments
 (0)