Skip to content

Commit d2f6dfd

Browse files
authored
Merge pull request #1665 from github/aeisenberg/config-param
Add new configuration Parameter
2 parents f31a31c + cba5616 commit d2f6dfd

15 files changed

+402
-55
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## [UNRELEASED]
44

5-
No user facing changes.
5+
- You can now configure CodeQL within your code scanning workflow by passing a `config` input to the `init` Action. [#1590](https://github.com/github/codeql-action/pull/1590)
66

77
## 2.3.2 - 27 Apr 2023
88

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,38 @@ By default, this will override any queries specified in a config file. If you wi
135135
queries: +<local-or-remote-query>,<another-query>
136136
```
137137

138+
### Configuration via `config` input
139+
140+
You can alternatively configure CodeQL using the `config` input to the `init` Action. The value of this input must be a YAML string that follows the configuration file format documented at "[Using a custom configuration file](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#using-a-custom-configuration-file)."
141+
142+
#### Example configuration
143+
144+
```yaml
145+
- uses: github/codeql-action/init@v2
146+
with:
147+
languages: ${{ matrix.language }}
148+
config: |
149+
disable-default-queries: true
150+
queries:
151+
- uses: security-extended
152+
- uses: security-and-quality
153+
query-filters:
154+
- include:
155+
tags: /cwe-020/
156+
```
157+
158+
159+
#### Sharing configuration across multiple repositories
160+
161+
You can use Actions or environment variables to share configuration across multiple repositories and to modify configuration without needing to edit the workflow file. In the following example, `vars.CODEQL_CONF` is an [Actions configuration variable](https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows):
162+
163+
```yaml
164+
- uses: github/codeql-action/init@v2
165+
with:
166+
languages: ${{ matrix.language }}
167+
config: ${{ vars.CODEQL_CONF }}
168+
```
169+
138170
## Troubleshooting
139171

140172
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).

init/action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ inputs:
4444
db-location:
4545
description: Path where CodeQL databases should be created. If not specified, a temporary directory will be used.
4646
required: false
47+
config:
48+
description: Configuration passed as a YAML string in the same format as the config-file input. This takes precedence over the config-file input.
49+
required: false
4750
queries:
4851
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
4952
required: false

lib/config-utils.js

+10-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js

+114-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)