Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e4cab7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into mathiasvp/replace-ast-with-ir-use-usedataflow
2 parents 349c5cd + 92ee0aa commit 9e4cab7

83 files changed

Lines changed: 877 additions & 1637 deletions

File tree

Some content is hidden

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

.github/actions/cache-query-compilation/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,18 @@ runs:
2626
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
2727
- name: Read CodeQL query compilation - PR
2828
if: ${{ github.event_name == 'pull_request' }}
29-
uses: actions/cache@v3
29+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
3030
with:
3131
path: '**/.cache'
32+
read-only: true
3233
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }} # deliberately not using the `compile-compile-main` keys here.
3334
restore-keys: |
3435
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
3536
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-
3637
codeql-compile-${{ inputs.key }}-main-
3738
- name: Fill CodeQL query compilation cache - main
3839
if: ${{ github.event_name != 'pull_request' }}
39-
uses: actions/cache@v3
40+
uses: erik-krogh/actions-cache@a88d0603fe5fb5606db9f002dfcadeb32b5f84c6
4041
with:
4142
path: '**/.cache'
4243
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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 }}

.github/workflows/ruby-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
key: ruby-build
9999
- name: Build Query Pack
100100
run: |
101+
rm -rf target/packs
101102
codeql pack create ../shared/ssa --output target/packs
102103
codeql pack create ../misc/suite-helpers --output target/packs
103104
codeql pack create ../shared/regex --output target/packs

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
# It's useful (though not required) to be able to unpack codeql in the ql checkout itself
2828
/codeql/
2929

30-
csharp/extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
31-
3230
# Avoid committing cached package components
3331
.codeql
3432

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/javascript/ @github/codeql-javascript
66
/python/ @github/codeql-python
77
/ruby/ @github/codeql-ruby
8-
/swift/ @github/codeql-c
8+
/swift/ @github/codeql-swift
99
/java/kotlin-extractor/ @github/codeql-kotlin
1010
/java/kotlin-explorer/ @github/codeql-kotlin
1111

@@ -45,4 +45,4 @@ WORKSPACE.bazel @github/codeql-ci-reviewers
4545
/.github/workflows/js-ml-tests.yml @github/codeql-ml-powered-queries-reviewers
4646
/.github/workflows/ql-for-ql-* @github/codeql-ql-for-ql-reviewers
4747
/.github/workflows/ruby-* @github/codeql-ruby
48-
/.github/workflows/swift.yml @github/codeql-c
48+
/.github/workflows/swift.yml @github/codeql-swift

csharp/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ csharp.log
1111
*.tlog
1212
.vs
1313
*.user
14-
.vscode/launch.json
14+
.vscode/launch.json
15+
16+
extractor/Semmle.Extraction.CSharp.Driver/Properties/launchSettings.json
17+
extractor-pack
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Build C# CodeQL pack
2+
description: Builds the C# CodeQL pack
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Setup dotnet
7+
uses: actions/setup-dotnet@v3
8+
with:
9+
dotnet-version: 6.0.202
10+
- name: Build Extractor
11+
shell: bash
12+
run: scripts/create-extractor-pack.sh
13+
working-directory: csharp

csharp/ql/lib/semmle/code/csharp/controlflow/internal/Completion.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ abstract class Completion extends TCompletion {
103103
* otherwise it is a normal non-Boolean completion.
104104
*/
105105
predicate isValidFor(ControlFlowElement cfe) {
106-
cfe instanceof NonReturningCall and
107106
this = cfe.(NonReturningCall).getACompletion()
108107
or
109108
this = TThrowCompletion(cfe.(TriedControlFlowElement).getAThrownException())

csharp/ql/src/Bad Practices/Magic Constants/MagicConstants.qll

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ private predicate trivialPositiveIntValue(string s) {
1010
s =
1111
[
1212
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16",
13-
"17", "18", "19", "20", "16", "32", "64", "128", "256", "512", "1024", "2048", "4096",
14-
"16384", "32768", "65536", "1048576", "2147483648", "4294967296", "15", "31", "63", "127",
15-
"255", "511", "1023", "2047", "4095", "16383", "32767", "65535", "1048577", "2147483647",
16-
"4294967295", "0x00000001", "0x00000002", "0x00000004", "0x00000008", "0x00000010",
17-
"0x00000020", "0x00000040", "0x00000080", "0x00000100", "0x00000200", "0x00000400",
18-
"0x00000800", "0x00001000", "0x00002000", "0x00004000", "0x00008000", "0x00010000",
19-
"0x00020000", "0x00040000", "0x00080000", "0x00100000", "0x00200000", "0x00400000",
20-
"0x00800000", "0x01000000", "0x02000000", "0x04000000", "0x08000000", "0x10000000",
21-
"0x20000000", "0x40000000", "0x80000000", "0x00000001", "0x00000003", "0x00000007",
22-
"0x0000000f", "0x0000001f", "0x0000003f", "0x0000007f", "0x000000ff", "0x000001ff",
23-
"0x000003ff", "0x000007ff", "0x00000fff", "0x00001fff", "0x00003fff", "0x00007fff",
24-
"0x0000ffff", "0x0001ffff", "0x0003ffff", "0x0007ffff", "0x000fffff", "0x001fffff",
25-
"0x003fffff", "0x007fffff", "0x00ffffff", "0x01ffffff", "0x03ffffff", "0x07ffffff",
26-
"0x0fffffff", "0x1fffffff", "0x3fffffff", "0x7fffffff", "0xffffffff", "0x0001", "0x0002",
27-
"0x0004", "0x0008", "0x0010", "0x0020", "0x0040", "0x0080", "0x0100", "0x0200", "0x0400",
28-
"0x0800", "0x1000", "0x2000", "0x4000", "0x8000", "0x0001", "0x0003", "0x0007", "0x000f",
29-
"0x001f", "0x003f", "0x007f", "0x00ff", "0x01ff", "0x03ff", "0x07ff", "0x0fff", "0x1fff",
30-
"0x3fff", "0x7fff", "0xffff", "0x01", "0x02", "0x04", "0x08", "0x10", "0x20", "0x40", "0x80",
31-
"0x01", "0x03", "0x07", "0x0f", "0x1f", "0x3f", "0x7f", "0xff", "0x00", "10", "100", "1000",
32-
"10000", "100000", "1000000", "10000000", "100000000", "1000000000"
13+
"17", "18", "19", "20", "32", "64", "128", "256", "512", "1024", "2048", "4096", "16384",
14+
"32768", "65536", "1048576", "2147483648", "4294967296", "31", "63", "127", "255", "511",
15+
"1023", "2047", "4095", "16383", "32767", "65535", "1048577", "2147483647", "4294967295",
16+
"0x00000001", "0x00000002", "0x00000004", "0x00000008", "0x00000010", "0x00000020",
17+
"0x00000040", "0x00000080", "0x00000100", "0x00000200", "0x00000400", "0x00000800",
18+
"0x00001000", "0x00002000", "0x00004000", "0x00008000", "0x00010000", "0x00020000",
19+
"0x00040000", "0x00080000", "0x00100000", "0x00200000", "0x00400000", "0x00800000",
20+
"0x01000000", "0x02000000", "0x04000000", "0x08000000", "0x10000000", "0x20000000",
21+
"0x40000000", "0x80000000", "0x00000003", "0x00000007", "0x0000000f", "0x0000001f",
22+
"0x0000003f", "0x0000007f", "0x000000ff", "0x000001ff", "0x000003ff", "0x000007ff",
23+
"0x00000fff", "0x00001fff", "0x00003fff", "0x00007fff", "0x0000ffff", "0x0001ffff",
24+
"0x0003ffff", "0x0007ffff", "0x000fffff", "0x001fffff", "0x003fffff", "0x007fffff",
25+
"0x00ffffff", "0x01ffffff", "0x03ffffff", "0x07ffffff", "0x0fffffff", "0x1fffffff",
26+
"0x3fffffff", "0x7fffffff", "0xffffffff", "0x0001", "0x0002", "0x0004", "0x0008", "0x0010",
27+
"0x0020", "0x0040", "0x0080", "0x0100", "0x0200", "0x0400", "0x0800", "0x1000", "0x2000",
28+
"0x4000", "0x8000", "0x0003", "0x0007", "0x000f", "0x001f", "0x003f", "0x007f", "0x00ff",
29+
"0x01ff", "0x03ff", "0x07ff", "0x0fff", "0x1fff", "0x3fff", "0x7fff", "0xffff", "0x02",
30+
"0x04", "0x08", "0x10", "0x20", "0x40", "0x80", "0x01", "0x03", "0x07", "0x0f", "0x1f",
31+
"0x3f", "0x7f", "0xff", "0x00", "100", "1000", "10000", "100000", "1000000", "10000000",
32+
"100000000", "1000000000"
3333
]
3434
}
3535

csharp/ql/test/library-tests/assemblies/assemblies.ql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ where
3434
f.hasName("f") and
3535
g.hasName("g") and
3636
a.getDeclaringType() = class1 and
37-
a.getDeclaringType() = class1 and
3837
b.getDeclaringType() = class1 and
3938
c.getDeclaringType() = class1 and
4039
not exists(c.getParameter(0).getType().(KnownType)) and

0 commit comments

Comments
 (0)