@@ -4,7 +4,7 @@ Getting started with the CodeQL CLI
44===================================
55
66To 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.
88
99.. include :: ../reusables/license-note.rst
1010
@@ -18,16 +18,16 @@ structures. To get started quickly, we recommend adopting a relatively simple
1818setup, as outlined in the steps below.
1919
2020If 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
2323**Information for macOS "Catalina" (or newer) users **. If you are using macOS
2424on Apple Silicon (e.g. Apple M1), ensure that the `Xcode command-line developer
2525tools <https://developer.apple.com/downloads/index.action> `__ and `Rosetta 2
2626<https://support.apple.com/en-us/HT211861> `__ are installed.
2727
2828For 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 >`__
3131in the GitHub documentation.
3232
33331. Download the CodeQL CLI zip package
@@ -42,9 +42,9 @@ Conditions <https://securitylab.github.com/tools/codeql/license>`__.
4242
4343 There are several different versions of the CLI available to download, depending
4444 on your use case:
45-
45+
4646 - If you want to use the most up to date CodeQL tools and features, download the
47- version tagged ``latest ``.
47+ version tagged ``latest ``.
4848
4949 - If you want to create CodeQL databases to upload to LGTM Enterprise, download
5050 the version that is compatible with the relevant LGTM Enterprise version
@@ -53,9 +53,9 @@ Conditions <https://securitylab.github.com/tools/codeql/license>`__.
5353 <https://github.com/github/codeql-cli-binaries/releases> `__ on GitHub. Using the
5454 correct version of the CLI ensures that your CodeQL databases are
5555 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
5757 <https://help.semmle.com/lgtm-enterprise/admin/help/prepare-database-upload.html> `__
58- in the LGTM admin help.
58+ in the LGTM admin help.
5959
6060If you use Linux, Windows, or macOS version 10.14 ("Mojave") or earlier, simply
6161`download the zip archive
@@ -72,12 +72,12 @@ Alternatively, you can download ``codeql.zip``, which contains the CLI for all s
7272 **Information for macOS "Catalina" (or newer) users **
7373
7474 .. 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
7979 the CodeQL CLI zip archive:
80-
80+
8181 i. Open Safari.
8282 ii. From the Safari menu, select **Preferences... **.
8383 iii. Click the **General ** Tab.
@@ -101,22 +101,22 @@ further options on the command line.
1011013. Obtain a local copy of the CodeQL queries
102102~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103103
104- The `CodeQL repository <https://github.com/github/codeql >`__ contains
104+ The `CodeQL repository <https://github.com/github/codeql >`__ contains
105105the queries and libraries required for CodeQL analysis of C/C++, C#, Java,
106106JavaScript/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
113113``git clone git@github.com:github/codeql.git codeql-repo `` in the ``codeql-home `` folder.
114114
115115The CodeQL libraries and queries for Go analysis live in the `CodeQL for Go
116116repository <https://github.com/github/codeql-go/> `__. Clone a copy of this
117- repository into ``codeql-home ``.
117+ repository into ``codeql-home ``.
118118
119- The cloned repositories should have a sibling relationship.
119+ The cloned repositories should have a sibling relationship.
120120For example, if the root of the cloned CodeQL repository is
121121``$HOME/codeql-home/codeql-repo ``, then the root of the cloned CodeQL for Go
122122repository should be ``$HOME/codeql-home/codeql-go ``.
@@ -134,29 +134,29 @@ see ":doc:`About QL packs <about-ql-packs>`."
134134 - For the queries used on `LGTM.com <https://lgtm.com >`__, check out the
135135 ``lgtm.com `` branch. You should use this branch for databases you've built
136136 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
140140 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.
143143 This branch represents the very latest version of CodeQL's analysis. Even
144144 databases created using the most recent version of the CLI may have to be
145145 upgraded before you can analyze them. For more information, see
146146 ":doc: `Upgrading CodeQL databases <upgrading-codeql-databases >`."
147-
147+
148148 - For the queries used in a particular LGTM Enterprise release, check out the
149149 branch tagged with the relevant release number. For example, the branch
150150 tagged ``v1.27.0 `` corresponds to LGTM Enterprise 1.27. You must use this
151151 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
153153 <https://help.semmle.com/lgtm-enterprise/admin/help/prepare-database-upload.html> `__
154154 in the LGTM admin help.
155155
1561564. Extract the zip archive
157157~~~~~~~~~~~~~~~~~~~~~~~~~~
158158
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)
160160simply
161161extract the zip archive into the directory you created in step 2.
162162
@@ -171,16 +171,16 @@ For example, if the path to your copy of the CodeQL repository is
171171 **Information for macOS "Catalina" (or newer) users **
172172
173173 .. 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
177177 directory you created in step 2:
178-
178+
179179 i. ``mv ~/Downloads/codeql*.zip ${install_loc} ``
180180 ii. ``cd ${install_loc} ``
181181 iii. ``/usr/bin/xattr -c codeql*.zip ``
182182 iv. ``unzip codeql*.zip ``
183-
183+
1841845. Launch ``codeql ``
185185~~~~~~~~~~~~~~~~~~~~
186186
@@ -191,7 +191,7 @@ executable in a couple of ways:
191191 ``<extraction-root> `` is the folder where you extracted the CodeQL CLI
192192 package.
193193- 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 ``.
195195
196196At this point, you can execute CodeQL commands. For a full list of the CodeQL
197197CLI commands, see the "`CodeQL CLI manual <../manual >`__."
@@ -212,16 +212,20 @@ up to create and analyze databases:
212212
213213- Run ``codeql resolve languages `` to show which languages are
214214 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.
216216- 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, for example, ``codeql/{language}-queries ``.
221+ These packs contain the standard queries that will be run for each analysis.
222+ - Library packs for each supported language, for example, ``codeql/{language}-all ``. These
223+ packs contain query libraries, such as control flow and data flow libraries, that
224+ may be useful to query writers.
225+ - Example packs for each supported language, for example, ``codeql/{language}-examples ``.
226+ These packs contain useful snippets of CodeQL that query writers may find useful.
227+ - Legacy packs that ensure custom queries and libraries created using older products are
228+ compatible with your version of CodeQL.
225229
226230
227231.. _using-two-versions-of-the-codeql-cli :
@@ -242,4 +246,4 @@ recommended directory setup depends on which versions you want to install:
242246 directory. For example, if you unpack version 2.0.2 into
243247 ``$HOME/codeql-home/codeql-cli ``, the older version should be
244248 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