Skip to content

Commit c62a21e

Browse files
Apply suggestions from code review
Co-authored-by: Felicity Chapman <[email protected]>
1 parent 930a36d commit c62a21e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

docs/codeql/codeql-cli/creating-codeql-databases.rst

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Using indirect build tracing
233233

234234
If the CodeQL CLI autobuilders for compiled languages do not work with your CI workflow and you cannot wrap invocations of build commands with ``codeql database trace-command``, you can use indirect build tracing to create a CodeQL database. To use indirect build tracing, your CI system must be able to set custom environment variables for each build action.
235235

236-
CodeQL databases are created with indirect build tracing when you run the following command from the checkout root of your project:
236+
To create a CodeQL database with indirect build tracing, run the following command from the checkout root of your project:
237237

238238
::
239239

@@ -250,7 +250,7 @@ You may specify other options for the ``codeql database init`` command as normal
250250

251251
.. pull-quote:: Note
252252

253-
If you are on Windows, set either ``--trace-process-level <number>`` or ``--trace-process-name <parent process name>`` so that the option points to a parent CI process that will observe all build steps for the code being analyzed.
253+
If the build runs on Windows, you must set either ``--trace-process-level <number>`` or ``--trace-process-name <parent process name>`` so that the option points to a parent CI process that will observe all build steps for the code being analyzed.
254254

255255

256256
The ``codeql database init`` command will output a message::
@@ -262,16 +262,14 @@ The ``codeql database init`` command will output a message::
262262

263263
Based on your operating system, we recommend you run: ...
264264

265-
The ``codeql database init`` command will produce files in ``<database>/temp/tracingEnvironment`` containing environment variables and their values for CodeQL to trace subsequent build steps. These files are named ``start-tracing.{json,sh,bat,ps1}``. Use one of these files with your CI system's mechanism for setting environment variables for future steps. You can:
265+
The ``codeql database init`` command creates ``<database>/temp/tracingEnvironment`` with files that contain environment variables and values that will enable CodeQL to trace a sequence of build steps. These files are named ``start-tracing.{json,sh,bat,ps1}``. Use one of these files with your CI system's mechanism for setting environment variables for future steps. You can:
266266

267267
* Read the JSON file, process it, and print out environment variables in the format expected by your CI system. For example, Azure DevOps expects ``echo "##vso[task.setvariable variable=NAME]VALUE"``.
268-
* Or source the ``sh/bat/ps1`` script so that its variables go into your shell environment.
268+
* Or source the appropriate ``start-tracing`` script to set the CodeQL variables in the shell environment of the CI system.
269269

270-
Build your code, end build tracing, and then run the command ``codeql database finalize <database>``.
270+
Build your code and then run the command ``codeql database finalize <database>``. Optionally, after building the code, unset the environment variables using an ``end-tracing.{json,sh,bat,ps1}`` script from the directory where the ``start-tracing`` scripts are stored.
271271

272-
You can optionally clean up the environment variables by following the same process as with the ``--begin-tracing`` scripts, except now with ``end-tracing.{json,sh,bat,ps1}`` scripts in the same directory.
273-
274-
Once you have created a CodeQL database using indirect build tracing, you can work with it like any other CodeQL database. For example, analyze the database, and upload the results if using Code Scanning.
272+
Once you have created a CodeQL database using indirect build tracing, you can work with it like any other CodeQL database. For example, analyze the database, and upload the results to GitHub if you use code scanning.
275273

276274
Example of creating a CodeQL database using indirect build tracing
277275
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -282,17 +280,18 @@ The following example shows how you could use indirect build tracing in an Azure
282280
# Download the CodeQL CLI and query packs...
283281
# Check out the repository ...
284282

285-
# Tasks prior to executing the build, e.g. restore NuGet dependencies...
283+
# Run any pre-build tasks, for example, restore NuGet dependencies...
286284

287285
# Initialize the CodeQL database.
288286
# In this example, the CodeQL CLI has been downloaded and placed on the PATH.
289-
# If no language is specified, a GitHub Apps or personal access token must be passed through stdin
287+
# If no language is specified, a GitHub Apps or personal access token must be passed through stdin.
290288
# to autodetect the language.
291289
- task: CmdLine@1
292290
displayName: Initialize CodeQL database
293291
inputs:
294292
# Assumes the source code is checked out to the current working directory.
295-
# Creates a database at `<current working directory>/db`
293+
# Creates a database at `<current working directory>/db`.
294+
# Running on Windows, so specifies a trace process level.
296295
script: "codeql database init --language csharp --trace-process-level 3 --source-root --begin-tracing db"
297296

298297
# Read the generated environment variables and values,
@@ -344,9 +343,9 @@ The following example shows how you could use indirect build tracing in an Azure
344343
inputs:
345344
script: 'codeql database finalize db'
346345

347-
# Other tasks go here,
348-
# e.g. `codeql database analyze`
349-
# and `codeql github upload-results` ...
346+
# Other tasks go here, for example:
347+
# `codeql database analyze`
348+
# then `codeql github upload-results` ...
350349

351350
Obtaining databases from LGTM.com
352351
---------------------------------

0 commit comments

Comments
 (0)