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
Use the ``--download`` flag to download the query pack if it isn't yet available locally.
131
+
132
+
.. _run-query-pack:
133
+
126
134
Running a CodeQL pack
127
135
~~~~~~~~~~~~~~~~~~~~~
128
136
@@ -136,6 +144,40 @@ pack names and use the ``--download`` flag::
136
144
The ``analyze`` command above runs the default suite from ``microsoft/coding-standards v1.0.0`` and the latest version of ``github/security-queries`` on the specified database.
137
145
For further information about default suites, see ":ref:`Publishing and using CodeQL packs <publishing-and-using-codeql-packs>`".
138
146
147
+
Running all queries in a directory
148
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
+
150
+
You can run all the queries located in a directory by providing the directory
151
+
path, rather than listing all the individual query files. Paths are searched
152
+
recursively, so any queries contained in subfolders will also be executed.
153
+
154
+
.. pull-quote::
155
+
156
+
Important
157
+
158
+
You should avoid specifying the root of a :ref:`core CodeQL query pack
159
+
<standard-codeql-query-packs>` when executing ``database analyze``
160
+
as it might contain some special queries that aren't designed to be used with
161
+
the command. Rather, :ref:`run the query pack <run-query-pack>` to include the
162
+
pack's default queries in the analysis, or run one of the
163
+
code scanning query suites.
164
+
165
+
For example, to execute all Python queries contained in the ``Functions`` directory you would run::
@@ -196,7 +238,7 @@ CodeQL query suites are ``.qls`` files that use directives to select queries to
196
238
based on certain metadata properties. The standard CodeQL packs have metadata that specify
197
239
the location of the query suites used by code scanning, so the CodeQL CLI knows where to find these
198
240
suite files automatically, and you don't have to specify the full path on the command line.
199
-
For more information, see ":ref:`About CodeQL packs <standard-ql-packs>`."
241
+
For more information, see ":ref:`About CodeQL packs <standard-codeql-packs>`."
200
242
201
243
The standard query suites are stored at the following paths in
202
244
the CodeQL repository::
@@ -228,40 +270,6 @@ Integrating a CodeQL pack into a code scanning workflow in GitHub
228
270
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.
229
271
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>`_."
230
272
231
-
232
-
Running all queries in a directory
233
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
234
-
235
-
You can run all the queries located in a directory by providing the directory
236
-
path, rather than listing all the individual query files. Paths are searched
237
-
recursively, so any queries contained in subfolders will also be executed.
238
-
239
-
.. pull-quote::
240
-
241
-
Important
242
-
243
-
You shouldn't specify the root of a :doc:`CodeQL pack
244
-
<about-codeql-packs>` when executing ``database analyze``
245
-
as it contains some special queries that aren't designed to be used with
246
-
the command. Rather, to run a wide range of useful queries, run one of the
247
-
LGTM.com query suites.
248
-
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/creating-and-working-with-codeql-packs.rst
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -34,14 +34,14 @@ 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 legacy CodeQL 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.
41
41
42
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.
43
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 and will default to the latest version when ``codeql pack install`` is run.
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 and will default to the latest version when you run ``codeql pack install``.
45
45
46
46
For more information about the properties, see ":ref:`About CodeQL packs <about-codeql-packs>`."
47
47
@@ -53,7 +53,7 @@ You can add dependencies on CodeQL packs using the command ``codeql pack add``.
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 don't specify a version range, the latest version will be added. Otherwise, the latest version that satisfies the requested range will be added.
57
57
58
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.
0 commit comments