Skip to content

Commit 1d4b2cc

Browse files
committed
Merge branch 'main' into tiferet/complexity-reduction
2 parents 4580b55 + f375b0c commit 1d4b2cc

File tree

1,308 files changed

+64713
-30694
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,308 files changed

+64713
-30694
lines changed

.github/ISSUE_TEMPLATE/lgtm-com---false-positive.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/ql---general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ assignees: ''
1010
**Description of the issue**
1111

1212
<!-- Please explain briefly what is the problem.
13-
If it is about an LGTM project, please include its URL.-->
13+
If it is about a GitHub project, please include its URL. -->
1414

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: CodeQL false positive
3+
about: Report CodeQL alerts that you think should not have been detected (not applicable, not exploitable, etc.)
4+
title: False positive
5+
labels: false-positive
6+
assignees: ''
7+
8+
---
9+
10+
**Description of the false positive**
11+
12+
<!-- Please explain briefly why you think it shouldn't be included. -->
13+
14+
**Code samples or links to source code**
15+
16+
<!--
17+
For open source code: file links with line numbers on GitHub, for example:
18+
https://github.com/github/codeql/blob/dc440aaee6695deb0d9676b87e06ea984e1b4ae5/javascript/ql/test/query-tests/Security/CWE-078/CommandInjection/exec-sh2.js#L10
19+
20+
For closed source code: (redacted) code samples that illustrate the problem, for example:
21+
22+
```
23+
function execSh(command, options) {
24+
return cp.spawn(getShell(), ["-c", command], options) // <- command line injection
25+
};
26+
```
27+
-->
28+
29+
**URL to the alert on GitHub code scanning (optional)**
30+
31+
<!--
32+
1. Open the project on GitHub.com.
33+
2. Switch to the `Security` tab.
34+
3. Browse to the alert that you would like to report.
35+
4. Copy and paste the page URL here.
36+
-->
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Cache query compilation
2+
description: Caches CodeQL compilation caches - should be run both on PRs and pushes to main.
3+
4+
inputs:
5+
key:
6+
description: 'The cache key to use - should be unique to the workflow'
7+
required: true
8+
9+
outputs:
10+
cache-dir:
11+
description: "The directory where the cache was stored"
12+
value: ${{ steps.fill-compilation-dir.outputs.compdir }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- name: Cache the query compilation caches
18+
uses: ./.github/actions/incremental-cache
19+
with:
20+
path: '**/.cache'
21+
key: codeql-compile-${{ inputs.key }}
22+
- name: Fill compilation cache directory
23+
id: fill-compilation-dir
24+
shell: bash
25+
run: |
26+
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
27+
mkdir -p ${COMBINED_CACHE_DIR}
28+
rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
29+
# copy the contents of the .cache folders into the combined cache folder.
30+
cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
31+
# clean up the .cache folders
32+
rm -rf **/.cache/*
33+
34+
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
35+
env:
36+
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Setup an incremental cache
2+
description: Special cache wrapper to be run on pull requests and pushes, that will try to restore
3+
a cache as close as possible to the merge base
4+
5+
inputs:
6+
path:
7+
description: 'The path to cache'
8+
required: true
9+
key:
10+
description: 'The cache key to use - should be unique to the workflow'
11+
required: true
12+
13+
runs:
14+
using: composite
15+
steps:
16+
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
17+
- name: Calculate merge-base
18+
shell: bash
19+
if: ${{ github.event_name == 'pull_request' }}
20+
env:
21+
BASE_BRANCH: ${{ github.base_ref }}
22+
run: |
23+
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
24+
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
25+
- name: Restore read-only cache (PR)
26+
if: ${{ github.event_name == 'pull_request' }}
27+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
28+
with:
29+
path: ${{ inputs.path }}
30+
read-only: true
31+
key: ${{ inputs.key }}-pr-${{ github.sha }}
32+
restore-keys: |
33+
${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
34+
${{ inputs.key }}-${{ github.base_ref }}-
35+
${{ inputs.key }}-main-
36+
- name: Fill cache (push)
37+
if: ${{ github.event_name != 'pull_request' }}
38+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
39+
with:
40+
path: ${{ inputs.path }}
41+
key: ${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
42+
restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
43+
${{ inputs.key }}-${{ github.ref_name }}-
44+
${{ inputs.key }}-main-

.github/workflows/compile-queries.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,26 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17-
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
18-
- name: Calculate merge-base
19-
if: ${{ github.event_name == 'pull_request' }}
20-
env:
21-
BASE_BRANCH: ${{ github.base_ref }}
22-
run: |
23-
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
24-
echo "merge-base=$MERGE_BASE" >> $GITHUB_ENV
25-
- name: Read CodeQL query compilation - PR
26-
if: ${{ github.event_name == 'pull_request' }}
27-
uses: actions/cache@v3
28-
with:
29-
path: '*/ql/src/.cache'
30-
key: codeql-compile-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
31-
restore-keys: |
32-
codeql-compile-${{ github.base_ref }}-${{ env.merge-base }}
33-
codeql-compile-${{ github.base_ref }}-
34-
codeql-compile-main-
35-
- name: Fill CodeQL query compilation cache - main
36-
if: ${{ github.event_name != 'pull_request' }}
37-
uses: actions/cache@v3
38-
with:
39-
path: '*/ql/src/.cache'
40-
key: codeql-compile-${{ github.ref_name }}-${{ github.sha }} # just fill on main
41-
restore-keys: | # restore from another random commit, to speed up compilation.
42-
codeql-compile-${{ github.ref_name }}-
43-
codeql-compile-main-
4417
- name: Setup CodeQL
4518
uses: ./.github/actions/fetch-codeql
4619
with:
4720
channel: 'release'
21+
- name: Cache compilation cache
22+
id: query-cache
23+
uses: ./.github/actions/cache-query-compilation
24+
with:
25+
key: all-queries
4826
- name: check formatting
4927
run: find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 codeql query format --check-only
5028
- name: compile queries - check-only
5129
# run with --check-only if running in a PR (github.sha != main)
5230
if : ${{ github.event_name == 'pull_request' }}
5331
shell: bash
54-
run: codeql query compile -j0 */ql/src --keep-going --warnings=error --check-only
32+
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
5533
- name: compile queries - full
5634
# do full compile if running on main - this populates the cache
5735
if : ${{ github.event_name != 'pull_request' }}
5836
shell: bash
59-
run: codeql query compile -j0 */ql/src --keep-going --warnings=error
37+
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
38+
env:
39+
COMBINED_CACHE_DIR: ${{ github.workspace }}/compilation-dir

.github/workflows/csharp-qltest.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: "C#: Run QL Tests"
2+
3+
on:
4+
push:
5+
paths:
6+
- "csharp/**"
7+
- "shared/**"
8+
- .github/actions/fetch-codeql/action.yml
9+
- codeql-workspace.yml
10+
branches:
11+
- main
12+
- "rc/*"
13+
pull_request:
14+
paths:
15+
- "csharp/**"
16+
- "shared/**"
17+
- .github/workflows/csharp-qltest.yml
18+
- .github/actions/fetch-codeql/action.yml
19+
- codeql-workspace.yml
20+
branches:
21+
- main
22+
- "rc/*"
23+
24+
defaults:
25+
run:
26+
working-directory: csharp
27+
28+
jobs:
29+
qlupgrade:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: ./.github/actions/fetch-codeql
34+
- name: Check DB upgrade scripts
35+
run: |
36+
echo >empty.trap
37+
codeql dataset import -S ql/lib/upgrades/initial/semmlecode.csharp.dbscheme testdb empty.trap
38+
codeql dataset upgrade testdb --additional-packs ql/lib
39+
diff -q testdb/semmlecode.csharp.dbscheme ql/lib/semmlecode.csharp.dbscheme
40+
- name: Check DB downgrade scripts
41+
run: |
42+
echo >empty.trap
43+
rm -rf testdb; codeql dataset import -S ql/lib/semmlecode.csharp.dbscheme testdb empty.trap
44+
codeql resolve upgrades --format=lines --allow-downgrades --additional-packs downgrades \
45+
--dbscheme=ql/lib/semmlecode.csharp.dbscheme --target-dbscheme=downgrades/initial/semmlecode.csharp.dbscheme |
46+
xargs codeql execute upgrades testdb
47+
diff -q testdb/semmlecode.csharp.dbscheme downgrades/initial/semmlecode.csharp.dbscheme
48+
qltest:
49+
runs-on: ubuntu-latest-xl
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
slice: ["1/2", "2/2"]
54+
steps:
55+
- uses: actions/checkout@v3
56+
- uses: ./.github/actions/fetch-codeql
57+
- uses: ./csharp/actions/create-extractor-pack
58+
- name: Cache compilation cache
59+
id: query-cache
60+
uses: ./.github/actions/cache-query-compilation
61+
with:
62+
key: csharp-qltest-${{ matrix.slice }}
63+
- name: Run QL tests
64+
run: |
65+
CODEQL_PATH=$(gh codeql version --format=json | jq -r .unpackedLocation)
66+
# The legacy ASP extractor is not in this repo, so take the one from the nightly build
67+
mv "$CODEQL_PATH/csharp/tools/extractor-asp.jar" "${{ github.workspace }}/csharp/extractor-pack/tools"
68+
# Safe guard against using the bundled extractor
69+
rm -rf "$CODEQL_PATH/csharp"
70+
codeql test run --threads=0 --ram 52000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/csharp/extractor-pack" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
71+
env:
72+
GITHUB_TOKEN: ${{ github.token }}
73+
unit-tests:
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v3
77+
- name: Setup dotnet
78+
uses: actions/setup-dotnet@v3
79+
with:
80+
dotnet-version: 6.0.202
81+
- name: Extractor unit tests
82+
run: |
83+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/extractor/Semmle.Util.Tests"
84+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/extractor/Semmle.Extraction.Tests"
85+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests"
86+
dotnet test -p:RuntimeFrameworkVersion=6.0.4 "${{ github.workspace }}/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: "Go: Run Tests - Other OS"
2+
on:
3+
pull_request:
4+
paths:
5+
- "go/**"
6+
- "!go/ql/**" # don't run other-os if only ql/ files changed
7+
- .github/workflows/go-tests-other-os.yml
8+
- .github/actions/**
9+
- codeql-workspace.yml
10+
jobs:
11+
test-mac:
12+
name: Test MacOS
13+
runs-on: macos-latest
14+
steps:
15+
- name: Set up Go 1.19
16+
uses: actions/setup-go@v3
17+
with:
18+
go-version: 1.19
19+
id: go
20+
21+
- name: Check out code
22+
uses: actions/checkout@v2
23+
24+
- name: Set up CodeQL CLI
25+
uses: ./.github/actions/fetch-codeql
26+
27+
- name: Enable problem matchers in repository
28+
shell: bash
29+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
30+
31+
- name: Build
32+
run: |
33+
cd go
34+
make
35+
36+
- name: Cache compilation cache
37+
id: query-cache
38+
uses: ./.github/actions/cache-query-compilation
39+
with:
40+
key: go-qltest
41+
- name: Test
42+
run: |
43+
cd go
44+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"
45+
46+
test-win:
47+
name: Test Windows
48+
runs-on: windows-latest-xl
49+
steps:
50+
- name: Set up Go 1.19
51+
uses: actions/setup-go@v3
52+
with:
53+
go-version: 1.19
54+
id: go
55+
56+
- name: Check out code
57+
uses: actions/checkout@v2
58+
59+
- name: Set up CodeQL CLI
60+
uses: ./.github/actions/fetch-codeql
61+
62+
- name: Enable problem matchers in repository
63+
shell: bash
64+
run: 'find .github/problem-matchers -name \*.json -exec echo "::add-matcher::{}" \;'
65+
66+
- name: Build
67+
run: |
68+
cd go
69+
make
70+
71+
- name: Cache compilation cache
72+
id: query-cache
73+
uses: ./.github/actions/cache-query-compilation
74+
with:
75+
key: go-qltest
76+
77+
- name: Test
78+
run: |
79+
cd go
80+
make test cache="${{ steps.query-cache.outputs.cache-dir }}"

0 commit comments

Comments
 (0)