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
Update other articles to with details about packaging
In this commit:
- Replace _QL pack_ with _CodeQL pack_
- Replace `about-ql-pack` references with `about-codeql-packs`
- Replace examples using `libraryPathDependencies with
`dependencies`
- Update some examples to specify the optional `version` field
- Update description of query specifiers to note that a path
within a pack is valid.
CodeQL packs are used to create, share, depend on, and run CodeQL queries and libraries. You can publish your own CodeQL packs and download packs created by others. CodeQL packs contain queries, library files, query suites, and metadata.
7
9
8
10
There are two types of CodeQL packs: query packs and library packs.
@@ -60,71 +62,114 @@ The following properties are supported in ``qlpack.yml`` files.
60
62
- Required
61
63
- Purpose
62
64
* - ``name``
63
-
- ``name: octo-org/security-queries``
65
+
- .. code-block:: yaml
66
+
67
+
name: octo-org/security-queries
68
+
64
69
- All packs
65
-
- 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. Use the pack name to specify queries to run using ``database analyze`` and to define dependencies between QL packs (see examples below).
70
+
- 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. Use the pack name to specify queries to run using ``database analyze`` and to define dependencies between CodeQL packs (see examples below).
66
71
* - ``version``
67
-
- ``version: 0.0.0``
72
+
- .. code-block:: yaml
73
+
74
+
version: 0.0.0
75
+
68
76
- All packs
69
77
- A semantic version for this CodeQL pack that must adhere to the `SemVer v2.0.0 specification <https://semver.org/spec/v2.0.0.html>`__.
70
78
* - ``dependencies``
71
79
- .. code-block:: yaml
72
80
73
-
dependencies:
74
-
codeql/cpp-all: ^0.0.2
81
+
dependencies:
82
+
codeql/cpp-all: ^0.0.2
75
83
76
84
- Packs that define CodeQL package dependencies on other packs
77
85
- A map from pack references to the semantic version range that is compatible with this pack. Supported from CLI version v2.6.0 and onwards.
78
86
* - ``defaultSuiteFile``
79
-
- ``defaultSuiteFile: cpp-code-scanning.qls``
87
+
- .. code-block:: yaml
88
+
89
+
defaultSuiteFile: cpp-code-scanning.qls
90
+
80
91
- Packs that export a set of default queries to run
81
92
- The path to a query suite file containing all of the queries that are run by default when this pack is passed to the ``codeql database analyze`` command. Supported from CLI version v2.6.0 and onwards.
82
93
* - ``defaultSuite``
83
94
- .. code-block:: yaml
84
95
85
-
defaultSuite:
86
-
queries: .
87
-
exclude:
88
-
precision: medium
96
+
defaultSuite:
97
+
queries: .
98
+
exclude:
99
+
precision: medium
89
100
90
101
- Packs that export a set of default queries to run
91
102
- An inlined query suite containing all of the queries that are run by default when this pack is passed to the ``codeql database analyze`` command. Supported from CLI version v2.6.0 and onwards.
92
103
* - ``library``
93
-
- ``library: true``
104
+
- .. code-block:: yaml
105
+
106
+
library: true
107
+
94
108
- Library packs
95
109
- A boolean value that indicates whether this pack is a library pack. Library packs do not contain queries and are not compiled. Query packs can ignore this field or explicitly set it to ``false``.
96
110
* - ``suites``
97
-
- ``suites: octo-org-query-suites``
111
+
- .. code-block:: yaml
112
+
113
+
suites: octo-org-query-suites
114
+
98
115
- Optional
99
-
- The path to a directory in the pack that contains the query suites you want to make known to the CLI, defined relative to the pack directory. QL pack users can run "well-known" suites stored in this directory by specifying the pack name, without providing their full path. This is not supported for CodeQL packs downloaded from a package registry. For more information about query suites, see ":doc:`Creating CodeQL query suites <creating-codeql-query-suites>`."
116
+
- The path to a directory in the pack that contains the query suites you want to make known to the CLI, defined relative to the pack directory. CodeQL pack users can run "well-known" suites stored in this directory by specifying the pack name, without providing their full path. This is not supported for CodeQL packs downloaded from a package registry. For more information about query suites, see ":doc:`Creating CodeQL query suites <creating-codeql-query-suites>`."
100
117
* - ``extractor``
101
-
- ``javascript``
118
+
- .. code-block:: yaml
119
+
120
+
extractor: javascript
121
+
102
122
- All test packs
103
123
- The CodeQL language extractor to use when the CLI creates a database in the pack. For more information about testing queries, see ":doc:`Testing custom queries <testing-custom-queries>`."
104
124
* - ``tests``
105
-
- ``.``
106
-
- Optional for test packs
107
-
- 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.
108
-
* - ``dbscheme`` TODO: Internal only. Delete?
109
-
- ``semmlecode.python.dbscheme``
125
+
- .. code-block:: yaml
126
+
127
+
tests: .
128
+
129
+
- Optional for test packs. Ignored for non-test packs.
130
+
- 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. If this property is missing, then ``.`` is assumed.
131
+
* - ``dbscheme``
132
+
- .. code-block:: yaml
133
+
134
+
dbscheme: semmlecode.python.dbscheme
135
+
110
136
- Core language packs only
111
137
- The path to the :ref:`database schema <codeql-database-schema>` for all libraries and queries written for this CodeQL language (see example below).
112
-
* - ``upgrades`` TODO: Internal only. Delete?
113
-
- ``.``
138
+
* - ``upgrades``
139
+
- .. code-block:: yaml
140
+
141
+
upgrades: .
142
+
114
143
- Core language packs only
115
144
- The path to a directory within the pack that contains upgrade scripts, defined relative to the pack directory. The ``database upgrade`` action uses these scripts to upgrade databases that were created by an older version of an extractor or downgrade databases that were created by a newer version of the extractor so they're compatible with the current extractor (see `Upgrade scripts for a language <#upgrade-scripts-for-a-language>`__ below.)
116
145
* - ``authors``
117
-
- ``example@github.com``
146
+
- .. code-block:: yaml
147
+
148
+
authors: author1@github.com,author2@github.com
149
+
118
150
- All packs
119
151
- Metadata that will be displayed on the packaging search page in the packages section of the account that the CodeQL pack is published to.
120
-
* - ``licenses``
121
-
- ``(LGPL-2.1 AND MIT)``
152
+
* - ``license``
153
+
- .. code-block:: yaml
154
+
155
+
license: MIT
156
+
122
157
- All packs
123
158
- Metadata that will be displayed on the packaging search page in the packages section of the account that the CodeQL pack is published to. For a list of allowed licenses, see `SPDX License List <https://spdx.org/licenses/>`__ in the SPDX Specification.
124
159
* - ``description``
125
-
- ``Human-readable description of the contents of the CodeQL pack.``
160
+
- .. code-block:: yaml
161
+
162
+
description: Human-readable description of the contents of the CodeQL pack.
163
+
126
164
- All packs
127
165
- Metadata that will be displayed on the packaging search page in the packages section of the account that the CodeQL pack is published to.
166
+
* - ``libraryPathDependencies``
167
+
- .. code-block:: yaml
168
+
169
+
libraryPathDependencies: codeql/javascript-all
170
+
171
+
- Optional, deprecated
172
+
- Use the ``dependencies`` property instead. The names of any CodeQL packs that this CodeQL pack depends on, as a sequence. This gives the pack access to any libraries, database schema, and query suites defined in the dependency.
128
173
129
174
.. _about-codeql-pack-lock:
130
175
@@ -166,9 +211,9 @@ When you write custom queries or tests, you should save them in custom CodeQL pa
166
211
CodeQL packs for custom queries
167
212
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168
213
169
-
A custom QL pack for queries must include a ``qlpack.yml`` file at the pack root, containing ``name``, ``version``, and ``dependencies`` properties. If the pack contains query suites, you can use the ``suites`` property to define their location. Query suites defined here are called "well-known" suites, and can be used on the command line by referring to their name only, rather than their full path. For more information about query suites, see ":doc:`Creating CodeQL query suites <creating-codeql-query-suites>`."
214
+
A custom CodeQL pack for queries must include a ``qlpack.yml`` file at the pack root, containing ``name``, ``version``, and ``dependencies`` properties. If the pack contains query suites, you can use the ``suites`` property to define their location. Query suites defined here are called "well-known" suites, and can be used on the command line by referring to their name only, rather than their full path. For more information about query suites, see ":doc:`Creating CodeQL query suites <creating-codeql-query-suites>`."
170
215
171
-
For example, a ``qlpack.yml`` file for a QL pack featuring custom C++ queries
216
+
For example, a ``qlpack.yml`` file for a CodeQL pack featuring custom C++ queries
172
217
and libraries may contain:
173
218
174
219
.. code-block:: yaml
@@ -179,7 +224,7 @@ and libraries may contain:
179
224
codeql/cpp-all: ^0.1.2
180
225
suites: my-custom-suites
181
226
182
-
where ``codeql/cpp-all`` is the name of the QL pack for C/C++ analysis included in the CodeQL repository. The version range ``^0.1.2`` indicates that this pack is compatible with all versions of ``codeql/cpp-all`` that are greater than or equal to ``0.1.2`` and less than ``0.2.0``.
227
+
where ``codeql/cpp-all`` is the name of the CodeQL pack for C/C++ analysis included in the CodeQL repository. The version range ``^0.1.2`` indicates that this pack is compatible with all versions of ``codeql/cpp-all`` that are greater than or equal to ``0.1.2`` and less than ``0.2.0``.
183
228
184
229
CodeQL packs for custom test files
185
230
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -249,10 +294,10 @@ contains:
249
294
250
295
This query pack depends on ``codeql/cpp-all`` and ``codeql/suite-helpers``. Since these dependencies are resolved from source, it does not matter what version of the CodeQL pack they are compatible with.
251
296
252
-
Tests for the core QL pack
253
-
~~~~~~~~~~~~~~~~~~~~~~~~~~
297
+
Tests for the core CodeQL pack
298
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254
299
255
-
The ``qlpack.yml`` file for the tests for the core QL packs use the following properties: ``name``, ``dependencies``, ``extractor``, ``tests``.
300
+
The ``qlpack.yml`` file for the tests for the core CodeQL packs use the following properties: ``name``, ``dependencies``, ``extractor``, ``tests``.
256
301
257
302
For example, the ``qlpack.yml`` file for `C/C++ analysis tests
The ``dependencies`` property always specifies the core QL pack. The ``extractor`` property specifies that all the tests will use the same C++ extractor to create the database for the tests. The ``tests`` property specifies the location of the tests. In this case, the tests are in the root folder (and all sub-folders) of the pack. Note that there is no ``version`` property for the tests pack since this pack is not meant to be published.
315
+
The ``dependencies`` property always specifies the core CodeQL pack. The ``extractor`` property specifies that all the tests will use the same C++ extractor to create the database for the tests. The ``tests`` property specifies the location of the tests. In this case, the tests are in the root folder (and all sub-folders) of the pack. Note that there is no ``version`` property for the tests pack since this pack is not meant to be published.
- with an optional path to a query, directory, or query suite inside the pack
63
+
64
+
If omitted, the default query suite for the language of the database being analyzed will be used. For more information, see the :ref:`examples <database-analyze-examples>` below.
64
65
65
66
- ``--sarif-category``: an identifying category for the results. Used when
66
67
you want to upload more than one set of results for a commit.
@@ -192,10 +193,10 @@ For more information, see `Analyzing a CodeQL database <https://docs.github.com/
192
193
or `Code scanning API <https://docs.github.com/en/rest/reference/code-scanning>`__ in the GitHub documentation.
193
194
194
195
CodeQL query suites are ``.qls`` files that use directives to select queries to run
195
-
based on certain metadata properties. The standard QL packs have metadata that specify
196
+
based on certain metadata properties. The standard CodeQL packs have metadata that specify
196
197
the location of the query suites used by code scanning, so the CodeQL CLI knows where to find these
197
198
suite files automatically, and you don't have to specify the full path on the command line.
198
-
For more information, see ":ref:`About QL packs <standard-ql-packs>`."
199
+
For more information, see ":ref:`About CodeQL packs <standard-ql-packs>`."
199
200
200
201
The standard query suites are stored at the following paths in
201
202
the CodeQL repository::
@@ -239,18 +240,23 @@ recursively, so any queries contained in subfolders will also be executed.
239
240
240
241
Important
241
242
242
-
You shouldn't specify the root of a :doc:`QL pack
243
-
<about-ql-packs>` when executing ``database analyze``
243
+
You shouldn't specify the root of a :doc:`CodeQL pack
244
+
<about-codeql-packs>` when executing ``database analyze``
244
245
as it contains some special queries that aren't designed to be used with
245
246
the command. Rather, to run a wide range of useful queries, run one of the
246
247
LGTM.com query suites.
247
248
248
-
For example, to execute all Python queries contained in the ``Functions``
249
-
directory you would run::
249
+
For example, to execute all Python queries contained in the ``Functions`` directory you would run::
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/codeql-cli-reference.rst
+2-5Lines changed: 2 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,22 +3,19 @@
3
3
CodeQL CLI reference
4
4
====================
5
5
6
-
Learn more about the files you can use when running CodeQL processes and the results format and exit codes that CodeQL generates.
6
+
Learn more about the files you can use when running CodeQL processes and the results format and exit codes that CodeQL generates.
7
7
8
8
.. toctree::
9
9
:titlesonly:
10
10
:hidden:
11
11
12
12
about-codeql-packs
13
-
about-ql-packs
14
13
query-reference-files
15
14
sarif-output
16
15
exit-codes
17
16
extractor-options
18
17
19
-
- :doc:`About CodeQL packs <about-codeql-packs>`: CodeQL packs are created with the CodeQL CLI and are used to create, depend on, publish, and run CodeQL queries and libraries.
20
-
- :doc:`About QL packs <about-ql-packs>`: QL packs are used to organize the files used in CodeQL analysis. They
21
-
contain queries, library files, query suites, and important metadata.
18
+
- :doc:`About CodeQL packs <about-codeql-packs>`: CodeQL packs are created with the CodeQL CLI and are used to create, depend on, publish, and run CodeQL queries, libraries, and query suites.
22
19
- :doc:`Query reference files <query-reference-files>`: A query reference file is text file that defines the location of one query to test.
23
20
- :doc:`SARIF output <sarif-output>`: CodeQL supports SARIF as an output format for sharing static analysis results.
24
21
- :doc:`Exit codes <exit-codes>`: The CodeQL CLI reports the status of each command it runs as an exit code.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-cli/creating-and-working-with-codeql-packs.rst
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -34,24 +34,26 @@ You must specify:
34
34
35
35
The ``codeql pack init`` command creates the directory structure and configuration files for a CodeQL pack. By default, the command creates a query pack. If you want to create a library pack, you must edit the ``qlpack.yml`` file to explicitly declare the file as a library pack by including the ``library:true`` property.
36
36
37
-
Modifying an existing QL pack to create a CodeQL pack
If you already have a ``qlpack.yml`` file, you can edit it manually to convert it into a CodeQL pack.
40
41
41
42
#. Edit the ``name`` property so that it matches the format ``<scope>/<name>``, where ``<scope>`` is the name of the GitHub organization or user account that you will publish to.
42
43
#. In the ``qlpack.yml`` file, include a ``version`` property with a semver identifier, as well as an optional ``dependencies`` block.
44
+
#. Migrate the list of dependencies in ``libraryPathDependencies`` to the ``dependencies`` block. Specify the version range for each dependency. If the range is unimportant, or you are unsure of compatibility, you can specify ``"*"``, which indicates that any version is acceptable, with will default to the latest version when ``codeql pack install`` is run.
43
45
44
46
For more information about the properties, see ":ref:`About CodeQL packs <about-codeql-packs>`."
45
47
46
48
Adding and installing dependencies to a CodeQL pack
You can add dependencies on CodeQL packs using the command ``codeql pack add``. You must specify the scope, name, and version range.
50
+
You can add dependencies on CodeQL packs using the command ``codeql pack add``. You must specify the scope, name, and (optionally) a compatible version range.
The version range is optional. If you leave off the version range, the latest version will be added. Otherwise, the latest version that satisfies the requested range will be added.
56
+
If you leave off the version range, the latest version will be added. Otherwise, the latest version that satisfies the requested range will be added.
55
57
56
58
This command updates the ``qlpack.yml`` file with the requested dependencies and downloads them into the package cache. Please note that this command will reformat the file and remove all comments.
57
59
@@ -67,7 +69,8 @@ This command downloads all dependencies to the shared cache on the local disk.
67
69
68
70
Note
69
71
70
-
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.
72
+
Running the ``codeql pack add`` and ``codeql pack install`` commands will generate or update the ``codeql-pack.lock.yml`` file. This file should be checked-in to version control. The ``codeql-pack.lock.yml`` file contains the precise version numbers used by the pack.
73
+
For more information, see ":ref:`About codeql-pack.lock.yml files <about-codeql-pack-lock>`."
0 commit comments