Skip to content

Commit 907ebb7

Browse files
authored
Merge branch 'main' into json-log
2 parents 2b9bc3c + 6a8c570 commit 907ebb7

File tree

1,341 files changed

+261160
-22399
lines changed

Some content is hidden

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

1,341 files changed

+261160
-22399
lines changed

.github/actions/fetch-codeql/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ runs:
1919
gh extension install github/gh-codeql
2020
gh codeql set-channel "$CHANNEL"
2121
gh codeql version
22+
printf "CODEQL_FETCHED_CODEQL_PATH=" >> "${GITHUB_ENV}"
23+
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_ENV}"
2224
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}"

.github/actions/os-version/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: OS Version
2+
description: Get OS version.
3+
4+
outputs:
5+
version:
6+
description: "OS version"
7+
value: ${{ steps.version.outputs.version }}
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- if: runner.os == 'Linux'
13+
shell: bash
14+
run: |
15+
. /etc/os-release
16+
echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV
17+
- if: runner.os == 'Windows'
18+
shell: powershell
19+
run: |
20+
$objects = systeminfo.exe /FO CSV | ConvertFrom-Csv
21+
"VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV
22+
- if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV
26+
- name: Emit OS version
27+
id: version
28+
shell: bash
29+
run: |
30+
echo "$VERSION"
31+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
32+

.github/dependabot.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
version: 2
22
updates:
33
- package-ecosystem: "cargo"
4-
directory: "ruby/node-types"
5-
schedule:
6-
interval: "daily"
7-
- package-ecosystem: "cargo"
8-
directory: "ruby/generator"
9-
schedule:
10-
interval: "daily"
11-
- package-ecosystem: "cargo"
12-
directory: "ruby/extractor"
13-
schedule:
14-
interval: "daily"
15-
- package-ecosystem: "cargo"
16-
directory: "ruby/autobuilder"
4+
directory: "ruby"
175
schedule:
186
interval: "daily"
197

.github/workflows/mad_modelDiff.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
branches:
1212
- main
1313
paths:
14-
- "java/ql/src/utils/model-generator/**/*.*"
14+
- "java/ql/src/utils/modelgenerator/**/*.*"
1515
- ".github/workflows/mad_modelDiff.yml"
1616

1717
permissions:
@@ -40,12 +40,12 @@ jobs:
4040
- name: Download database
4141
env:
4242
SLUG: ${{ matrix.slug }}
43+
GH_TOKEN: ${{ github.token }}
4344
run: |
4445
set -x
4546
mkdir lib-dbs
4647
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
47-
projectId=`curl -s https://lgtm.com/api/v1.0/projects/g/${SLUG} | jq .id`
48-
curl -L "https://lgtm.com/api/v1.0/snapshots/$projectId/java" -o "$SHORTNAME.zip"
48+
gh api -H "Accept: application/zip" "/repos/${SLUG}/code-scanning/codeql/databases/java" > "$SHORTNAME.zip"
4949
unzip -q -d "${SHORTNAME}-db" "${SHORTNAME}.zip"
5050
mkdir "lib-dbs/$SHORTNAME/"
5151
mv "${SHORTNAME}-db/"$(ls -1 "${SHORTNAME}"-db)/* "lib-dbs/${SHORTNAME}/"
@@ -61,7 +61,7 @@ jobs:
6161
DATABASE=$2
6262
cd codeql-$QL_VARIANT
6363
SHORTNAME=`basename $DATABASE`
64-
python java/ql/src/utils/model-generator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE ${SHORTNAME}.temp.model.yml
64+
python java/ql/src/utils/modelgenerator/GenerateFlowModel.py --with-summaries --with-sinks $DATABASE ${SHORTNAME}.temp.model.yml
6565
mv java/ql/lib/ext/generated/${SHORTNAME}.temp.model.yml $MODELS/${SHORTNAME}Generated_${QL_VARIANT}.model.yml
6666
cd ..
6767
}
@@ -100,4 +100,6 @@ jobs:
100100
with:
101101
name: diffs
102102
path: tmp-models/*.html
103+
# An html file is only produced if the generated models differ.
104+
if-no-files-found: ignore
103105
retention-days: 20

.github/workflows/mad_regenerate-models.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
SLUG: ${{ matrix.slug }}
5151
run: |
5252
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
53-
java/ql/src/utils/model-generator/RegenerateModels.py "${SLUG}" dbs/${SHORTNAME}
53+
java/ql/src/utils/modelgenerator/RegenerateModels.py "${SLUG}" dbs/${SHORTNAME}
5454
- name: Stage changes
5555
run: |
5656
find java -name "*.model.yml" -print0 | xargs -0 git add

.github/workflows/ql-for-ql-build.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: ./.github/actions/find-latest-bundle
2828
- name: Find codeql
2929
id: find-codeql
30-
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
30+
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
3131
with:
3232
languages: javascript # does not matter
3333
tools: ${{ steps.find-latest-bundle.outputs.url }}
@@ -38,12 +38,14 @@ jobs:
3838
shell: bash
3939
env:
4040
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
41+
- uses: ./.github/actions/os-version
42+
id: os_version
4143
- name: Cache entire pack
4244
id: cache-pack
4345
uses: actions/cache@v3
4446
with:
4547
path: ${{ runner.temp }}/pack
46-
key: ${{ runner.os }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
48+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-pack-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}-${{ hashFiles('ql/**/*.ql*') }}-${{ hashFiles('ql/**/qlpack.yml') }}-${{ hashFiles('ql/ql/src/ql.dbscheme*') }}-${{ steps.get-codeql-version.outputs.version }}--${{ hashFiles('.github/workflows/ql-for-ql-build.yml') }}
4749
- name: Cache queries
4850
if: steps.cache-pack.outputs.cache-hit != 'true'
4951
id: cache-queries
@@ -77,7 +79,7 @@ jobs:
7779
ql/target/release/ql-autobuilder.exe
7880
ql/target/release/ql-extractor
7981
ql/target/release/ql-extractor.exe
80-
key: ${{ runner.os }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
82+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
8183
- name: Cache cargo
8284
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
8385
uses: actions/cache@v3
@@ -86,7 +88,7 @@ jobs:
8688
~/.cargo/registry
8789
~/.cargo/git
8890
ql/target
89-
key: ${{ runner.os }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
91+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
9092
- name: Check formatting
9193
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
9294
run: cd ql; cargo fmt --all -- --check
@@ -137,20 +139,20 @@ jobs:
137139
env:
138140
CONF: ./ql-for-ql-config.yml
139141
- name: Initialize CodeQL
140-
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
142+
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
141143
with:
142144
languages: ql
143145
db-location: ${{ runner.temp }}/db
144146
config-file: ./ql-for-ql-config.yml
145147
tools: ${{ steps.find-latest-bundle.outputs.url }}
146-
- name: Move pack cache
148+
- name: Move pack queries
147149
run: |
148-
cp -r ${PACK}/.cache ql/ql/src/.cache
150+
cp -r ${PACK}/queries ql/ql/src
149151
env:
150152
PACK: ${{ runner.temp }}/pack
151153

152154
- name: Perform CodeQL Analysis
153-
uses: github/codeql-action/analyze@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
155+
uses: github/codeql-action/analyze@45955cb1830b640e2c1603ad72ad542a49d47b96
154156
with:
155157
category: "ql-for-ql"
156158
- name: Copy sarif file to CWD
@@ -172,4 +174,4 @@ jobs:
172174
with:
173175
name: ql-for-ql-langs
174176
path: split-sarif
175-
retention-days: 1
177+
retention-days: 1

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,18 @@ jobs:
2525

2626
- name: Find codeql
2727
id: find-codeql
28-
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
28+
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2929
with:
3030
languages: javascript # does not matter
31+
- uses: ./.github/actions/os-version
32+
id: os_version
3133
- uses: actions/cache@v3
3234
with:
3335
path: |
3436
~/.cargo/registry
3537
~/.cargo/git
3638
ql/target
37-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
39+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3840
- name: Build Extractor
3941
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
4042
env:

.github/workflows/ql-for-ql-tests.yml

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,84 @@ jobs:
2222
- uses: actions/checkout@v3
2323
- name: Find codeql
2424
id: find-codeql
25-
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
25+
uses: github/codeql-action/init@45955cb1830b640e2c1603ad72ad542a49d47b96
2626
with:
2727
languages: javascript # does not matter
28+
- uses: ./.github/actions/os-version
29+
id: os_version
2830
- uses: actions/cache@v3
2931
with:
3032
path: |
3133
~/.cargo/registry
3234
~/.cargo/git
3335
ql/target
34-
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
36+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
3537
- name: Build extractor
3638
run: |
3739
cd ql;
3840
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
3941
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
42+
- name: Cache compilation cache
43+
id: query-cache
44+
uses: ./.github/actions/cache-query-compilation
45+
with:
46+
key: ql-for-ql-tests
4047
- name: Run QL tests
4148
run: |
42-
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries ql/ql/test
49+
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" ql/ql/test
4350
env:
4451
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
45-
- name: Check QL formatting
52+
53+
other-os:
54+
strategy:
55+
matrix:
56+
os: [macos-latest, windows-latest]
57+
needs: [qltest]
58+
runs-on: ${{ matrix.os }}
59+
steps:
60+
- uses: actions/checkout@v3
61+
- name: Install GNU tar
62+
if: runner.os == 'macOS'
63+
run: |
64+
brew install gnu-tar
65+
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
66+
- name: Find codeql
67+
id: find-codeql
68+
uses: github/codeql-action/init@77a8d2d10c0b403a8b4aadbd223dc489ecd22683
69+
with:
70+
languages: javascript # does not matter
71+
- uses: ./.github/actions/os-version
72+
id: os_version
73+
- uses: actions/cache@v3
74+
with:
75+
path: |
76+
~/.cargo/registry
77+
~/.cargo/git
78+
ql/target
79+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
80+
- name: Build extractor
81+
if: runner.os != 'Windows'
82+
run: |
83+
cd ql;
84+
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
85+
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
86+
- name: Build extractor (Windows)
87+
if: runner.os == 'Windows'
88+
shell: pwsh
4689
run: |
47-
find ql/ql/src "(" -name "*.ql" -or -name "*.qll" ")" -print0 | xargs -0 "${CODEQL}" query format --check-only
90+
cd ql;
91+
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
92+
pwsh ./scripts/create-extractor-pack.ps1
93+
- name: Run a single QL tests - Unix
94+
if: runner.os != 'Windows'
95+
run: |
96+
"${CODEQL}" test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref
4897
env:
4998
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
99+
- name: Run a single QL tests - Windows
100+
if: runner.os == 'Windows'
101+
shell: pwsh
102+
run: |
103+
$Env:PATH += ";$(dirname ${{ steps.find-codeql.outputs.codeql-path }})"
104+
codeql test run --check-databases --search-path "${{ github.workspace }}/ql/extractor-pack" ql/ql/test/queries/style/DeadCode/DeadCode.qlref
105+

.github/workflows/ruby-build.yml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
run: |
4949
brew install gnu-tar
5050
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
51+
- uses: ./.github/actions/os-version
52+
id: os_version
5153
- name: Cache entire extractor
5254
uses: actions/cache@v3
5355
id: cache-extractor
@@ -58,15 +60,15 @@ jobs:
5860
ruby/target/release/ruby-extractor
5961
ruby/target/release/ruby-extractor.exe
6062
ruby/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
61-
key: ${{ runner.os }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
63+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}--${{ hashFiles('ruby/**/*.rs') }}
6264
- uses: actions/cache@v3
6365
if: steps.cache-extractor.outputs.cache-hit != 'true'
6466
with:
6567
path: |
6668
~/.cargo/registry
6769
~/.cargo/git
6870
ruby/target
69-
key: ${{ runner.os }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
71+
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/rust-toolchain.toml', 'ruby/**/Cargo.lock') }}
7072
- name: Check formatting
7173
if: steps.cache-extractor.outputs.cache-hit != 'true'
7274
run: cargo fmt --all -- --check
@@ -203,11 +205,6 @@ jobs:
203205
- name: Fetch CodeQL
204206
uses: ./.github/actions/fetch-codeql
205207

206-
- uses: actions/checkout@v3
207-
with:
208-
repository: Shopify/example-ruby-app
209-
ref: 67a0decc5eb550f3a9228eda53925c3afd40dfe9
210-
211208
- name: Download Ruby bundle
212209
uses: actions/download-artifact@v3
213210
with:
@@ -216,26 +213,15 @@ jobs:
216213
- name: Unzip Ruby bundle
217214
shell: bash
218215
run: unzip -q -d "${{ runner.temp }}/ruby-bundle" "${{ runner.temp }}/codeql-ruby-bundle.zip"
219-
- name: Prepare test files
220-
shell: bash
221-
run: |
222-
echo "import codeql.ruby.AST select count(File f)" > "test.ql"
223-
echo "| 4 |" > "test.expected"
224-
echo 'name: sample-tests
225-
version: 0.0.0
226-
dependencies:
227-
codeql/ruby-all: "*"
228-
extractor: ruby
229-
tests: .
230-
' > qlpack.yml
216+
231217
- name: Run QL test
232218
shell: bash
233219
run: |
234-
codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" .
220+
codeql test run --search-path "${{ runner.temp }}/ruby-bundle" --additional-packs "${{ runner.temp }}/ruby-bundle" ruby/ql/test/library-tests/ast/constants/
235221
- name: Create database
236222
shell: bash
237223
run: |
238-
codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root . ../database
224+
codeql database create --search-path "${{ runner.temp }}/ruby-bundle" --language ruby --source-root ruby/ql/test/library-tests/ast/constants/ ../database
239225
- name: Analyze database
240226
shell: bash
241227
run: |

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
2525

2626
Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose.
2727
- Experimental queries and libraries are stored in the `experimental` subdirectory within each language-specific directory in the [CodeQL repository](https://github.com/github/codeql). For example, experimental Java queries and libraries are stored in `java/ql/src/experimental` and any corresponding tests in `java/ql/test/experimental`.
28+
- Experimental queries need to include `experimental` in their `@tags`
2829
- The structure of an `experimental` subdirectory mirrors the structure of its parent directory.
2930
- Select or create an appropriate directory in `experimental` based on the existing directory structure of `experimental` or its parent directory.
3031

0 commit comments

Comments
 (0)