Skip to content

Commit 1bd969c

Browse files
committed
Merge branch 'main' into call-graph-code
2 parents 4df946b + 976b040 commit 1bd969c

File tree

244 files changed

+37857
-2704
lines changed

Some content is hidden

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

244 files changed

+37857
-2704
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/workflows/ql-for-ql-tests.yml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,73 @@ jobs:
3333
~/.cargo/registry
3434
~/.cargo/git
3535
ql/target
36-
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-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') }}
3737
- name: Build extractor
3838
run: |
3939
cd ql;
4040
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
4141
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
4247
- name: Run QL tests
4348
run: |
44-
"${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
4550
env:
4651
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
47-
- 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
4889
run: |
49-
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
5097
env:
5198
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: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ jobs:
205205
- name: Fetch CodeQL
206206
uses: ./.github/actions/fetch-codeql
207207

208-
- uses: actions/checkout@v3
209-
with:
210-
repository: Shopify/example-ruby-app
211-
ref: 67a0decc5eb550f3a9228eda53925c3afd40dfe9
212-
213208
- name: Download Ruby bundle
214209
uses: actions/download-artifact@v3
215210
with:
@@ -218,26 +213,15 @@ jobs:
218213
- name: Unzip Ruby bundle
219214
shell: bash
220215
run: unzip -q -d "${{ runner.temp }}/ruby-bundle" "${{ runner.temp }}/codeql-ruby-bundle.zip"
221-
- name: Prepare test files
222-
shell: bash
223-
run: |
224-
echo "import codeql.ruby.AST select count(File f)" > "test.ql"
225-
echo "| 4 |" > "test.expected"
226-
echo 'name: sample-tests
227-
version: 0.0.0
228-
dependencies:
229-
codeql/ruby-all: "*"
230-
extractor: ruby
231-
tests: .
232-
' > qlpack.yml
216+
233217
- name: Run QL test
234218
shell: bash
235219
run: |
236-
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/
237221
- name: Create database
238222
shell: bash
239223
run: |
240-
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
241225
- name: Analyze database
242226
shell: bash
243227
run: |

config/identical-files.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplForContentDataFlow.qll",
3030
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl.qll",
3131
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImpl2.qll",
32+
"go/ql/lib/semmle/go/dataflow/internal/DataFlowImplForStringsNewReplacer.qll",
3233
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl.qll",
3334
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl2.qll",
3435
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl3.qll",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
private import RangeAnalysisStage
2+
3+
module FloatDelta implements DeltaSig {
4+
class Delta = float;
5+
6+
bindingset[d]
7+
bindingset[result]
8+
float toFloat(Delta d) { result = d }
9+
10+
bindingset[d]
11+
bindingset[result]
12+
int toInt(Delta d) { result = d }
13+
14+
bindingset[n]
15+
bindingset[result]
16+
Delta fromInt(int n) { result = n }
17+
18+
bindingset[f]
19+
Delta fromFloat(float f) {
20+
result =
21+
min(float diff, float res |
22+
diff = (res - f) and res = f.ceil()
23+
or
24+
diff = (f - res) and res = f.floor()
25+
|
26+
res order by diff
27+
)
28+
}
29+
}

0 commit comments

Comments
 (0)