Skip to content

Commit 23144f5

Browse files
committed
Merge branch 'main' into call-graph-code
2 parents db114bb + 13c7c84 commit 23144f5

File tree

377 files changed

+38633
-5376
lines changed

Some content is hidden

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

377 files changed

+38633
-5376
lines changed

.github/actions/find-latest-bundle/action.yml

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

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
steps:
3030
- name: Setup dotnet
31-
uses: actions/setup-dotnet@v2
31+
uses: actions/setup-dotnet@v3
3232
with:
3333
dotnet-version: 7.0.102
3434

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

Lines changed: 24 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -22,144 +22,54 @@ jobs:
2222
steps:
2323
### Build the queries ###
2424
- uses: actions/checkout@v3
25-
- name: Find latest bundle
26-
id: find-latest-bundle
27-
uses: ./.github/actions/find-latest-bundle
2825
- name: Find codeql
2926
id: find-codeql
30-
uses: github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
27+
uses: github/codeql-action/init@v2
3128
with:
3229
languages: javascript # does not matter
33-
tools: ${{ steps.find-latest-bundle.outputs.url }}
34-
- name: Get CodeQL version
35-
id: get-codeql-version
36-
run: |
37-
echo "version=$("${CODEQL}" --version | head -n 1 | rev | cut -d " " -f 1 | rev)" >> $GITHUB_OUTPUT
38-
shell: bash
39-
env:
40-
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
4130
- uses: ./.github/actions/os-version
4231
id: os_version
43-
- name: Cache entire pack
44-
id: cache-pack
45-
uses: actions/cache@v3
46-
with:
47-
path: ${{ runner.temp }}/pack
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') }}
49-
- name: Cache queries
50-
if: steps.cache-pack.outputs.cache-hit != 'true'
51-
id: cache-queries
52-
uses: actions/cache@v3
53-
with:
54-
path: ${{ runner.temp }}/queries
55-
key: queries-${{ 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') }}
56-
- name: Build query pack
57-
if: steps.cache-queries.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
58-
run: |
59-
cd ql/ql/src
60-
"${CODEQL}" pack create -j 16
61-
mv .codeql/pack/codeql/ql/0.0.0 ${{ runner.temp }}/queries
62-
env:
63-
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
64-
- name: Move cache queries to pack
65-
if: steps.cache-pack.outputs.cache-hit != 'true'
66-
run: |
67-
cp -r ${{ runner.temp }}/queries ${{ runner.temp }}/pack
68-
env:
69-
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
70-
7132
### Build the extractor ###
7233
- name: Cache entire extractor
73-
if: steps.cache-pack.outputs.cache-hit != 'true'
7434
id: cache-extractor
7535
uses: actions/cache@v3
7636
with:
77-
path: |
78-
ql/target/release/ql-autobuilder
79-
ql/target/release/ql-autobuilder.exe
80-
ql/target/release/ql-extractor
81-
ql/target/release/ql-extractor.exe
37+
path: ql/extractor-pack/
8238
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
8339
- name: Cache cargo
84-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
40+
if: steps.cache-extractor.outputs.cache-hit != 'true'
8541
uses: actions/cache@v3
8642
with:
8743
path: |
8844
~/.cargo/registry
8945
~/.cargo/git
9046
ql/target
9147
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-rust-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
92-
- name: Check formatting
93-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
94-
run: cd ql; cargo fmt --all -- --check
95-
- name: Build
96-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
97-
run: cd ql; cargo build --verbose
98-
- name: Run tests
99-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
100-
run: cd ql; cargo test --verbose
10148
- name: Release build
102-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
103-
run: cd ql; cargo build --release
104-
- name: Generate dbscheme
105-
if: steps.cache-extractor.outputs.cache-hit != 'true' && steps.cache-pack.outputs.cache-hit != 'true'
106-
run: ql/target/release/ql-generator --dbscheme ql/ql/src/ql.dbscheme --library ql/ql/src/codeql_ql/ast/internal/TreeSitter.qll
107-
108-
### Package the queries and extractor ###
109-
- name: Package pack
110-
if: steps.cache-pack.outputs.cache-hit != 'true'
111-
run: |
112-
cp -r ql/codeql-extractor.yml ql/tools ql/ql/src/ql.dbscheme.stats ${PACK}/
113-
mkdir -p ${PACK}/tools/linux64
114-
cp ql/target/release/ql-autobuilder ${PACK}/tools/linux64/autobuilder
115-
cp ql/target/release/ql-extractor ${PACK}/tools/linux64/extractor
116-
chmod +x ${PACK}/tools/linux64/autobuilder
117-
chmod +x ${PACK}/tools/linux64/extractor
118-
env:
119-
PACK: ${{ runner.temp }}/pack
120-
121-
### Run the analysis ###
122-
- name: Hack codeql-action options
123-
run: |
124-
JSON=$(jq -nc --arg pack "${PACK}" '.database."run-queries"=["--search-path", $pack] | .resolve.queries=["--search-path", $pack] | .resolve.extractor=["--search-path", $pack] | .resolve.languages=["--search-path", $pack] | .database.init=["--search-path", $pack]')
125-
echo "CODEQL_ACTION_EXTRA_OPTIONS=${JSON}" >> ${GITHUB_ENV}
126-
env:
127-
PACK: ${{ runner.temp }}/pack
128-
129-
- name: Create CodeQL config file
130-
run: |
131-
echo "paths-ignore:" >> ${CONF}
132-
echo " - ql/ql/test" >> ${CONF}
133-
echo " - \"*/ql/lib/upgrades/\"" >> ${CONF}
134-
echo "disable-default-queries: true" >> ${CONF}
135-
echo "queries:" >> ${CONF}
136-
echo " - uses: ./ql/ql/src/codeql-suites/ql-code-scanning.qls" >> ${CONF}
137-
echo "Config file: "
138-
cat ${CONF}
49+
if: steps.cache-extractor.outputs.cache-hit != 'true'
50+
run: cd ql; ./scripts/create-extractor-pack.sh
13951
env:
140-
CONF: ./ql-for-ql-config.yml
141-
- name: Initialize CodeQL
142-
uses: github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
143-
with:
144-
languages: ql
145-
db-location: ${{ runner.temp }}/db
146-
config-file: ./ql-for-ql-config.yml
147-
tools: ${{ steps.find-latest-bundle.outputs.url }}
148-
- name: Move pack queries
52+
GH_TOKEN: ${{ github.token }}
53+
- name: Cache compilation cache
54+
id: query-cache
55+
uses: ./.github/actions/cache-query-compilation
56+
with:
57+
key: run-ql-for-ql
58+
- name: Make database and analyze
14959
run: |
150-
cp -r ${PACK}/queries ql/ql/src
151-
env:
152-
PACK: ${{ runner.temp }}/pack
153-
154-
- name: Perform CodeQL Analysis
155-
uses: github/codeql-action/analyze@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
60+
${CODEQL} database create -l=ql --search-path ql/extractor-pack ${DB}
61+
${CODEQL} database analyze -j0 --format=sarif-latest --output=ql-for-ql.sarif ${DB} ql/ql/src/codeql-suites/ql-code-scanning.qls --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
62+
env:
63+
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
64+
DB: ${{ runner.temp }}/DB
65+
LGTM_INDEX_FILTERS: |
66+
exclude:ql/ql/test
67+
exclude:*/ql/lib/upgrades/
68+
- name: Upload sarif to code-scanning
69+
uses: github/codeql-action/upload-sarif@v2
15670
with:
157-
category: "ql-for-ql"
158-
- name: Copy sarif file to CWD
159-
run: cp ../results/ql.sarif ./ql-for-ql.sarif
160-
- name: Fixup the $scema in sarif # Until https://github.com/microsoft/sarif-vscode-extension/pull/436/ is part in a stable release
161-
run: |
162-
sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ql-for-ql.sarif
71+
sarif_file: ql-for-ql.sarif
72+
category: ql-for-ql
16373
- name: Sarif as artifact
16474
uses: actions/upload-artifact@v3
16575
with:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Find codeql
2727
id: find-codeql
28-
uses: github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
28+
uses: github/codeql-action/init@v2
2929
with:
3030
languages: javascript # does not matter
3131
- uses: ./.github/actions/os-version

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- uses: actions/checkout@v3
2525
- name: Find codeql
2626
id: find-codeql
27-
uses: github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
27+
uses: github/codeql-action/init@v2
2828
with:
2929
languages: javascript # does not matter
3030
- uses: ./.github/actions/os-version
@@ -36,6 +36,8 @@ jobs:
3636
~/.cargo/git
3737
ql/target
3838
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-qltest-cargo-${{ hashFiles('ql/rust-toolchain.toml', 'ql/**/Cargo.lock') }}
39+
- name: Check formatting
40+
run: cd ql; cargo fmt --all -- --check
3941
- name: Build extractor
4042
run: |
4143
cd ql;
@@ -67,7 +69,7 @@ jobs:
6769
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
6870
- name: Find codeql
6971
id: find-codeql
70-
uses: github/codeql-action/init@beae46e6b1da530ed5e9fc6a756f92433ca47ae1
72+
uses: github/codeql-action/init@v2
7173
with:
7274
languages: javascript # does not matter
7375
- uses: ./.github/actions/os-version

cpp/ql/lib/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.2
2+
3+
No user-facing changes.
4+
15
## 0.5.1
26

37
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.5.2
2+
3+
No user-facing changes.

cpp/ql/lib/codeql-pack.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 0.5.1
2+
lastReleaseVersion: 0.5.2

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,16 @@ private module MkStage<StageSig PrevStage> {
12231223
bindingset[tc, tail]
12241224
Ap apCons(TypedContent tc, Ap tail);
12251225

1226-
Content getHeadContent(Ap ap);
1226+
/**
1227+
* An approximation of `Content` that corresponds to the precision level of
1228+
* `Ap`, such that the mappings from both `Ap` and `Content` to this type
1229+
* are functional.
1230+
*/
1231+
class ApHeadContent;
1232+
1233+
ApHeadContent getHeadContent(Ap ap);
1234+
1235+
ApHeadContent projectToHeadContent(Content c);
12271236

12281237
class ApOption;
12291238

@@ -1471,34 +1480,32 @@ private module MkStage<StageSig PrevStage> {
14711480
)
14721481
}
14731482

1474-
private class ApNonNil instanceof Ap {
1475-
pragma[nomagic]
1476-
ApNonNil() { not this instanceof ApNil }
1477-
1478-
string toString() { result = "" }
1479-
}
1480-
14811483
pragma[nomagic]
1482-
private predicate fwdFlowRead0(
1483-
NodeEx node1, FlowState state, Cc cc, ParamNodeOption summaryCtx, ApOption argAp, ApNonNil ap,
1484-
Configuration config
1484+
private predicate readStepCand(
1485+
NodeEx node1, ApHeadContent apc, Content c, NodeEx node2, Configuration config
14851486
) {
1486-
fwdFlow(node1, state, cc, summaryCtx, argAp, ap, config) and
1487-
PrevStage::readStepCand(node1, _, _, config)
1487+
PrevStage::readStepCand(node1, c, node2, config) and
1488+
apc = projectToHeadContent(c)
14881489
}
14891490

1490-
bindingset[ap, c]
1491+
bindingset[node1, apc]
14911492
pragma[inline_late]
1492-
private predicate hasHeadContent(Ap ap, Content c) { getHeadContent(ap) = c }
1493+
private predicate readStepCand0(
1494+
NodeEx node1, ApHeadContent apc, Content c, NodeEx node2, Configuration config
1495+
) {
1496+
readStepCand(node1, apc, c, node2, config)
1497+
}
14931498

14941499
pragma[nomagic]
14951500
private predicate fwdFlowRead(
14961501
Ap ap, Content c, NodeEx node1, NodeEx node2, FlowState state, Cc cc,
14971502
ParamNodeOption summaryCtx, ApOption argAp, Configuration config
14981503
) {
1499-
fwdFlowRead0(node1, state, cc, summaryCtx, argAp, ap, config) and
1500-
PrevStage::readStepCand(node1, c, node2, config) and
1501-
hasHeadContent(ap, c)
1504+
exists(ApHeadContent apc |
1505+
fwdFlow(node1, state, cc, summaryCtx, argAp, ap, config) and
1506+
apc = getHeadContent(ap) and
1507+
readStepCand0(node1, apc, c, node2, config)
1508+
)
15021509
}
15031510

15041511
pragma[nomagic]
@@ -2072,8 +2079,12 @@ private module Stage2Param implements MkStage<Stage1>::StageParam {
20722079
bindingset[tc, tail]
20732080
Ap apCons(TypedContent tc, Ap tail) { result = true and exists(tc) and exists(tail) }
20742081

2082+
class ApHeadContent = Unit;
2083+
20752084
pragma[inline]
2076-
Content getHeadContent(Ap ap) { exists(result) and ap = true }
2085+
ApHeadContent getHeadContent(Ap ap) { exists(result) and ap = true }
2086+
2087+
ApHeadContent projectToHeadContent(Content c) { any() }
20772088

20782089
class ApOption = BooleanOption;
20792090

@@ -2337,8 +2348,12 @@ private module Stage3Param implements MkStage<Stage2>::StageParam {
23372348
bindingset[tc, tail]
23382349
Ap apCons(TypedContent tc, Ap tail) { result.getAHead() = tc and exists(tail) }
23392350

2351+
class ApHeadContent = ContentApprox;
2352+
23402353
pragma[noinline]
2341-
Content getHeadContent(Ap ap) { result = ap.getAHead().getContent() }
2354+
ApHeadContent getHeadContent(Ap ap) { result = ap.getHead().getContent() }
2355+
2356+
predicate projectToHeadContent = getContentApprox/1;
23422357

23432358
class ApOption = ApproxAccessPathFrontOption;
23442359

@@ -2413,8 +2428,12 @@ private module Stage4Param implements MkStage<Stage3>::StageParam {
24132428
bindingset[tc, tail]
24142429
Ap apCons(TypedContent tc, Ap tail) { result.getHead() = tc and exists(tail) }
24152430

2431+
class ApHeadContent = Content;
2432+
24162433
pragma[noinline]
2417-
Content getHeadContent(Ap ap) { result = ap.getHead().getContent() }
2434+
ApHeadContent getHeadContent(Ap ap) { result = ap.getHead().getContent() }
2435+
2436+
ApHeadContent projectToHeadContent(Content c) { result = c }
24182437

24192438
class ApOption = AccessPathFrontOption;
24202439

@@ -2743,8 +2762,12 @@ private module Stage5Param implements MkStage<Stage4>::StageParam {
27432762
bindingset[tc, tail]
27442763
Ap apCons(TypedContent tc, Ap tail) { result = push(tc, tail) }
27452764

2765+
class ApHeadContent = Content;
2766+
27462767
pragma[noinline]
2747-
Content getHeadContent(Ap ap) { result = ap.getHead().getContent() }
2768+
ApHeadContent getHeadContent(Ap ap) { result = ap.getHead().getContent() }
2769+
2770+
ApHeadContent projectToHeadContent(Content c) { result = c }
27482771

27492772
class ApOption = AccessPathApproxOption;
27502773

0 commit comments

Comments
 (0)