Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new configuration Parameter #1590

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,7 @@

## [UNRELEASED]

No user facing changes.
- Add `config` parameter to the `init` action https://github.com/github/codeql-action/pull/1590
tgrall marked this conversation as resolved.
Show resolved Hide resolved

## 2.2.9 - 27 Mar 2023

Expand Down
56 changes: 56 additions & 0 deletions README.md
Expand Up @@ -135,6 +135,62 @@ By default, this will override any queries specified in a config file. If you wi
queries: +<local-or-remote-query>,<another-query>
```

### Configuration
tgrall marked this conversation as resolved.
Show resolved Hide resolved


Use the `config` parameter of the `init` action to enable a workflow based configuration. The value of `configuration` should be compliant with 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)."
tgrall marked this conversation as resolved.
Show resolved Hide resolved


- **Complete Configuration**

```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: |
disable-default-queries: true
queries:
- uses: security-extended
- uses: security-and-quality
query-filters:
- include:
tags: /cwe-020/
```


- **Actions Variables**

You can use actions or environment variables to use dynamic configuration.
tgrall marked this conversation as resolved.
Show resolved Hide resolved

```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: |
${{vars.CODEQL_CONF}}
tgrall marked this conversation as resolved.
Show resolved Hide resolved
```


where `vars.CODEQL_CONF` references a [Action Variables](https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows) with the following content, that will only execute the queries related to the [CWE-020](https://cwe.mitre.org/data/definitions/20.html).
tgrall marked this conversation as resolved.
Show resolved Hide resolved

- **Input Parameters**

Use workflow input parameter:

```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config: |
disable-default-queries: true
queries:
- uses: security-extended
- uses: security-and-quality
query-filters:
- include:
tags: /${{ github.event.inputs.codeql-include-tags }}/
```

tgrall marked this conversation as resolved.
Show resolved Hide resolved
## Troubleshooting

Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
Expand Down
3 changes: 3 additions & 0 deletions init/action.yml
Expand Up @@ -44,6 +44,9 @@ inputs:
db-location:
description: Path where CodeQL databases should be created. If not specified, a temporary directory will be used.
required: false
config:
description: Configuration passed as YAML object using the same format as the config-file. This takes precedence over the config-file parameter.
tgrall marked this conversation as resolved.
Show resolved Hide resolved
required: false
queries:
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.
required: false
Expand Down
9 changes: 8 additions & 1 deletion lib/config-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/config-utils.js.map

Large diffs are not rendered by default.

86 changes: 64 additions & 22 deletions lib/config-utils.test.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/config-utils.test.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.