Skip to content

Commit

Permalink
- Add new configuration Parameter
Browse files Browse the repository at this point in the history
- Write test to check it is read from configuration
- Update documentation
  • Loading branch information
Tugdual Grall committed Mar 18, 2023
1 parent fb75ebd commit ee44252
Show file tree
Hide file tree
Showing 16 changed files with 1,644 additions and 31 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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


Use the `configuration` 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)."


- **Complete Configuration**

```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
configuration: |
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.

```yaml
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
configuration: |
${{vars.CODEQL_CONF}}
```


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).

- **Input Parameters**

Use workflow input parameter:

```yaml
- uses: tgrall/codeql-action/init@query-filter
with:
languages: ${{ matrix.language }}
configuration: |
disable-default-queries: true
queries:
- uses: security-extended
- uses: security-and-quality
query-filters:
- include:
tags: /${{ github.event.inputs.codeql-include-tags }}/
``
## 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
Original file line number Diff line number Diff line change
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
configuration:
description: Configuration passed as YAML object using the same format as the config-file. This takes precedence over the config-file parameter.
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.

Loading

0 comments on commit ee44252

Please sign in to comment.