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: docs/codeql/codeql-cli/about-codeql-packs.rst
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ CodeQL packs are used to create, share, depend on, and run CodeQL queries and li
13
13
14
14
There are two types of CodeQL packs: query packs and library packs.
15
15
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.
18
18
19
19
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>`."
20
20
@@ -31,11 +31,11 @@ files and directories within the pack should be logically organized. For example
31
31
About ``qlpack.yml`` files
32
32
--------------------------
33
33
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
36
36
find query suite definitions.
37
37
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
39
39
included in the same directory as ``qlpack.yml``, or its subdirectories.
40
40
41
41
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.
61
61
* - ``name``
62
62
- ``octo-org/security-queries``
63
63
- 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 charactersand 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).
65
65
* - ``version``
66
66
- ``0.0.0``
67
67
- All packs
68
68
- 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>`__.
69
69
* - ``dependencies``
70
70
- ``codeql/javascript-all: 1.2.3``
71
71
- 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.
73
73
* - ``suites``
74
74
- ``octo-org-query-suites``
75
75
- Optional
@@ -84,7 +84,7 @@ The following properties are supported in ``qlpack.yml`` files.
84
84
- 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.
85
85
* - ``dbscheme``
86
86
- ``semmlecode.python.dbscheme``
87
-
- Core language pack only
87
+
- Core language packs only
88
88
- The path to the :ref:`database schema <codeql-database-schema>` for all libraries and queries written for this CodeQL language (see example below).
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/analyzing-databases-with-the-codeql-cli.rst
+10-38Lines changed: 10 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,13 +115,13 @@ Running a CodeQL pack
115
115
116
116
Note
117
117
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.
119
119
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::
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.
141
141
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>`__
142
142
or `Code scanning API <https://docs.github.com/en/rest/reference/code-scanning>`__ in the GitHub documentation.
143
143
144
144
CodeQL query suites are ``.qls`` files that use directives to select queries to run
145
145
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
147
147
suite files automatically, and you don't have to specify the full path on the command line.
148
148
For more information, see ":ref:`About QL packs <standard-ql-packs>`."
149
149
@@ -157,7 +157,7 @@ and at the following path in the CodeQL for Go repository::
157
157
ql/src/codeql-suites/go-code-scanning.qls
158
158
159
159
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``.
161
161
162
162
For information about creating custom query suites, see ":doc:`Creating
@@ -169,46 +169,18 @@ When you create a CodeQL database, the extractor stores diagnostic data in the d
169
169
170
170
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.
171
171
172
-
Integrating a CodeQL pack into a Code Scanning workflow
172
+
Integrating a CodeQL pack into a code scanning workflow in GitHub
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.
180
180
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>`_."
182
183
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.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/creating-and-working-with-codeql-packs.rst
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,23 +9,23 @@ You can use CodeQL packs to create, share, depend on, and run CodeQL queries and
9
9
10
10
Note
11
11
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.
13
13
14
14
About CodeQL packs and the CodeQL CLI package manager
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.
18
18
19
19
There are two types of CodeQL packs: query packs and library packs.
20
20
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.
23
23
24
24
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>`."
25
25
26
-
Running ``codeql pack init``
26
+
Creating a CodeQL pack
27
27
----------------------------
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:
29
29
30
30
::
31
31
@@ -40,10 +40,12 @@ The ``codeql pack init`` command creates the directory structure and configurati
40
40
41
41
Modifying an existing QL pack to create a CodeQL pack
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.
44
44
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>`."
47
49
48
50
Adding and installing dependencies to a CodeQL pack
@@ -69,4 +71,4 @@ This command downloads all dependencies to the shared cache on the local disk.
69
71
70
72
Note
71
73
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.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/publishing-and-using-codeql-packs.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ You can publish your own CodeQL packs and use packs published by other people.
9
9
10
10
Note
11
11
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.
13
13
14
14
Configuring the ``qlpack.yml`` file before publishing
@@ -20,27 +20,27 @@ You can check and modify the configuration details of your CodeQL pack prior to
20
20
21
21
library: # set to true if the pack is a library. Set to false or omit for a query pack
22
22
name: <scope>/<pack>
23
-
version: x.x.x
24
-
description:
23
+
version: <x.x.x>
24
+
description: <Description to publish with the package>
25
25
default-suite: # a query-suite file that has been inlined
26
26
- query:
27
27
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
29
29
dependencies:
30
30
31
31
- ``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.
33
33
34
34
Running ``codeql pack publish``
35
35
-------------------------------
36
36
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:
38
38
39
39
::
40
40
41
41
codeql pack publish
42
42
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.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/using-custom-queries-with-the-codeql-cli.rst
+3-4Lines changed: 3 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,12 +56,11 @@ Packaging custom QL queries
56
56
57
57
Note
58
58
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.
60
60
61
61
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.
65
64
66
65
QL packs organize the files used in CodeQL analysis and can store queries,
67
66
library files, query suites, and important metadata. Their root directory must
0 commit comments