Skip to content

Commit b2175ea

Browse files
authored
Merge branch 'main' into releases
2 parents 34b685a + 7a6a715 commit b2175ea

File tree

70 files changed

+1240
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1240
-497
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Setup CodeQL CLI
2+
description: |
3+
Install a CodeQL CLI or re-use an existing one from the cache and it to the path.
4+
inputs:
5+
codeql-cli-version:
6+
description: |
7+
The version of the CodeQL CLI to be downloaded.
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Cache CodeQL
13+
id: cache-codeql
14+
uses: actions/cache@v4
15+
with:
16+
# A list of files, directories, and wildcard patterns to cache and restore
17+
path: ${{github.workspace}}/codeql_home
18+
# An explicit key for restoring and saving the cache
19+
key: codeql-home-${{ inputs.codeql-cli-version }}
20+
21+
- name: Install CodeQL
22+
if: steps.cache-codeql.outputs.cache-hit != 'true'
23+
shell: bash
24+
env:
25+
GITHUB_TOKEN: ${{ github.token }}
26+
CODEQL_HOME: ${{ github.workspace }}/codeql_home
27+
CODEQL_CLI_VERSION: ${{ inputs.codeql-cli-version }}
28+
run: |
29+
mkdir -p $CODEQL_HOME
30+
echo "Change directory to $CODEQL_HOME"
31+
pushd $CODEQL_HOME
32+
33+
echo "Downloading CodeQL CLI v${CODEQL_CLI_VERSION}."
34+
gh release download "v${CODEQL_CLI_VERSION}" --repo https://github.com/github/codeql-cli-binaries --pattern codeql-linux64.zip
35+
36+
echo "Unzipping CodeQL CLI."
37+
unzip -q codeql-linux64.zip
38+
39+
popd
40+
echo "Done."
41+
42+
- name: Add CodeQL to the PATH
43+
shell: bash
44+
env:
45+
CODEQL_HOME: ${{ github.workspace }}/codeql_home
46+
run: |
47+
echo "Adding CodeQL CLI to the PATH."
48+
echo "$CODEQL_HOME/codeql" >> $GITHUB_PATH

.github/workflows/ci.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches: [ main ]
66
workflow_dispatch:
77

8+
env:
9+
CODEQL_CLI_VERSION: 2.19.3
10+
811
jobs:
912
compile-and-test:
1013
runs-on: ubuntu-latest
@@ -24,23 +27,21 @@ jobs:
2427
filters: |
2528
src:
2629
- '${{ matrix.language }}/**'
30+
- '.github/**'
2731
28-
- name: Initialize CodeQL
32+
- name: Setup CodeQL
2933
if: steps.changes.outputs.src == 'true'
30-
run: |
31-
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
32-
| sort \
33-
| tail -n 1 \
34-
| tr -d '\n')"
35-
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
36-
34+
uses: ./.github/actions/install-codeql
35+
with:
36+
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}
37+
3738
- name: Install Packs
3839
if: steps.changes.outputs.src == 'true'
3940
env:
4041
GITHUB_TOKEN: ${{ github.token }}
42+
CODEQL_CLI_VERSION: ${{ env.CODEQL_CLI_VERSION }}
4143
run: |
42-
gh repo clone github/codeql # to make stubs available for tests
43-
codeql pack download "codeql/${{ matrix.language }}-queries"
44+
gh repo clone github/codeql -- -b codeql-cli-${CODEQL_CLI_VERSION} # to make stubs available for tests
4445
codeql pack install "${{ matrix.language }}/lib"
4546
codeql pack install "${{ matrix.language }}/src"
4647
codeql pack install "${{ matrix.language }}/test"
@@ -171,14 +172,11 @@ jobs:
171172
src:
172173
- '${{ matrix.language }}/ext/**'
173174
174-
- name: Initialize CodeQL
175+
- name: Setup CodeQL
175176
if: steps.changes.outputs.src == 'true'
176-
run: |
177-
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
178-
| sort \
179-
| tail -n 1 \
180-
| tr -d '\n')"
181-
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
177+
uses: ./.github/actions/install-codeql
178+
with:
179+
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}
182180

183181
- name: Install Packs
184182
if: steps.changes.outputs.src == 'true'
@@ -209,14 +207,11 @@ jobs:
209207
src:
210208
- '${{ matrix.language }}/ext-library-sources/**'
211209
212-
- name: Initialize CodeQL
210+
- name: Setup CodeQL
213211
if: steps.changes.outputs.src == 'true'
214-
run: |
215-
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
216-
| sort \
217-
| tail -n 1 \
218-
| tr -d '\n')"
219-
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
212+
uses: ./.github/actions/install-codeql
213+
with:
214+
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}
220215

221216
- name: Install CodeQL
222217
if: steps.changes.outputs.src == 'true'
@@ -240,14 +235,11 @@ jobs:
240235
src:
241236
- 'configs/**'
242237
243-
- name: Initialize CodeQL
238+
- name: Setup CodeQL
244239
if: steps.changes.outputs.src == 'true'
245-
run: |
246-
VERSION="$(find "${{ runner.tool_cache }}/CodeQL/" -maxdepth 1 -mindepth 1 -type d -print \
247-
| sort \
248-
| tail -n 1 \
249-
| tr -d '\n')"
250-
echo "$VERSION/x64/codeql" >> $GITHUB_PATH
240+
uses: ./.github/actions/install-codeql
241+
with:
242+
codeql-cli-version: ${{ env.CODEQL_CLI_VERSION }}
251243

252244
- name: "Check Configurations"
253245
if: steps.changes.outputs.src == 'true'

CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Contributing to CodeQL Community Packs
2+
3+
We welcome contributions to our CodeQL Community Packs libraries and queries. Got an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
4+
5+
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/codeql-queries) on [codeql.github.com](https://codeql.github.com).
6+
7+
## Change notes
8+
9+
Any nontrivial user-visible change to a query pack or library pack should have a change note. For details on how to add a change note for your change, see [this guide](docs/change-notes.md).
10+
11+
## Submitting a new query
12+
13+
If you have an idea for a query that you would like to share with other CodeQL users, please open a pull request to add it to this repository. New queries start out in a `<language>/ql/src/` directory, to which they can be merged when they meet the following requirements.
14+
15+
1. **Directory structure**
16+
17+
There are eight language-specific query directories in this repository:
18+
19+
* C/C++: `cpp/ql/src`
20+
* C#: `csharp/ql/src`
21+
* Go: `go/ql/src`
22+
* Java/Kotlin: `java/ql/src`
23+
* JavaScript: `javascript/ql/src`
24+
* Python: `python/ql/src`
25+
* Ruby: `ruby/ql/src`
26+
* Swift: `swift/ql/src`
27+
28+
Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose.
29+
30+
2. **Query metadata**
31+
32+
- The query `@id` must conform to all the requirements in the [guide on query metadata](docs/query-metadata-style-guide.md#query-id-id). In particular, it must not clash with any other queries in the repository, and it must start with the appropriate language-specific prefix.
33+
- The query must have a `@name` and `@description` to explain its purpose.
34+
- The query must have a `@kind` and `@problem.severity` as required by CodeQL tools.
35+
36+
For details, see the [guide on query metadata](docs/query-metadata-style-guide.md).
37+
38+
Make sure the `select` statement is compatible with the query `@kind`. See [About CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/about-codeql-queries/#select-clause) on codeql.github.com.
39+
40+
3. **Formatting**
41+
42+
- The queries and libraries must be autoformatted, for example using the "Format Document" command in [CodeQL for Visual Studio Code](https://docs.github.com/en/code-security/codeql-for-vs-code/).
43+
44+
If you prefer, you can either:
45+
1. install the [pre-commit framework](https://pre-commit.com/) and install the configured hooks on this repo via `pre-commit install`, or
46+
2. use this [pre-commit hook](misc/scripts/pre-commit) that automatically checks whether your files are correctly formatted.
47+
48+
See the [pre-commit hook installation guide](docs/pre-commit-hook-setup.md) for instructions on the two approaches.
49+
50+
4. **Compilation**
51+
52+
- Compilation of the query and any associated libraries and tests must be resilient to future development of the [supported](docs/supported-queries.md) libraries. This means that the functionality cannot use internal libraries, cannot depend on the output of `getAQlClass`, and cannot make use of regexp matching on `toString`.
53+
- The query and any associated libraries and tests must not cause any compiler warnings to be emitted (such as use of deprecated functionality or missing `override` annotations).
54+
55+
5. **Results**
56+
57+
- The query must have at least one true positive result on some revision of a real project.
58+
59+
6. **Query help files and unit tests**
60+
61+
- Query help (`.qhelp`) files and unit tests are optional (but strongly encouraged!) for queries. For more information about contributing query help files and unit tests, see [Supported CodeQL queries and libraries](docs/supported-queries.md).
62+
63+
Queries and libraries may not be actively maintained as the supported libraries evolve. They may also be changed in backwards-incompatible ways or may be removed entirely in the future without deprecation warnings.
64+
65+
After the query is merged, we welcome pull requests to improve it.
66+
67+
## Using your personal data
68+
69+
If you contribute to this project, we will record your name and email address (as provided by you with your contributions) as part of the code repositories, which are public. We might also use this information to contact you in relation to your contributions, as well as in the normal course of software development. We also store records of CLA agreements signed in the past, but no longer require contributors to sign a CLA. Under GDPR legislation, we do this on the basis of our legitimate interest in creating the CodeQL product.
70+
71+
Please do get in touch ([email protected]) if you have any questions about this or our data protection policies.

cpp/lib/codeql-pack.lock.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.2
5+
version: 2.1.0
66
codeql/dataflow:
7-
version: 0.0.3
7+
version: 1.1.5
8+
codeql/mad:
9+
version: 1.0.11
10+
codeql/rangeanalysis:
11+
version: 1.0.11
812
codeql/ssa:
9-
version: 0.1.4
13+
version: 1.0.11
1014
codeql/tutorial:
11-
version: 0.1.4
15+
version: 1.0.11
16+
codeql/typeflow:
17+
version: 1.0.11
18+
codeql/typetracking:
19+
version: 1.0.11
1220
codeql/util:
13-
version: 0.1.4
21+
version: 1.0.11
22+
codeql/xml:
23+
version: 1.0.11
1424
compiled: false

cpp/src/codeql-pack.lock.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.2
5+
version: 2.1.0
66
codeql/cpp-queries:
7-
version: 0.7.4
7+
version: 1.2.6
88
codeql/dataflow:
9-
version: 0.0.3
9+
version: 1.1.5
10+
codeql/mad:
11+
version: 1.0.11
12+
codeql/rangeanalysis:
13+
version: 1.0.11
1014
codeql/ssa:
11-
version: 0.1.4
15+
version: 1.0.11
1216
codeql/suite-helpers:
13-
version: 0.6.4
17+
version: 1.0.11
1418
codeql/tutorial:
15-
version: 0.1.4
19+
version: 1.0.11
20+
codeql/typeflow:
21+
version: 1.0.11
22+
codeql/typetracking:
23+
version: 1.0.11
1624
codeql/util:
17-
version: 0.1.4
25+
version: 1.0.11
26+
codeql/xml:
27+
version: 1.0.11
1828
compiled: false

cpp/test/codeql-pack.lock.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,27 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.2
5+
version: 2.1.0
66
codeql/cpp-queries:
7-
version: 0.7.4
7+
version: 1.2.6
88
codeql/dataflow:
9-
version: 0.0.3
9+
version: 1.1.5
10+
codeql/mad:
11+
version: 1.0.11
12+
codeql/rangeanalysis:
13+
version: 1.0.11
1014
codeql/ssa:
11-
version: 0.1.4
15+
version: 1.0.11
1216
codeql/suite-helpers:
13-
version: 0.6.4
17+
version: 1.0.11
1418
codeql/tutorial:
15-
version: 0.1.4
19+
version: 1.0.11
20+
codeql/typeflow:
21+
version: 1.0.11
22+
codeql/typetracking:
23+
version: 1.0.11
1624
codeql/util:
17-
version: 0.1.4
25+
version: 1.0.11
26+
codeql/xml:
27+
version: 1.0.11
1828
compiled: false

csharp/lib/codeql-pack.lock.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/controlflow:
5-
version: 1.0.10
5+
version: 1.0.11
66
codeql/csharp-all:
7-
version: 3.0.1
7+
version: 3.1.0
88
codeql/dataflow:
9-
version: 1.1.4
9+
version: 1.1.5
1010
codeql/mad:
11-
version: 1.0.10
11+
version: 1.0.11
1212
codeql/ssa:
13-
version: 1.0.10
13+
version: 1.0.11
1414
codeql/threat-models:
15-
version: 1.0.10
15+
version: 1.0.11
1616
codeql/tutorial:
17-
version: 1.0.10
17+
version: 1.0.11
1818
codeql/typetracking:
19-
version: 1.0.10
19+
version: 1.0.11
2020
codeql/util:
21-
version: 1.0.10
21+
version: 1.0.11
2222
codeql/xml:
23-
version: 1.0.10
23+
version: 1.0.11
2424
compiled: false

csharp/src/codeql-pack.lock.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/controlflow:
5-
version: 1.0.10
5+
version: 1.0.11
66
codeql/csharp-all:
7-
version: 3.0.1
7+
version: 3.1.0
88
codeql/csharp-queries:
9-
version: 1.0.10
9+
version: 1.0.11
1010
codeql/dataflow:
11-
version: 1.1.4
11+
version: 1.1.5
1212
codeql/mad:
13-
version: 1.0.10
13+
version: 1.0.11
1414
codeql/ssa:
15-
version: 1.0.10
15+
version: 1.0.11
1616
codeql/suite-helpers:
17-
version: 1.0.10
17+
version: 1.0.11
1818
codeql/threat-models:
19-
version: 1.0.10
19+
version: 1.0.11
2020
codeql/tutorial:
21-
version: 1.0.10
21+
version: 1.0.11
2222
codeql/typetracking:
23-
version: 1.0.10
23+
version: 1.0.11
2424
codeql/util:
25-
version: 1.0.10
25+
version: 1.0.11
2626
codeql/xml:
27-
version: 1.0.10
27+
version: 1.0.11
2828
compiled: false

0 commit comments

Comments
 (0)