@@ -4,7 +4,7 @@ Getting started with the CodeQL CLI
4
4
===================================
5
5
6
6
To run CodeQL commands, you need to set up the CLI so that it can access
7
- the tools, queries, and libraries required to create and analyze databases.
7
+ the tools, queries, and libraries required to create and analyze databases.
8
8
9
9
.. include :: ../reusables/license-note.rst
10
10
@@ -18,16 +18,16 @@ structures. To get started quickly, we recommend adopting a relatively simple
18
18
setup, as outlined in the steps below.
19
19
20
20
If you use Linux, Windows, or macOS version 10.14 ("Mojave") or earlier, simply
21
- follow the steps below. For macOS version 10.15 ("Catalina") or newer, steps 1
22
- and 4 are slightly different---for further details, see the sections labeled
21
+ follow the steps below. For macOS version 10.15 ("Catalina") or newer, steps 1
22
+ and 4 are slightly different---for further details, see the sections labeled
23
23
**Information for macOS "Catalina" (or newer) users **. If you are using macOS
24
24
on Apple Silicon (e.g. Apple M1), ensure that the `Xcode command-line developer
25
25
tools <https://developer.apple.com/downloads/index.action> `__ and `Rosetta 2
26
26
<https://support.apple.com/en-us/HT211861> `__ are installed.
27
27
28
28
For information about installing the CodeQL CLI in a CI system to create results
29
- to display in GitHub as code scanning alerts, see
30
- `Installing CodeQL CLI in your CI system <https://docs.github.com/en/code-security/secure-coding/using-codeql-code-scanning-with-your-existing-ci-system/installing-codeql-cli-in-your-ci-system >`__
29
+ to display in GitHub as code scanning alerts, see
30
+ `Installing CodeQL CLI in your CI system <https://docs.github.com/en/code-security/secure-coding/using-codeql-code-scanning-with-your-existing-ci-system/installing-codeql-cli-in-your-ci-system >`__
31
31
in the GitHub documentation.
32
32
33
33
1. Download the CodeQL CLI zip package
@@ -42,9 +42,9 @@ Conditions <https://securitylab.github.com/tools/codeql/license>`__.
42
42
43
43
There are several different versions of the CLI available to download, depending
44
44
on your use case:
45
-
45
+
46
46
- If you want to use the most up to date CodeQL tools and features, download the
47
- version tagged ``latest ``.
47
+ version tagged ``latest ``.
48
48
49
49
- If you want to create CodeQL databases to upload to LGTM Enterprise, download
50
50
the version that is compatible with the relevant LGTM Enterprise version
@@ -53,9 +53,9 @@ Conditions <https://securitylab.github.com/tools/codeql/license>`__.
53
53
<https://github.com/github/codeql-cli-binaries/releases> `__ on GitHub. Using the
54
54
correct version of the CLI ensures that your CodeQL databases are
55
55
compatible with your version of LGTM Enterprise. For more information,
56
- see `Preparing CodeQL databases to upload to LGTM
56
+ see `Preparing CodeQL databases to upload to LGTM
57
57
<https://help.semmle.com/lgtm-enterprise/admin/help/prepare-database-upload.html> `__
58
- in the LGTM admin help.
58
+ in the LGTM admin help.
59
59
60
60
If you use Linux, Windows, or macOS version 10.14 ("Mojave") or earlier, simply
61
61
`download the zip archive
@@ -72,12 +72,12 @@ Alternatively, you can download ``codeql.zip``, which contains the CLI for all s
72
72
**Information for macOS "Catalina" (or newer) users **
73
73
74
74
.. pull-quote :: macOS "Catalina" (or newer)
75
-
76
- If you use macOS version 10.15 ("Catalina"), version 11 ("Big Sur"), or the upcoming
77
- version 12 ("Monterey"), you need to ensure that your web browser does not automatically
78
- extract zip files. If you use Safari, complete the following steps before downloading
75
+
76
+ If you use macOS version 10.15 ("Catalina"), version 11 ("Big Sur"), or the upcoming
77
+ version 12 ("Monterey"), you need to ensure that your web browser does not automatically
78
+ extract zip files. If you use Safari, complete the following steps before downloading
79
79
the CodeQL CLI zip archive:
80
-
80
+
81
81
i. Open Safari.
82
82
ii. From the Safari menu, select **Preferences... **.
83
83
iii. Click the **General ** Tab.
@@ -101,22 +101,22 @@ further options on the command line.
101
101
3. Obtain a local copy of the CodeQL queries
102
102
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103
103
104
- The `CodeQL repository <https://github.com/github/codeql >`__ contains
104
+ The `CodeQL repository <https://github.com/github/codeql >`__ contains
105
105
the queries and libraries required for CodeQL analysis of C/C++, C#, Java,
106
106
JavaScript/TypeScript, Python, and Ruby.
107
- Clone a copy of this repository into ``codeql-home ``.
108
-
109
- By default, the root of the cloned repository will be called ``codeql ``.
110
- Rename this folder ``codeql-repo `` to avoid conflicting with the CodeQL
111
- CLI that you will extract in step 4. If you use git on the command line, you can
112
- clone and rename the repository in a single step by running
107
+ Clone a copy of this repository into ``codeql-home ``.
108
+
109
+ By default, the root of the cloned repository will be called ``codeql ``.
110
+ Rename this folder ``codeql-repo `` to avoid conflicting with the CodeQL
111
+ CLI that you will extract in step 4. If you use git on the command line, you can
112
+ clone and rename the repository in a single step by running
113
113
``
git clone [email protected] :github/codeql.git codeql-repo `` in the ``
codeql-home `` folder.
114
114
115
115
The CodeQL libraries and queries for Go analysis live in the `CodeQL for Go
116
116
repository <https://github.com/github/codeql-go/> `__. Clone a copy of this
117
- repository into ``codeql-home ``.
117
+ repository into ``codeql-home ``.
118
118
119
- The cloned repositories should have a sibling relationship.
119
+ The cloned repositories should have a sibling relationship.
120
120
For example, if the root of the cloned CodeQL repository is
121
121
``$HOME/codeql-home/codeql-repo ``, then the root of the cloned CodeQL for Go
122
122
repository should be ``$HOME/codeql-home/codeql-go ``.
@@ -134,29 +134,29 @@ see ":doc:`About QL packs <about-ql-packs>`."
134
134
- For the queries used on `LGTM.com <https://lgtm.com >`__, check out the
135
135
``lgtm.com `` branch. You should use this branch for databases you've built
136
136
using the CodeQL CLI, fetched from code scanning on GitHub, or recently downloaded from LGTM.com.
137
- The queries on the ``lgtm.com `` branch are more likely to be compatible
138
- with the ``latest `` CLI, so you'll be less likely to have to upgrade
139
- newly-created databases than if you use the ``main `` branch. Older databases
137
+ The queries on the ``lgtm.com `` branch are more likely to be compatible
138
+ with the ``latest `` CLI, so you'll be less likely to have to upgrade
139
+ newly-created databases than if you use the ``main `` branch. Older databases
140
140
may need to be upgraded before you can analyze them.
141
-
142
- - For the most up to date CodeQL queries, check out the ``main `` branch.
141
+
142
+ - For the most up to date CodeQL queries, check out the ``main `` branch.
143
143
This branch represents the very latest version of CodeQL's analysis. Even
144
144
databases created using the most recent version of the CLI may have to be
145
145
upgraded before you can analyze them. For more information, see
146
146
":doc: `Upgrading CodeQL databases <upgrading-codeql-databases >`."
147
-
147
+
148
148
- For the queries used in a particular LGTM Enterprise release, check out the
149
149
branch tagged with the relevant release number. For example, the branch
150
150
tagged ``v1.27.0 `` corresponds to LGTM Enterprise 1.27. You must use this
151
151
version if you want to upload data to LGTM Enterprise. For further
152
- information, see `Preparing CodeQL databases to upload to LGTM
152
+ information, see `Preparing CodeQL databases to upload to LGTM
153
153
<https://help.semmle.com/lgtm-enterprise/admin/help/prepare-database-upload.html> `__
154
154
in the LGTM admin help.
155
155
156
156
4. Extract the zip archive
157
157
~~~~~~~~~~~~~~~~~~~~~~~~~~
158
158
159
- For Linux, Windows, and macOS users (version 10.14 "Mojave", and earlier)
159
+ For Linux, Windows, and macOS users (version 10.14 "Mojave", and earlier)
160
160
simply
161
161
extract the zip archive into the directory you created in step 2.
162
162
@@ -171,16 +171,16 @@ For example, if the path to your copy of the CodeQL repository is
171
171
**Information for macOS "Catalina" (or newer) users **
172
172
173
173
.. pull-quote :: macOS "Catalina"
174
-
175
- macOS "Catalina", "Big Sur", or "Monterey" users should run the following
176
- commands in the Terminal, where ``${install_loc} `` is the path to the
174
+
175
+ macOS "Catalina", "Big Sur", or "Monterey" users should run the following
176
+ commands in the Terminal, where ``${install_loc} `` is the path to the
177
177
directory you created in step 2:
178
-
178
+
179
179
i. ``mv ~/Downloads/codeql*.zip ${install_loc} ``
180
180
ii. ``cd ${install_loc} ``
181
181
iii. ``/usr/bin/xattr -c codeql*.zip ``
182
182
iv. ``unzip codeql*.zip ``
183
-
183
+
184
184
5. Launch ``codeql ``
185
185
~~~~~~~~~~~~~~~~~~~~
186
186
@@ -191,7 +191,7 @@ executable in a couple of ways:
191
191
``<extraction-root> `` is the folder where you extracted the CodeQL CLI
192
192
package.
193
193
- By adding ``<extraction-root>/codeql `` to your ``PATH ``, so that you
194
- can run the executable as just ``codeql ``.
194
+ can run the executable as just ``codeql ``.
195
195
196
196
At this point, you can execute CodeQL commands. For a full list of the CodeQL
197
197
CLI commands, see the "`CodeQL CLI manual <../manual >`__."
@@ -212,16 +212,20 @@ up to create and analyze databases:
212
212
213
213
- Run ``codeql resolve languages `` to show which languages are
214
214
available for database creation. This will list the languages supported by
215
- default in your CodeQL CLI package.
215
+ default in your CodeQL CLI package.
216
216
- Run ``codeql resolve qlpacks `` to show which QL packs the CLI can find. This
217
- will display the names of the QL packs included in the CodeQL repositories:
218
- ``codeql-cpp ``, ``codeql-csharp ``, ``codeql-go ``,
219
- ``codeql-java ``, ``codeql-javascript ``, and ``codeql-python ``. The CodeQL
220
- repositories also contain 'upgrade' packs and 'legacy' packs. Upgrade packs
221
- are used by the CLI when you want to upgrade a database so that it can be
222
- analyzed with a newer version of the CodeQL toolchain than was used to create
223
- it. Legacy packs ensure that custom queries and libraries created using older
224
- products are compatible with your version of CodeQL.
217
+ will display the names of all the QL packs directly available to the CodeQL CLI.
218
+ This should include:
219
+
220
+ - Query packs for each supported language, e.g., ``codeql/{language}-queries ``.
221
+ These packs contain the standard queries that will be run for each analysis.
222
+ - Library packs for each supported language, e.g., ``codeql/{language}-all ``. These
223
+ packs contain query libraries, such as control flow and data flow libraries, that
224
+ may be useful to other query authors.
225
+ - Example packs for each supported language, e.g., ``codeql/{language}-examples ``.
226
+ These packs contain useful snippets of CodeQL that query auhtors may want To use.
227
+ - Legacy packs that ensure custom queries and libraries created using older products are
228
+ compatible with your version of CodeQL.
225
229
226
230
227
231
.. _using-two-versions-of-the-codeql-cli :
@@ -242,4 +246,4 @@ recommended directory setup depends on which versions you want to install:
242
246
directory. For example, if you unpack version 2.0.2 into
243
247
``$HOME/codeql-home/codeql-cli ``, the older version should be
244
248
unpacked into ``$HOME/codeql-older-version/old-codeql-cli ``. Here, the common
245
- grandparent is the ``$HOME `` directory.
249
+ grandparent is the ``$HOME `` directory.
0 commit comments