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
- 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.
@@ -122,6 +123,14 @@ You can also run your own custom queries with the ``database analyze`` command.
122
123
For more information about preparing your queries to use with the CodeQL CLI,
123
124
see ":doc:`Using custom queries with the CodeQL CLI <using-custom-queries-with-the-codeql-cli>`."
124
125
126
+
If you do not have the CodeQL repository checked out, you can execute the same queries by specifying the query pack name and the path to the queries::
Use the ``--download`` flag to download the query pack if it isn't yet available locally.
131
+
132
+
.. _run-query-pack:
133
+
125
134
Running a CodeQL pack
126
135
~~~~~~~~~~~~~~~~~~~~~
127
136
@@ -135,6 +144,34 @@ pack names and use the ``--download`` flag::
135
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.
136
145
For further information about default suites, see ":ref:`Publishing and using CodeQL packs <publishing-and-using-codeql-packs>`".
137
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::
@@ -192,10 +229,10 @@ For more information, see `Analyzing a CodeQL database <https://docs.github.com/
192
229
or `Code scanning API <https://docs.github.com/en/rest/reference/code-scanning>`__ in the GitHub documentation.
193
230
194
231
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
232
+
based on certain metadata properties. The standard CodeQL packs have metadata that specify
196
233
the location of the query suites used by code scanning, so the CodeQL CLI knows where to find these
197
234
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>`."
235
+
For more information, see ":ref:`About CodeQL packs <standard-codeql-packs>`."
199
236
200
237
The standard query suites are stored at the following paths in
201
238
the CodeQL repository::
@@ -227,35 +264,6 @@ Integrating a CodeQL pack into a code scanning workflow in GitHub
227
264
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.
228
265
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>`_."
229
266
230
-
231
-
Running all queries in a directory
232
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
233
-
234
-
You can run all the queries located in a directory by providing the directory
235
-
path, rather than listing all the individual query files. Paths are searched
236
-
recursively, so any queries contained in subfolders will also be executed.
237
-
238
-
.. pull-quote::
239
-
240
-
Important
241
-
242
-
You shouldn't specify the root of a :doc:`QL pack
243
-
<about-ql-packs>` when executing ``database analyze``
244
-
as it contains some special queries that aren't designed to be used with
245
-
the command. Rather, to run a wide range of useful queries, run one of the
246
-
LGTM.com query suites.
247
-
248
-
For example, to execute all Python queries contained in the ``Functions``
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.
0 commit comments