Skip to content

Commit 3ddc28e

Browse files
isaacmbrownCopilotCopilot
authored
[EDI] Advanced setup of the CodeQL CLI (#59983)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 283873c commit 3ddc28e

File tree

6 files changed

+135
-123
lines changed

6 files changed

+135
-123
lines changed

content/code-security/concepts/code-scanning/codeql/about-the-codeql-cli.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ redirect_from:
2424
- /code-security/code-scanning/using-codeql-code-scanning-with-your-existing-ci-system/migrating-from-the-codeql-runner-to-codeql-cli
2525
- /code-security/code-scanning/using-codeql-code-scanning-with-your-existing-ci-system/about-codeql-code-scanning-in-your-ci-system
2626
- /code-security/codeql-cli/getting-started-with-the-codeql-cli/about-the-codeql-cli
27+
- /code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/advanced-setup-of-the-codeql-cli
28+
- /code-security/how-tos/scan-code-for-vulnerabilities/scan-from-the-command-line/advanced-setup-of-the-codeql-cli
2729
contentType: concepts
2830
---
2931

@@ -45,9 +47,6 @@ The {% data variables.product.prodname_codeql_cli %} can analyze:
4547
* Compiled languages, for example, {% data variables.code-scanning.compiled_languages %}
4648
* Codebases written in a mixture of languages.
4749

48-
For information about setting up the {% data variables.product.prodname_codeql_cli %}, see
49-
[AUTOTITLE](/code-security/codeql-cli/getting-started-with-the-codeql-cli/setting-up-the-codeql-cli).
50-
5150
## About using the {% data variables.product.prodname_codeql_cli %} for {% data variables.product.prodname_code_scanning %}
5251

5352
You can use the {% data variables.product.prodname_codeql_cli %} to run {% data variables.product.prodname_code_scanning %} on code that you're processing in a third-party continuous integration (CI) system. {% data reusables.code-scanning.about-code-scanning %} For an overview of using code scanning with external CI systems, see [AUTOTITLE](/code-security/code-scanning/integrating-with-code-scanning/using-code-scanning-with-your-existing-ci-system). For recommended specifications (RAM, CPU cores, and disk) for running {% data variables.product.prodname_codeql %} analysis, see [AUTOTITLE](/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/recommended-hardware-resources-for-running-codeql).
@@ -60,7 +59,7 @@ For an overview of all the options for using {% data variables.product.prodname_
6059

6160
## About generating code scanning results with the {% data variables.product.prodname_codeql_cli %}
6261

63-
If you choose to run the {% data variables.product.prodname_codeql_cli %} directly, you first have to install the {% data variables.product.prodname_codeql_cli %} locally. If you are planning to use the {% data variables.product.prodname_codeql_cli %} with an external CI system, you need to make the {% data variables.product.prodname_codeql_cli %} available to servers in your CI system. For more information, see [AUTOTITLE](/code-security/codeql-cli/getting-started-with-the-codeql-cli/setting-up-the-codeql-cli).
62+
If you choose to run the {% data variables.product.prodname_codeql_cli %} directly, you first have to install the {% data variables.product.prodname_codeql_cli %} locally. If you are planning to use the {% data variables.product.prodname_codeql_cli %} with an external CI system, you need to make the {% data variables.product.prodname_codeql_cli %} available to servers in your CI system.
6463

6564
Once the {% data variables.product.prodname_codeql_cli %} is set up, you can use three different commands to generate results and upload them to {% data variables.product.github %}:
6665

@@ -115,3 +114,13 @@ codeql github upload-results \
115114
The {% data variables.product.prodname_codeql_cli %} uses special programs, called extractors, to extract information from the source code of a software system into a database that can be queried. You can customize the behavior of extractors by setting extractor configuration options through the {% data variables.product.prodname_codeql_cli %}. See [AUTOTITLE](/code-security/reference/code-scanning/codeql/codeql-cli/extractor-options).
116115

117116
{% data reusables.code-scanning.codeql-license %}
117+
118+
## Getting started
119+
120+
For the simplest way to get started, see [AUTOTITLE](/code-security/codeql-cli/getting-started-with-the-codeql-cli/setting-up-the-codeql-cli).
121+
122+
More advanced setup options are available if you need them. For example, if you:
123+
124+
* Want to contribute to open source shared {% data variables.product.prodname_codeql %} queries and prefer working with the {% data variables.product.prodname_codeql %} source code directly. See [AUTOTITLE](/code-security/how-tos/scan-code-for-vulnerabilities/scan-from-the-command-line/check-out-source-code).
125+
* Need to install multiple versions of the {% data variables.product.prodname_codeql_cli %} side by side. For example, if one codebase requires a specific version while another uses the latest. You can download each version and unpack both CLI archives in the same parent directory.
126+
* Are researching or developing queries and want to download databases from {% data variables.product.prodname_dotcom_the_website %}. See [AUTOTITLE](/code-security/how-tos/scan-code-for-vulnerabilities/scan-from-the-command-line/download-databases).

content/code-security/how-tos/scan-code-for-vulnerabilities/scan-from-the-command-line/advanced-setup-of-the-codeql-cli.md

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Checking out the CodeQL CLI source code
3+
intro: Set up the {% data variables.product.prodname_codeql_cli %} directly from the source code.
4+
product: '{% data reusables.gated-features.codeql %}'
5+
versions:
6+
fpt: '*'
7+
ghes: '*'
8+
ghec: '*'
9+
topics:
10+
- Code Security
11+
- Code scanning
12+
- CodeQL
13+
contentType: how-tos
14+
shortTitle: Check out source code
15+
---
16+
17+
Some users prefer working with {% data variables.product.prodname_codeql %} query sources directly in order to work on or contribute to open source shared queries.
18+
19+
## 1. Download the {% data variables.product.prodname_codeql_cli %} tar archive
20+
21+
{% data reusables.codeql-cli.download-codeql-cli %}
22+
23+
## 2. Create a new {% data variables.product.prodname_codeql %} directory
24+
25+
Create a new directory where you can place the CLI and any queries and libraries
26+
you want to use. For example, `$HOME/codeql-home`.
27+
28+
The CLI’s built-in search operations automatically look in all of its sibling
29+
directories for the files used in database creation and analysis. Keeping these
30+
components in their own directory prevents the CLI searching unrelated sibling
31+
directories while ensuring all files are available without specifying any
32+
further options on the command line.
33+
34+
## 3. Obtain a local copy of the {% data variables.product.prodname_codeql %} queries
35+
36+
The [{% data variables.product.prodname_codeql %} repository](https://github.com/github/codeql?ref_product=code-scanning&ref_type=engagement&ref_style=text) contains
37+
the queries and libraries required for {% data variables.product.prodname_codeql %} analysis of all supported languages.
38+
Clone a copy of this repository into `codeql-home`.
39+
40+
By default, the root of the cloned repository will be called `codeql`.
41+
Rename this folder `codeql-repo` to avoid conflicting with the {% data variables.product.prodname_codeql_cli %} that you will extract in step 1. If you use git on the command line, you can
42+
clone and rename the repository in a single step by running
43+
`git clone git@github.com:github/codeql.git codeql-repo` in the `codeql-home` folder.
44+
45+
Within this repository, the queries and libraries are organized into {% data variables.product.prodname_codeql %}
46+
packs. Along with the queries themselves, {% data variables.product.prodname_codeql %} packs contain important metadata
47+
that tells the {% data variables.product.prodname_codeql_cli %} how to process the query files. For more information,
48+
see [AUTOTITLE](/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/creating-and-working-with-codeql-packs).
49+
50+
> [!NOTE]
51+
> There are different versions of the {% data variables.product.prodname_codeql %} queries available for different users. Check out the correct version for your use case:
52+
>
53+
> * For the queries that are intended to be used with the latest {% data variables.product.prodname_codeql_cli %} release, check out the branch tagged `codeql-cli/latest`. You should use this branch for databases you’ve built using the {% data variables.product.prodname_codeql_cli %} or recently downloaded from {% data variables.product.github %}.
54+
> * For the most up to date {% data variables.product.prodname_codeql %} queries, check out the `main` branch. This branch represents the very latest version of {% data variables.product.prodname_codeql %}’s analysis.
55+
56+
## 4. Extract the {% data variables.product.prodname_codeql_cli %} tar archive
57+
58+
Extract the tar archive into the directory you created in step 2.
59+
60+
For example, if the path to your copy of the {% data variables.product.prodname_codeql %} repository is `$HOME/codeql-home/codeql-repo`, then extract the CLI into
61+
`$HOME/codeql-home/`.
62+
63+
## 5. Launch `codeql`
64+
65+
{% data reusables.codeql-cli.launch-codeql %}
66+
67+
## 6. Verify your {% data variables.product.prodname_codeql_cli %} setup
68+
69+
{% data variables.product.prodname_codeql_cli %} has subcommands you can execute to verify that you are correctly set up to create and analyze databases:
70+
71+
* Run `codeql resolve languages` to show which languages are available for database creation. This will list the languages supported by default in your {% data variables.product.prodname_codeql_cli %} package.
72+
* Run `codeql resolve qlpacks` to show which {% data variables.product.prodname_codeql %} packs the CLI can find. This will display the names of all the {% data variables.product.prodname_codeql %} packs directly available to the {% data variables.product.prodname_codeql_cli %}. This should include:
73+
* Query packs for each supported language, for example, `codeql/{language}-queries`. These packs contain the standard queries that will be run for each analysis.
74+
* Library packs for each supported language, for example, `codeql/{language}-all`. These packs contain query libraries, such as control flow and data flow libraries, that may be useful to query writers.
75+
* Example packs for each supported language, for example, `codeql/{language}-examples`. These packs contain useful snippets of {% data variables.product.prodname_codeql %} that query writers may find useful.
76+
* Legacy packs that ensure custom queries and libraries created using older products are compatible with your version of {% data variables.product.prodname_codeql %}.

0 commit comments

Comments
 (0)