Skip to content

Commit 4647dd8

Browse files
authored
Merge pull request github#34700 from github/repo-sync
repo sync
2 parents 6578100 + 879db5f commit 4647dd8

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

content/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ By default, only alerts with the severity level of `Error` or security severity
102102

103103
You might want to avoid a code scan being triggered on specific pull requests targeted against the default branch, irrespective of which files have been changed. You can configure this by specifying `on:pull_request:paths-ignore` or `on:pull_request:paths` in the {% data variables.product.prodname_code_scanning %} workflow. For example, if the only changes in a pull request are to files with the file extensions `.md` or `.txt` you can use the following `paths-ignore` array.
104104

105-
``` yaml
105+
``` yaml{:copy}
106106
on:
107107
push:
108108
branches: [main, protected]
@@ -138,7 +138,7 @@ If you use the default {% data variables.code-scanning.codeql_workflow %}, the w
138138

139139
The following example shows a {% data variables.code-scanning.codeql_workflow %} for a particular repository that has a default branch called `main` and one protected branch called `protected`.
140140

141-
``` yaml
141+
``` yaml{:copy}
142142
on:
143143
push:
144144
branches: [main, protected]
@@ -157,7 +157,7 @@ This workflow scans:
157157

158158
If your code requires a specific operating system to compile, you can configure the operating system in your {% data variables.code-scanning.codeql_workflow %}. Edit the value of `jobs.analyze.runs-on` to specify the operating system for the machine that runs your {% data variables.product.prodname_code_scanning %} actions. {% ifversion ghes %}You specify the operating system by using an appropriate label as the second element in a two-element array, after `self-hosted`.{% else %}
159159

160-
``` yaml
160+
``` yaml{:copy}
161161
jobs:
162162
analyze:
163163
name: Analyze
@@ -166,7 +166,7 @@ jobs:
166166

167167
If you choose to use a self-hosted runner for code scanning, you can specify an operating system by using an appropriate label as the second element in a two-element array, after `self-hosted`.{% endif %}
168168

169-
``` yaml
169+
``` yaml{:copy}
170170
jobs:
171171
analyze:
172172
name: Analyze
@@ -183,7 +183,7 @@ For recommended specifications (RAM, CPU cores, and disk) for running {% data va
183183

184184
In general, you do not need to worry about where the {% data variables.code-scanning.codeql_workflow %} places {% data variables.product.prodname_codeql %} databases since later steps will automatically find databases created by previous steps. However, if you are writing a custom workflow step that requires the {% data variables.product.prodname_codeql %} database to be in a specific disk location, for example to upload the database as a workflow artifact, you can specify that location using the `db-location` parameter under the `init` action.
185185

186-
``` yaml
186+
``` yaml{:copy}
187187
- uses: {% data reusables.actions.action-codeql-action-init %}
188188
with:
189189
db-location: {% raw %}'${{ github.workspace }}/codeql_dbs'{% endraw %}
@@ -205,7 +205,7 @@ The default {% data variables.code-scanning.codeql_workflow %} file contains a m
205205

206206
If your workflow uses the `language` matrix then {% data variables.product.prodname_codeql %} is hardcoded to analyze only the languages in the matrix. To change the languages you want to analyze, edit the value of the matrix variable. You can remove a language to prevent it being analyzed or you can add a language that was not present in the repository when {% data variables.product.prodname_code_scanning %} was configured. For example, if the repository initially only contained JavaScript when {% data variables.product.prodname_code_scanning %} was configured, and you later added Python code, you will need to add `python` to the matrix.
207207

208-
```yaml
208+
```yaml{:copy}
209209
jobs:
210210
analyze:
211211
name: Analyze
@@ -218,7 +218,7 @@ jobs:
218218

219219
If your workflow does not contain a matrix called `language`, then {% data variables.product.prodname_codeql %} is configured to run analysis sequentially. If you don't specify languages in the workflow, {% data variables.product.prodname_codeql %} automatically detects, and attempts to analyze, any supported languages in the repository. If you want to choose which languages to analyze, without using a matrix, you can use the `languages` parameter under the `init` action.
220220

221-
```yaml
221+
```yaml{:copy}
222222
- uses: {% data reusables.actions.action-codeql-action-init %}
223223
with:
224224
languages: cpp, csharp, python
@@ -234,7 +234,7 @@ For GitHub-hosted runners that use Linux only, the {% data variables.code-scanni
234234

235235
Alternatively, you can install Python dependencies manually on any operating system. You will need to add `setup-python-dependencies` and set it to `false`, as well as set `CODEQL_PYTHON` to the Python executable that includes the dependencies, as shown in this workflow extract:
236236

237-
```yaml
237+
```yaml{:copy}
238238
jobs:
239239
CodeQL-Build:
240240
runs-on: ubuntu-latest
@@ -274,7 +274,7 @@ Use `category` to distinguish between multiple analyses for the same tool and co
274274

275275
This parameter is particularly useful if you work with monorepos and have multiple SARIF files for different components of the monorepo.
276276

277-
``` yaml
277+
``` yaml{:copy}
278278
- name: Perform CodeQL Analysis
279279
uses: {% data reusables.actions.action-codeql-action-analyze %}
280280
with:
@@ -315,7 +315,7 @@ In the example below, `scope` is the organization or personal account that publi
315315
- The latest version of `pack3` that is compatible with version 3.2.1 is downloaded and all queries are run.
316316
- Version 4.5.6 of `pack4` is downloaded and only the queries found in `path/to/queries` are run.
317317

318-
``` yaml
318+
``` yaml{:copy}
319319
- uses: {% data reusables.actions.action-codeql-action-init %}
320320
with:
321321
# Comma-separated list of packs to download
@@ -341,7 +341,7 @@ For more information about pack compatibility, see "[About {% data variables.pro
341341

342342
If your workflow uses packs that are published on a {% data variables.product.prodname_ghe_server %} installation, you need to tell your workflow where to find them. You can do this by using the `registries` input of the {% data reusables.actions.action-codeql-action-init %} action. This input accepts a list of `url`, `packages`, and `token` properties as shown below.
343343

344-
```
344+
```yaml{:copy}
345345
- uses: {% data reusables.actions.action-codeql-action-init %}
346346
with:
347347
registries: {% raw %}|
@@ -373,7 +373,7 @@ Notice the `|` after the `registries` property name. This is important since {%
373373
{% endif %}
374374
To add one or more queries, add a `with: queries:` entry within the `uses: {% data reusables.actions.action-codeql-action-init %}` section of the workflow. If the queries are in a private repository, use the `external-repository-token` parameter to specify a token that has access to checkout the private repository.
375375

376-
``` yaml
376+
``` yaml{:copy}
377377
- uses: {% data reusables.actions.action-codeql-action-init %}
378378
with:
379379
queries: COMMA-SEPARATED LIST OF PATHS
@@ -393,7 +393,7 @@ If you also use a configuration file for custom settings, any additional {% ifve
393393

394394
In the following example, the `+` symbol ensures that the specified additional {% ifversion codeql-packs %}packs and {% endif %}queries are used together with any specified in the referenced configuration file.
395395

396-
``` yaml
396+
``` yaml{:copy}
397397
- uses: {% data reusables.actions.action-codeql-action-init %}
398398
with:
399399
config-file: ./.github/codeql/codeql-config.yml
@@ -409,7 +409,7 @@ A custom configuration file is an alternative way to specify additional {% ifver
409409

410410
In the workflow file, use the `config-file` parameter of the `init` action to specify the path to the configuration file you want to use. This example loads the configuration file _./.github/codeql/codeql-config.yml_.
411411

412-
``` yaml
412+
``` yaml{:copy}
413413
- uses: {% data reusables.actions.action-codeql-action-init %}
414414
with:
415415
config-file: ./.github/codeql/codeql-config.yml
@@ -419,7 +419,7 @@ In the workflow file, use the `config-file` parameter of the `init` action to sp
419419

420420
If the configuration file is located in an external private repository, use the `external-repository-token` parameter of the `init` action to specify a token that has access to the private repository.
421421

422-
```yaml
422+
```yaml{:copy}
423423
- uses: {% data reusables.actions.action-codeql-action-init %}
424424
with:
425425
external-repository-token: {% raw %}${{ secrets.ACCESS_TOKEN }}{% endraw %}
@@ -435,7 +435,7 @@ The settings in the configuration file are written in YAML format.
435435
You specify {% data variables.product.prodname_codeql %} query packs in an array. Note that the format is different from the format used by the workflow file.
436436

437437
{% raw %}
438-
``` yaml
438+
``` yaml{:copy}
439439
packs:
440440
# Use the latest version of 'pack1' published by 'scope'
441441
- scope/pack1
@@ -457,7 +457,7 @@ The full format for specifying a query pack is `scope/name[@version][:path]`. Bo
457457
If you have a workflow that generates more than one {% data variables.product.prodname_codeql %} database, you can specify any {% data variables.product.prodname_codeql %} query packs to run in a custom configuration file using a nested map of packs.
458458

459459
{% raw %}
460-
``` yaml
460+
``` yaml{:copy}
461461
packs:
462462
# Use these packs for JavaScript and TypeScript analysis
463463
javascript:
@@ -475,7 +475,7 @@ packs:
475475

476476
You specify additional queries in a `queries` array. Each element of the array contains a `uses` parameter with a value that identifies a single query file, a directory containing query files, or a query suite definition file.
477477

478-
``` yaml
478+
``` yaml{:copy}
479479
queries:
480480
- uses: ./my-basic-queries/example-query.ql
481481
- uses: ./my-advanced-queries
@@ -500,7 +500,7 @@ This is useful if you want to exclude, for example:
500500

501501
You can use `exclude` filters similar to those in the configuration file below to exclude queries that you want to remove from the default analysis. In the example of configuration file below, both the `js/redundant-assignment` and the `js/useless-assignment-to-local` queries are excluded from analysis.
502502

503-
```yaml
503+
```yaml{:copy}
504504
query-filters:
505505
- exclude:
506506
id: js/redundant-assignment
@@ -527,7 +527,7 @@ For more information about using `exclude` and `include` filters in your custom
527527

528528
For the interpreted languages that {% data variables.product.prodname_codeql %} supports (Python{% ifversion fpt or ghes or ghae > 3.3 %}, Ruby{% endif %} and JavaScript/TypeScript), you can restrict {% data variables.product.prodname_code_scanning %} to files in specific directories by adding a `paths` array to the configuration file. You can exclude the files in specific directories from analysis by adding a `paths-ignore` array.
529529

530-
``` yaml
530+
``` yaml{:copy}
531531
paths:
532532
- src
533533
paths-ignore:

0 commit comments

Comments
 (0)