mirror of
https://github.com/github/codeql.git
synced 2026-05-26 00:51:25 +02:00
Compare commits
385 Commits
dependabot
...
codeql-cli
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b359e7e40 | ||
|
|
e99d7db428 | ||
|
|
be02864281 | ||
|
|
8c92d92427 | ||
|
|
8f345f9618 | ||
|
|
acdafd9646 | ||
|
|
030977003e | ||
|
|
39ce3fbd33 | ||
|
|
e1ac40e750 | ||
|
|
74440273f1 | ||
|
|
d6a7c87696 | ||
|
|
485fc04029 | ||
|
|
7f8bb7e859 | ||
|
|
90537f9132 | ||
|
|
3fdc49c4cb | ||
|
|
ebe1e5e0d2 | ||
|
|
661a4e07be | ||
|
|
5108799224 | ||
|
|
c7be2ae08a | ||
|
|
4912ee8ab3 | ||
|
|
087a8484aa | ||
|
|
e1299143c6 | ||
|
|
40c5f10fea | ||
|
|
5cd4d88d44 | ||
|
|
d73d90dba2 | ||
|
|
e68229892e | ||
|
|
5c02fb4a2e | ||
|
|
e46ad61bb8 | ||
|
|
d99c2031ac | ||
|
|
587ebbffba | ||
|
|
b0939cfffa | ||
|
|
fa9cfc1104 | ||
|
|
8dcf93d065 | ||
|
|
452424a0d2 | ||
|
|
085aad3b3c | ||
|
|
c634b0a000 | ||
|
|
197fb04184 | ||
|
|
c825ae4eab | ||
|
|
8e378d86df | ||
|
|
7572546efa | ||
|
|
69761a2942 | ||
|
|
292c6b6159 | ||
|
|
2a88086544 | ||
|
|
7907cbeae1 | ||
|
|
0b850a2dff | ||
|
|
beb27bf5e3 | ||
|
|
f77c79593e | ||
|
|
9d8b514b5c | ||
|
|
b4b680775c | ||
|
|
9250c29bd5 | ||
|
|
a4c1ec75db | ||
|
|
ed0370b715 | ||
|
|
aeae922ef3 | ||
|
|
076dd07cdc | ||
|
|
c2e86423b9 | ||
|
|
f1d281ffcc | ||
|
|
a933f0d695 | ||
|
|
f9e4c0af13 | ||
|
|
da3c5f44f2 | ||
|
|
07bd854868 | ||
|
|
15cdc7210e | ||
|
|
f46b4b344f | ||
|
|
fea6017688 | ||
|
|
43984212a5 | ||
|
|
983eb1924f | ||
|
|
e4766b60c3 | ||
|
|
857edb791c | ||
|
|
8bf3c42213 | ||
|
|
d8db0e43da | ||
|
|
aa6726a401 | ||
|
|
d374935008 | ||
|
|
f624a1b7a7 | ||
|
|
809d040528 | ||
|
|
2a7533c441 | ||
|
|
304e68df30 | ||
|
|
f464759eb3 | ||
|
|
6d972bea2c | ||
|
|
91d5171d90 | ||
|
|
f8c9d96882 | ||
|
|
bc70d5ceb1 | ||
|
|
3436fc6177 | ||
|
|
3516117215 | ||
|
|
785af12f1c | ||
|
|
aa787a9cb1 | ||
|
|
2c74b5ee50 | ||
|
|
13f8488148 | ||
|
|
061d58ae4a | ||
|
|
ca10953761 | ||
|
|
969c57c1c8 | ||
|
|
5754f8bac8 | ||
|
|
58779e1b90 | ||
|
|
4c8aec0db5 | ||
|
|
7c95bb243e | ||
|
|
6b0d7bcda8 | ||
|
|
270fa8d507 | ||
|
|
84c41744c1 | ||
|
|
9aafcbc1e3 | ||
|
|
4f90f5fb4c | ||
|
|
d04f0200e2 | ||
|
|
00bc40765c | ||
|
|
d6d52a97a2 | ||
|
|
9c8f6145ab | ||
|
|
d9a37119f8 | ||
|
|
ac9afea75e | ||
|
|
bffdf2b179 | ||
|
|
f37b4aebc2 | ||
|
|
43e54fb0ae | ||
|
|
8213bbb14a | ||
|
|
1e830dad1a | ||
|
|
ba5218dfc0 | ||
|
|
26b9de3d63 | ||
|
|
5f4fee0780 | ||
|
|
a5d1d9e167 | ||
|
|
500a2a0738 | ||
|
|
2ae725784c | ||
|
|
b2451c6667 | ||
|
|
46bfefc99a | ||
|
|
ef06b555c1 | ||
|
|
90f7b30997 | ||
|
|
437b671035 | ||
|
|
38c25f96e5 | ||
|
|
37afad2f70 | ||
|
|
ae3f3d0c25 | ||
|
|
78281168c2 | ||
|
|
fae180f612 | ||
|
|
5961774f84 | ||
|
|
dfa16423c0 | ||
|
|
97edff3f70 | ||
|
|
561abced2d | ||
|
|
6e0b5bcb63 | ||
|
|
91537cdf9a | ||
|
|
353cd8cc74 | ||
|
|
42b1112be6 | ||
|
|
20ca8801e6 | ||
|
|
61592a3256 | ||
|
|
1250e72ebb | ||
|
|
6f36ea9188 | ||
|
|
f1cd9211e7 | ||
|
|
6c8780a2f9 | ||
|
|
86215b4f02 | ||
|
|
85e51bf0ec | ||
|
|
b40476423b | ||
|
|
6acc107021 | ||
|
|
6e6942b1d7 | ||
|
|
da8750e95e | ||
|
|
7c4383975f | ||
|
|
d69c1e9af6 | ||
|
|
45c9eb1b94 | ||
|
|
d6b8dd15a9 | ||
|
|
b0ca7935d7 | ||
|
|
573b8b9373 | ||
|
|
56e127849f | ||
|
|
9d08d248fe | ||
|
|
10a23c0843 | ||
|
|
c979a949e1 | ||
|
|
ee2a8b09f6 | ||
|
|
4512e4280d | ||
|
|
d8f37cf1f9 | ||
|
|
2c472dd5b8 | ||
|
|
d1cca13563 | ||
|
|
ef34d24e53 | ||
|
|
7637393f75 | ||
|
|
4454566d8d | ||
|
|
3cd8aaf4b0 | ||
|
|
c8f73587cc | ||
|
|
d34a0ba306 | ||
|
|
5d1da861a2 | ||
|
|
5df3af2272 | ||
|
|
d9e8792d33 | ||
|
|
e165fc77b5 | ||
|
|
1a9b2329f4 | ||
|
|
406d03edfc | ||
|
|
e8277015ab | ||
|
|
69b05e835c | ||
|
|
75113367c9 | ||
|
|
bc6da117d2 | ||
|
|
915d24c62f | ||
|
|
928f3f11f1 | ||
|
|
ac9e977baa | ||
|
|
18c423eb55 | ||
|
|
6111a7497d | ||
|
|
8c5cc2efdc | ||
|
|
a33c7703cd | ||
|
|
e14b626917 | ||
|
|
122e5a7598 | ||
|
|
9b12df5ae4 | ||
|
|
c34fe9eda2 | ||
|
|
3f94ed19bd | ||
|
|
ce2fdb3463 | ||
|
|
d1b311f11f | ||
|
|
a5b462292f | ||
|
|
c75f55debf | ||
|
|
b73b8682b4 | ||
|
|
8ecba44ea9 | ||
|
|
3c1e3b66ec | ||
|
|
1e32e84b1f | ||
|
|
772bc9b5c8 | ||
|
|
9aeaae6068 | ||
|
|
6ef5063ff0 | ||
|
|
195f37267e | ||
|
|
8380d71b01 | ||
|
|
1a9608a1f5 | ||
|
|
97c3efccd1 | ||
|
|
c5b8163493 | ||
|
|
c8e732468a | ||
|
|
4dead2bd8d | ||
|
|
ca796b0383 | ||
|
|
d790d1ff08 | ||
|
|
1005a89007 | ||
|
|
a8b8eb42c0 | ||
|
|
25d7f17efc | ||
|
|
78c6c09912 | ||
|
|
a226bdfbd3 | ||
|
|
e1048cf8ea | ||
|
|
e891c5a882 | ||
|
|
401bb24fde | ||
|
|
faef6359dd | ||
|
|
679d81ab00 | ||
|
|
46d6bbb458 | ||
|
|
76c35bec93 | ||
|
|
0516505033 | ||
|
|
8ab22feae1 | ||
|
|
5b65f98e2c | ||
|
|
6fd469c807 | ||
|
|
d93330bc4c | ||
|
|
d8eb5d463d | ||
|
|
60b349f7e5 | ||
|
|
be16954521 | ||
|
|
52ef1e382a | ||
|
|
013ee34de7 | ||
|
|
b23e482ed2 | ||
|
|
28a7fca7ed | ||
|
|
9786934d9a | ||
|
|
f76a190ed1 | ||
|
|
5950af390d | ||
|
|
5bafa8ace2 | ||
|
|
b6e38ff862 | ||
|
|
57534599c8 | ||
|
|
7c80b33a63 | ||
|
|
913a9263d2 | ||
|
|
05bdce1cd3 | ||
|
|
959715ac8e | ||
|
|
fe9d879e37 | ||
|
|
4c5344d62a | ||
|
|
3aa68b34bb | ||
|
|
f9e956dc94 | ||
|
|
e542d66719 | ||
|
|
627c533e98 | ||
|
|
78898955b6 | ||
|
|
cbd129fddd | ||
|
|
6f1aade8e0 | ||
|
|
fd9a5ee453 | ||
|
|
77b88afa9e | ||
|
|
c86b5790ff | ||
|
|
cc953c87d9 | ||
|
|
9bd706a576 | ||
|
|
e4d29905a9 | ||
|
|
f0eeaaf44e | ||
|
|
abd0a076a8 | ||
|
|
9105375097 | ||
|
|
4fa462417f | ||
|
|
351c50afc1 | ||
|
|
66af4fd337 | ||
|
|
cd8a5d7707 | ||
|
|
8508056e72 | ||
|
|
9b905d5e84 | ||
|
|
238895e677 | ||
|
|
92c6170a76 | ||
|
|
f066f21751 | ||
|
|
ce2df04854 | ||
|
|
2369b18ca6 | ||
|
|
db72bd4f96 | ||
|
|
6c28abdad7 | ||
|
|
8fe0d0a045 | ||
|
|
8d22d147b8 | ||
|
|
05ffb47711 | ||
|
|
4258119ba3 | ||
|
|
49aaf65f3f | ||
|
|
b253b4ff49 | ||
|
|
c38281528f | ||
|
|
65fafbf4df | ||
|
|
084dbc4e12 | ||
|
|
c048401ca7 | ||
|
|
bd45c1fdbe | ||
|
|
0f98e292ed | ||
|
|
d4947cc1a2 | ||
|
|
27e9c1b885 | ||
|
|
09f6576e6b | ||
|
|
078e63524c | ||
|
|
7b8e707465 | ||
|
|
1e225d7c44 | ||
|
|
ad3605c595 | ||
|
|
d8a70d8d58 | ||
|
|
751e7e6bfb | ||
|
|
d526f1d081 | ||
|
|
eb1b2a5594 | ||
|
|
50d9e77339 | ||
|
|
04f4039adc | ||
|
|
99400fe3d4 | ||
|
|
75643043bc | ||
|
|
3eeb79c599 | ||
|
|
3f5a146a1c | ||
|
|
6ed0a37efd | ||
|
|
bf2fb2f6e2 | ||
|
|
e2b16bd8f9 | ||
|
|
e76dcf9df9 | ||
|
|
846882d22c | ||
|
|
20dfdc9661 | ||
|
|
0fdd06fff5 | ||
|
|
73cc7460f3 | ||
|
|
a94601c8c0 | ||
|
|
8ca52f278a | ||
|
|
f5c195d830 | ||
|
|
d5948d2d95 | ||
|
|
386e45a11e | ||
|
|
81283d59ab | ||
|
|
4fc971dbcb | ||
|
|
a0f0854fdb | ||
|
|
6c97096642 | ||
|
|
037912fd2d | ||
|
|
9531701129 | ||
|
|
7bf7df2f99 | ||
|
|
6e8941ea9d | ||
|
|
4123876343 | ||
|
|
486246c82d | ||
|
|
5ddcb16cd6 | ||
|
|
e85ca79d77 | ||
|
|
78068a488f | ||
|
|
2dfca8ab20 | ||
|
|
59423c692f | ||
|
|
6365e5edff | ||
|
|
4bdf21b022 | ||
|
|
49eaaf55a5 | ||
|
|
8c1c537150 | ||
|
|
89e842b147 | ||
|
|
f86570f6e7 | ||
|
|
4f4c7bfbb9 | ||
|
|
6e81d74558 | ||
|
|
0d343c5ce1 | ||
|
|
885e89a927 | ||
|
|
7e1290aa74 | ||
|
|
ec7ad84cd1 | ||
|
|
5360192a58 | ||
|
|
4f0fe1ce3a | ||
|
|
3da6cee6ef | ||
|
|
321820e758 | ||
|
|
04753b286f | ||
|
|
13705531b5 | ||
|
|
590a146b49 | ||
|
|
5494389c4b | ||
|
|
f40901f391 | ||
|
|
a8591c79c5 | ||
|
|
f3dea1d647 | ||
|
|
2a2b79e6df | ||
|
|
927710017e | ||
|
|
fc24ca304d | ||
|
|
1cb23e7e86 | ||
|
|
d19102c399 | ||
|
|
c1c9ef2c1f | ||
|
|
113ab755d9 | ||
|
|
0e3c867cb9 | ||
|
|
f97b1039cd | ||
|
|
6f8eec2bf9 | ||
|
|
a10b5021b4 | ||
|
|
87b6495c91 | ||
|
|
361ad6be6a | ||
|
|
656dc4e276 | ||
|
|
13f697c056 | ||
|
|
11a416ea7c | ||
|
|
273848c879 | ||
|
|
a5363286f1 | ||
|
|
184aa0480e | ||
|
|
a5c9dc74bf | ||
|
|
e37ceac3b1 | ||
|
|
e0798b29da | ||
|
|
065c527615 | ||
|
|
16be908cb3 | ||
|
|
56bc32ff91 | ||
|
|
d4d505d7af | ||
|
|
042133a991 | ||
|
|
f715a3437b | ||
|
|
3ddc9a8b31 | ||
|
|
ae98510f77 | ||
|
|
430375e2f0 | ||
|
|
4a37da3593 |
4
.github/labeler.yml
vendored
4
.github/labeler.yml
vendored
@@ -30,6 +30,10 @@ Ruby:
|
||||
- ruby/**/*
|
||||
- change-notes/**/*ruby*
|
||||
|
||||
Rust:
|
||||
- rust/**/*
|
||||
- change-notes/**/*rust*
|
||||
|
||||
Swift:
|
||||
- swift/**/*
|
||||
- change-notes/**/*swift*
|
||||
|
||||
14
.github/pull_request_template.md
vendored
Normal file
14
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
### Pull Request checklist
|
||||
|
||||
#### All query authors
|
||||
|
||||
- [ ] A change note is added if necessary. See [the documentation](https://github.com/github/codeql/blob/main/docs/change-notes.md) in this repository.
|
||||
- [ ] All new queries have appropriate `.qhelp`. See [the documentation](https://github.com/github/codeql/blob/main/docs/query-help-style-guide.md) in this repository.
|
||||
- [ ] QL tests are added if necessary. See [Testing custom queries](https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/testing-custom-queries) in the GitHub documentation.
|
||||
- [ ] New and changed queries have correct query metadata. See [the documentation](https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md) in this repository.
|
||||
|
||||
#### Internal query authors only
|
||||
|
||||
- [ ] Autofixes generated based on these changes are valid, only needed if this PR makes significant changes to `.ql`, `.qll`, or `.qhelp` files. See [the documentation](https://github.com/github/codeql-team/blob/main/docs/best-practices/validating-autofix-for-query-changes.md) (internal access required).
|
||||
- [ ] Changes are validated [at scale](https://github.com/github/codeql-dca/) (internal access required).
|
||||
- [ ] Adding a new query? Consider also [adding the query to autofix](https://github.com/github/codeml-autofix/blob/main/docs/updating-query-support.md#adding-a-new-query-to-the-query-suite).
|
||||
5
.github/workflows/check-change-note.yml
vendored
5
.github/workflows/check-change-note.yml
vendored
@@ -16,11 +16,12 @@ on:
|
||||
- "shared/**/*.qll"
|
||||
- "!**/experimental/**"
|
||||
- "!ql/**"
|
||||
- "!rust/**"
|
||||
- ".github/workflows/check-change-note.yml"
|
||||
|
||||
jobs:
|
||||
check-change-note:
|
||||
env:
|
||||
env:
|
||||
REPO: ${{ github.repository }}
|
||||
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -33,7 +34,7 @@ jobs:
|
||||
!contains(github.event.pull_request.labels.*.name, 'no-change-note-required')
|
||||
run: |
|
||||
change_note_files=$(gh api "repos/$REPO/pulls/$PULL_REQUEST_NUMBER/files" --paginate --jq '.[].filename | select(test("/change-notes/.*[.]md$"))')
|
||||
|
||||
|
||||
if [ -z "$change_note_files" ]; then
|
||||
echo "No change note found. Either add one, or add the 'no-change-note-required' label."
|
||||
exit 1
|
||||
|
||||
39
.github/workflows/csharp-qltest.yml
vendored
39
.github/workflows/csharp-qltest.yml
vendored
@@ -29,45 +29,6 @@ permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
qlupgrade:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.github/actions/fetch-codeql
|
||||
- name: Check DB upgrade scripts
|
||||
run: |
|
||||
echo >empty.trap
|
||||
codeql dataset import -S ql/lib/upgrades/initial/semmlecode.csharp.dbscheme testdb empty.trap
|
||||
codeql dataset upgrade testdb --additional-packs ql/lib
|
||||
diff -q testdb/semmlecode.csharp.dbscheme ql/lib/semmlecode.csharp.dbscheme
|
||||
- name: Check DB downgrade scripts
|
||||
run: |
|
||||
echo >empty.trap
|
||||
rm -rf testdb; codeql dataset import -S ql/lib/semmlecode.csharp.dbscheme testdb empty.trap
|
||||
codeql resolve upgrades --format=lines --allow-downgrades --additional-packs downgrades \
|
||||
--dbscheme=ql/lib/semmlecode.csharp.dbscheme --target-dbscheme=downgrades/initial/semmlecode.csharp.dbscheme |
|
||||
xargs codeql execute upgrades testdb
|
||||
diff -q testdb/semmlecode.csharp.dbscheme downgrades/initial/semmlecode.csharp.dbscheme
|
||||
qltest:
|
||||
if: github.repository_owner == 'github'
|
||||
runs-on: ubuntu-latest-xl
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
slice: ["1/2", "2/2"]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./csharp/actions/create-extractor-pack
|
||||
- name: Cache compilation cache
|
||||
id: query-cache
|
||||
uses: ./.github/actions/cache-query-compilation
|
||||
with:
|
||||
key: csharp-qltest-${{ matrix.slice }}
|
||||
- name: Run QL tests
|
||||
run: |
|
||||
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}" --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 }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
unit-tests:
|
||||
strategy:
|
||||
matrix:
|
||||
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
needs: measure
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: measurements
|
||||
path: stats
|
||||
|
||||
24
.github/workflows/ruby-build.yml
vendored
24
.github/workflows/ruby-build.yml
vendored
@@ -65,8 +65,8 @@ jobs:
|
||||
id: cache-extractor
|
||||
with:
|
||||
path: |
|
||||
ruby/extractor/target/release/codeql-extractor-ruby
|
||||
ruby/extractor/target/release/codeql-extractor-ruby.exe
|
||||
target/release/codeql-extractor-ruby
|
||||
target/release/codeql-extractor-ruby.exe
|
||||
ruby/extractor/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
|
||||
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/Cargo.lock') }}-${{ hashFiles('shared/tree-sitter-extractor') }}-${{ hashFiles('ruby/extractor/**/*.rs') }}
|
||||
- uses: actions/cache@v3
|
||||
@@ -75,7 +75,7 @@ jobs:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
ruby/target
|
||||
target
|
||||
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/**/Cargo.lock') }}
|
||||
- name: Check formatting
|
||||
if: steps.cache-extractor.outputs.cache-hit != 'true'
|
||||
@@ -91,7 +91,7 @@ jobs:
|
||||
run: cd extractor && cargo build --release
|
||||
- name: Generate dbscheme
|
||||
if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
|
||||
run: extractor/target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
|
||||
run: ../target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
with:
|
||||
@@ -106,8 +106,8 @@ jobs:
|
||||
with:
|
||||
name: extractor-${{ matrix.os }}
|
||||
path: |
|
||||
ruby/extractor/target/release/codeql-extractor-ruby
|
||||
ruby/extractor/target/release/codeql-extractor-ruby.exe
|
||||
target/release/codeql-extractor-ruby
|
||||
target/release/codeql-extractor-ruby.exe
|
||||
retention-days: 1
|
||||
compile-queries:
|
||||
if: github.repository_owner == 'github'
|
||||
@@ -147,19 +147,19 @@ jobs:
|
||||
needs: [build, compile-queries]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: ruby.dbscheme
|
||||
path: ruby/ruby
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: extractor-ubuntu-latest
|
||||
path: ruby/linux64
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: extractor-windows-latest
|
||||
path: ruby/win64
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: extractor-macos-latest
|
||||
path: ruby/osx64
|
||||
@@ -178,7 +178,7 @@ jobs:
|
||||
path: ruby/codeql-ruby.zip
|
||||
retention-days: 1
|
||||
include-hidden-files: true
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: codeql-ruby-queries
|
||||
path: ruby/qlpacks
|
||||
@@ -214,7 +214,7 @@ jobs:
|
||||
uses: ./.github/actions/fetch-codeql
|
||||
|
||||
- name: Download Ruby bundle
|
||||
uses: actions/download-artifact@v4.1.7
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: codeql-ruby-bundle
|
||||
path: ${{ runner.temp }}
|
||||
|
||||
2
.github/workflows/ruby-dataset-measure.yml
vendored
2
.github/workflows/ruby-dataset-measure.yml
vendored
@@ -63,7 +63,7 @@ jobs:
|
||||
needs: measure
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4.1.7
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: measurements
|
||||
path: stats
|
||||
|
||||
58
.github/workflows/rust.yml
vendored
Normal file
58
.github/workflows/rust.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: "Rust"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- "rust/**"
|
||||
- "misc/bazel/**"
|
||||
- "misc/codegen/**"
|
||||
- "shared/**"
|
||||
- "MODULE.bazel"
|
||||
- .github/workflows/rust.yml
|
||||
- .github/actions/**
|
||||
- codeql-workspace.yml
|
||||
- "!**/*.md"
|
||||
- "!**/*.qhelp"
|
||||
branches:
|
||||
- rust-experiment
|
||||
- main
|
||||
- rc/*
|
||||
- codeql-cli-*
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
rust-code:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Format
|
||||
working-directory: rust/extractor
|
||||
shell: bash
|
||||
run: |
|
||||
cargo fmt --check
|
||||
- name: Compilation
|
||||
working-directory: rust/extractor
|
||||
shell: bash
|
||||
run: cargo check
|
||||
- name: Clippy
|
||||
working-directory: rust/extractor
|
||||
shell: bash
|
||||
run: |
|
||||
cargo clippy --fix
|
||||
git diff --exit-code
|
||||
rust-codegen:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Install CodeQL
|
||||
uses: ./.github/actions/fetch-codeql
|
||||
- name: Code generation
|
||||
shell: bash
|
||||
run: |
|
||||
bazel run //rust/codegen
|
||||
git add .
|
||||
git diff --exit-code HEAD
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -65,3 +65,9 @@ node_modules/
|
||||
|
||||
# bazel-built in-tree extractor packs
|
||||
/*/extractor-pack
|
||||
|
||||
# Jetbrains IDE files
|
||||
.idea
|
||||
|
||||
# cargo build directory
|
||||
/target
|
||||
|
||||
@@ -5,9 +5,9 @@ repos:
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
|
||||
exclude: /test/.*$(?<!\.qlref)|.*\.patch$|.*\.qll?$
|
||||
- id: end-of-file-fixer
|
||||
exclude: /test/.*$(?<!\.ql)(?<!\.qll)(?<!\.qlref)|.*\.patch
|
||||
exclude: /test/.*$(?<!\.qlref)|.*\.patch$|.*\.qll?$
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||
rev: v17.0.6
|
||||
@@ -45,7 +45,7 @@ repos:
|
||||
|
||||
- id: sync-files
|
||||
name: Fix files required to be identical
|
||||
files: \.(qll?|qhelp|swift)$|^config/identical-files\.json$
|
||||
files: \.(qll?|qhelp|swift|toml)$|^config/identical-files\.json$
|
||||
language: system
|
||||
entry: python3 config/sync-files.py --latest
|
||||
pass_filenames: false
|
||||
@@ -58,7 +58,7 @@ repos:
|
||||
|
||||
- id: swift-codegen
|
||||
name: Run Swift checked in code generation
|
||||
files: ^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements)|ql/\.generated.list)
|
||||
files: ^misc/codegen/|^swift/(schema.py$|codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements)|ql/\.generated.list)
|
||||
language: system
|
||||
entry: bazel run //swift/codegen -- --quiet
|
||||
pass_filenames: false
|
||||
@@ -69,3 +69,17 @@ repos:
|
||||
language: system
|
||||
entry: bazel test //misc/codegen/test
|
||||
pass_filenames: false
|
||||
|
||||
- id: rust-codegen
|
||||
name: Run Rust checked in code generation
|
||||
files: ^misc/codegen/|^rust/(schema.py$|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list)
|
||||
language: system
|
||||
entry: bazel run //rust/codegen -- --quiet
|
||||
pass_filenames: false
|
||||
|
||||
- id: rust-lint
|
||||
name: Run fmt and clippy on Rust code
|
||||
files: ^rust/extractor/(.*rs|Cargo.toml)$
|
||||
language: system
|
||||
entry: python3 rust/lint.py
|
||||
pass_filenames: false
|
||||
|
||||
2610
Cargo.lock
generated
Normal file
2610
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
# This is the shared workspace file for extractor using shared/tree-sitter/extractor
|
||||
[workspace]
|
||||
|
||||
resolver = "2"
|
||||
members = [
|
||||
"shared/tree-sitter-extractor",
|
||||
"ruby/extractor",
|
||||
"rust/extractor",
|
||||
]
|
||||
|
||||
[patch.crates-io]
|
||||
# patch for build script bug preventing bazel build
|
||||
# see https://github.com/rust-lang/rustc_apfloat/pull/17
|
||||
rustc_apfloat = { git = "https://github.com/redsun82/rustc_apfloat.git", rev = "096d585100636bc2e9f09d7eefec38c5b334d47b" }
|
||||
20
MODULE.bazel
20
MODULE.bazel
@@ -16,9 +16,9 @@ local_path_override(
|
||||
|
||||
bazel_dep(name = "platforms", version = "0.0.10")
|
||||
bazel_dep(name = "rules_go", version = "0.50.0")
|
||||
bazel_dep(name = "rules_pkg", version = "0.10.1")
|
||||
bazel_dep(name = "rules_pkg", version = "1.0.1")
|
||||
bazel_dep(name = "rules_nodejs", version = "6.2.0-codeql.1")
|
||||
bazel_dep(name = "rules_python", version = "0.32.2")
|
||||
bazel_dep(name = "rules_python", version = "0.35.0")
|
||||
bazel_dep(name = "bazel_skylib", version = "1.6.1")
|
||||
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
|
||||
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
|
||||
@@ -27,7 +27,7 @@ bazel_dep(name = "rules_kotlin", version = "1.9.4-codeql.1")
|
||||
bazel_dep(name = "gazelle", version = "0.38.0")
|
||||
bazel_dep(name = "rules_dotnet", version = "0.15.1")
|
||||
bazel_dep(name = "googletest", version = "1.14.0.bcr.1")
|
||||
bazel_dep(name = "rules_rust", version = "0.49.1")
|
||||
bazel_dep(name = "rules_rust", version = "0.50.0")
|
||||
|
||||
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
|
||||
|
||||
@@ -47,21 +47,23 @@ cp.from_cargo(
|
||||
)
|
||||
use_repo(cp, "py_deps")
|
||||
|
||||
# crate_ruby, but shortened due to windows file paths
|
||||
# deps for ruby+rust, but shortened due to windows file paths
|
||||
r = use_extension(
|
||||
"@rules_rust//crate_universe:extension.bzl",
|
||||
"crate",
|
||||
isolate = True,
|
||||
)
|
||||
r.from_cargo(
|
||||
name = "rd",
|
||||
cargo_lockfile = "//ruby/extractor:Cargo.lock",
|
||||
name = "r",
|
||||
cargo_lockfile = "//:Cargo.lock",
|
||||
manifests = [
|
||||
"//:Cargo.toml",
|
||||
"//ruby/extractor:Cargo.toml",
|
||||
"//ruby/extractor/codeql-extractor-fake-crate:Cargo.toml",
|
||||
"//rust/extractor:Cargo.toml",
|
||||
"//shared/tree-sitter-extractor:Cargo.toml",
|
||||
],
|
||||
)
|
||||
use_repo(r, ruby_deps = "rd")
|
||||
use_repo(r, tree_sitter_extractors_deps = "r")
|
||||
|
||||
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
|
||||
dotnet.toolchain(dotnet_version = "8.0.101")
|
||||
@@ -153,7 +155,7 @@ use_repo(
|
||||
)
|
||||
|
||||
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
|
||||
go_sdk.download(version = "1.22.2")
|
||||
go_sdk.download(version = "1.23.1")
|
||||
|
||||
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
|
||||
go_deps.from_file(go_mod = "//go/extractor:go.mod")
|
||||
|
||||
@@ -355,9 +355,5 @@
|
||||
"Python model summaries test extension": [
|
||||
"python/ql/test/library-tests/dataflow/model-summaries/InlineTaintTest.ext.yml",
|
||||
"python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml"
|
||||
],
|
||||
"shared tree-sitter extractor cargo.toml": [
|
||||
"shared/tree-sitter-extractor/Cargo.toml",
|
||||
"ruby/extractor/codeql-extractor-fake-crate/Cargo.toml"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
class Function extends @function {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Type extends @type {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Variable extends @variable {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from Function func, Type traits, Variable handle, Variable promise
|
||||
where
|
||||
coroutine(func, traits) and
|
||||
coroutine_placeholder_variable(handle, 1, func) and
|
||||
coroutine_placeholder_variable(promise, 2, func)
|
||||
select func, traits, handle, promise
|
||||
2315
cpp/downgrades/7ff6a6e53dbcff09d1b9b758b594bc6d17366863/old.dbscheme
Normal file
2315
cpp/downgrades/7ff6a6e53dbcff09d1b9b758b594bc6d17366863/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
description: Improve handling of coroutine placeholder variables
|
||||
compatibility: full
|
||||
coroutine.rel: run coroutine.qlo
|
||||
coroutine_placeholder_variable.rel: delete
|
||||
@@ -1,3 +1,31 @@
|
||||
## 2.0.0
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* Deleted many deprecated taint-tracking configurations based on `TaintTracking::Configuration`.
|
||||
* Deleted many deprecated dataflow configurations based on `DataFlow::Configuration`.
|
||||
* Deleted the deprecated `hasQualifiedName` and `isDefined` predicates from the `Declaration` class, use `hasGlobalName` and `hasDefinition` respectively instead.
|
||||
* Deleted the `getFullSignature` predicate from the `Function` class, use `getIdentityString(Declaration)` from `semmle.code.cpp.Print` instead.
|
||||
* Deleted the deprecated `freeCall` predicate from `Alloc.qll`. Use `DeallocationExpr` instead.
|
||||
* Deleted the deprecated `explorationLimit` predicate from `DataFlow::Configuration`, use `FlowExploration<explorationLimit>` instead.
|
||||
* Deleted the deprecated `getFieldExpr` predicate from `ClassAggregateLiteral`, use `getAFieldExpr` instead.
|
||||
* Deleted the deprecated `getElementExpr` predicate from `ArrayOrVectorAggregateLiteral`, use `getAnElementExpr` instead.
|
||||
|
||||
### New Features
|
||||
|
||||
* Added a class `C11GenericExpr` to represent C11 generic selection expressions. The generic selection is represented as a `Conversion` on the expression that will be selected.
|
||||
* Added subclasses of `BuiltInOperations` for the `__is_scoped_enum`, `__is_trivially_equality_comparable`, and `__is_trivially_relocatable` builtin operations.
|
||||
* Added a subclass of `Expr` for `__datasizeof` expressions.
|
||||
|
||||
### Minor Analysis Improvements
|
||||
|
||||
* Added a data flow model for `swap` member functions, which were previously modeled as taint tracking functions. This change improves the precision of queries where flow through `swap` member functions might affect the results.
|
||||
* Added a data flow model for `realloc`-like functions, which were previously modeled as a taint tracking functions. This change improves the precision of queries where flow through `realloc`-like functions might affect the results.
|
||||
|
||||
## 1.4.2
|
||||
|
||||
No user-facing changes.
|
||||
|
||||
## 1.4.1
|
||||
|
||||
No user-facing changes.
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* Added subclasses of `BuiltInOperations` for the `__is_scoped_enum`, `__is_trivially_equality_comparable`, and `__is_trivially_relocatable` builtin operations.
|
||||
* Added a subclass of `Expr` for `__datasizeof` expressions.
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
category: feature
|
||||
---
|
||||
* Added a class `C11GenericExpr` to represent C11 generic selection expressions. The generic selection is represented as a `Conversion` on the expression that will be selected.
|
||||
3
cpp/ql/lib/change-notes/released/1.4.2.md
Normal file
3
cpp/ql/lib/change-notes/released/1.4.2.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 1.4.2
|
||||
|
||||
No user-facing changes.
|
||||
23
cpp/ql/lib/change-notes/released/2.0.0.md
Normal file
23
cpp/ql/lib/change-notes/released/2.0.0.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## 2.0.0
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
* Deleted many deprecated taint-tracking configurations based on `TaintTracking::Configuration`.
|
||||
* Deleted many deprecated dataflow configurations based on `DataFlow::Configuration`.
|
||||
* Deleted the deprecated `hasQualifiedName` and `isDefined` predicates from the `Declaration` class, use `hasGlobalName` and `hasDefinition` respectively instead.
|
||||
* Deleted the `getFullSignature` predicate from the `Function` class, use `getIdentityString(Declaration)` from `semmle.code.cpp.Print` instead.
|
||||
* Deleted the deprecated `freeCall` predicate from `Alloc.qll`. Use `DeallocationExpr` instead.
|
||||
* Deleted the deprecated `explorationLimit` predicate from `DataFlow::Configuration`, use `FlowExploration<explorationLimit>` instead.
|
||||
* Deleted the deprecated `getFieldExpr` predicate from `ClassAggregateLiteral`, use `getAFieldExpr` instead.
|
||||
* Deleted the deprecated `getElementExpr` predicate from `ArrayOrVectorAggregateLiteral`, use `getAnElementExpr` instead.
|
||||
|
||||
### New Features
|
||||
|
||||
* Added a class `C11GenericExpr` to represent C11 generic selection expressions. The generic selection is represented as a `Conversion` on the expression that will be selected.
|
||||
* Added subclasses of `BuiltInOperations` for the `__is_scoped_enum`, `__is_trivially_equality_comparable`, and `__is_trivially_relocatable` builtin operations.
|
||||
* Added a subclass of `Expr` for `__datasizeof` expressions.
|
||||
|
||||
### Minor Analysis Improvements
|
||||
|
||||
* Added a data flow model for `swap` member functions, which were previously modeled as taint tracking functions. This change improves the precision of queries where flow through `swap` member functions might affect the results.
|
||||
* Added a data flow model for `realloc`-like functions, which were previously modeled as a taint tracking functions. This change improves the precision of queries where flow through `realloc`-like functions might affect the results.
|
||||
@@ -1,2 +1,2 @@
|
||||
---
|
||||
lastReleaseVersion: 1.4.1
|
||||
lastReleaseVersion: 2.0.0
|
||||
|
||||
@@ -36,16 +36,6 @@ module PrivateCleartextWrite {
|
||||
}
|
||||
}
|
||||
|
||||
deprecated class WriteConfig extends TaintTracking::Configuration {
|
||||
WriteConfig() { this = "Write configuration" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof Source }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
|
||||
|
||||
override predicate isSanitizer(DataFlow::Node node) { node instanceof Sanitizer }
|
||||
}
|
||||
|
||||
private module WriteConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof Source }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: codeql/cpp-all
|
||||
version: 1.4.2-dev
|
||||
version: 2.0.0
|
||||
groups: cpp
|
||||
dbscheme: semmlecode.cpp.dbscheme
|
||||
extractor: cpp
|
||||
|
||||
@@ -60,18 +60,6 @@ class Declaration extends Locatable, @declaration {
|
||||
*/
|
||||
string getQualifiedName() { result = underlyingElement(this).(Q::Declaration).getQualifiedName() }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Prefer `hasGlobalName` or the 2-argument or 3-argument
|
||||
* `hasQualifiedName` predicates. To get the exact same results as this
|
||||
* predicate in all edge cases, use `getQualifiedName()`.
|
||||
*
|
||||
* Holds if this declaration has the fully-qualified name `qualifiedName`.
|
||||
* See `getQualifiedName`.
|
||||
*/
|
||||
deprecated predicate hasQualifiedName(string qualifiedName) {
|
||||
this.getQualifiedName() = qualifiedName
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if this declaration has a fully-qualified name with a name-space
|
||||
* component of `namespaceQualifier`, a declaring type of `typeQualifier`,
|
||||
@@ -185,9 +173,6 @@ class Declaration extends Locatable, @declaration {
|
||||
/** Holds if the declaration has a definition. */
|
||||
predicate hasDefinition() { exists(this.getDefinition()) }
|
||||
|
||||
/** DEPRECATED: Use `hasDefinition` instead. */
|
||||
deprecated predicate isDefined() { this.hasDefinition() }
|
||||
|
||||
/** Gets the preferred location of this declaration, if any. */
|
||||
override Location getLocation() { none() }
|
||||
|
||||
|
||||
@@ -30,46 +30,6 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
|
||||
|
||||
override string getName() { functions(underlyingElement(this), result, _) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `getIdentityString(Declaration)` from `semmle.code.cpp.Print` instead.
|
||||
* Gets the full signature of this function, including return type, parameter
|
||||
* types, and template arguments.
|
||||
*
|
||||
* For example, in the following code:
|
||||
* ```
|
||||
* template<typename T> T min(T x, T y);
|
||||
* int z = min(5, 7);
|
||||
* ```
|
||||
* The full signature of the function called on the last line would be
|
||||
* `min<int>(int, int) -> int`, and the full signature of the uninstantiated
|
||||
* template on the first line would be `min<T>(T, T) -> T`.
|
||||
*/
|
||||
deprecated string getFullSignature() {
|
||||
exists(string name, string templateArgs, string args |
|
||||
result = name + templateArgs + args + " -> " + this.getType().toString() and
|
||||
name = this.getQualifiedName() and
|
||||
(
|
||||
if exists(this.getATemplateArgument())
|
||||
then
|
||||
templateArgs =
|
||||
"<" +
|
||||
concat(int i |
|
||||
exists(this.getTemplateArgument(i))
|
||||
|
|
||||
this.getTemplateArgument(i).toString(), ", " order by i
|
||||
) + ">"
|
||||
else templateArgs = ""
|
||||
) and
|
||||
args =
|
||||
"(" +
|
||||
concat(int i |
|
||||
exists(this.getParameter(i))
|
||||
|
|
||||
this.getParameter(i).getType().toString(), ", " order by i
|
||||
) + ")"
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets a specifier of this function. */
|
||||
override Specifier getASpecifier() {
|
||||
funspecifiers(underlyingElement(this), unresolveElement(result)) or
|
||||
|
||||
@@ -286,9 +286,6 @@ abstract class BaseAstNode extends PrintAstNode {
|
||||
* Gets the AST represented by this node.
|
||||
*/
|
||||
final Locatable getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Locatable getAST() { result = this.getAst() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -409,11 +409,18 @@ class LocalVariable extends LocalScopeVariable, @localvariable {
|
||||
exists(ConditionDeclExpr e | e.getVariable() = this and e.getEnclosingFunction() = result)
|
||||
or
|
||||
orphaned_variables(underlyingElement(this), unresolveElement(result))
|
||||
or
|
||||
coroutine_placeholder_variable(underlyingElement(this), _, unresolveElement(result))
|
||||
}
|
||||
|
||||
override predicate isStatic() {
|
||||
super.isStatic() or orphaned_variables(underlyingElement(this), _)
|
||||
}
|
||||
|
||||
override predicate isCompilerGenerated() {
|
||||
super.isCompilerGenerated() or
|
||||
coroutine_placeholder_variable(underlyingElement(this), _, _)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,15 +7,6 @@ import semmle.code.cpp.models.interfaces.Deallocation
|
||||
*/
|
||||
predicate freeFunction(Function f, int argNum) { argNum = f.(DeallocationFunction).getFreedArg() }
|
||||
|
||||
/**
|
||||
* A call to a library routine that frees memory.
|
||||
*
|
||||
* DEPRECATED: Use `DeallocationExpr` instead (this also includes `delete` expressions).
|
||||
*/
|
||||
deprecated predicate freeCall(FunctionCall fc, Expr arg) {
|
||||
arg = fc.(DeallocationExpr).getFreedExpr()
|
||||
}
|
||||
|
||||
/**
|
||||
* Is e some kind of allocation or deallocation (`new`, `alloc`, `realloc`, `delete`, `free` etc)?
|
||||
*/
|
||||
|
||||
@@ -57,7 +57,7 @@ private int isSource(Expr bufferExpr, Element why) {
|
||||
exists(Type bufferType |
|
||||
// buffer is the address of a variable
|
||||
why = bufferExpr.(AddressOfExpr).getAddressable() and
|
||||
bufferType = why.(Variable).getType() and
|
||||
bufferType = why.(Variable).getUnspecifiedType() and
|
||||
result = bufferType.getSize() and
|
||||
not bufferType instanceof ReferenceType and
|
||||
not any(Union u).getAMemberVariable() = why
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -195,17 +195,6 @@ class ClassAggregateLiteral extends AggregateLiteral {
|
||||
*/
|
||||
Expr getAFieldExpr(Field field) { result = this.getFieldExpr(field, _) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `getAFieldExpr` instead.
|
||||
*
|
||||
* Gets the expression within the aggregate literal that is used to initialize
|
||||
* field `field`, if present.
|
||||
*
|
||||
* This predicate may have multiple results since a field can be initialized
|
||||
* multiple times in the same initializer.
|
||||
*/
|
||||
deprecated Expr getFieldExpr(Field field) { result = this.getFieldExpr(field, _) }
|
||||
|
||||
/**
|
||||
* Gets the expression within the aggregate literal that is used to initialize
|
||||
* field `field`, if present. The expression is the `position`'th entry in the
|
||||
@@ -300,17 +289,6 @@ class ArrayOrVectorAggregateLiteral extends AggregateLiteral {
|
||||
*/
|
||||
Expr getAnElementExpr(int elementIndex) { result = this.getElementExpr(elementIndex, _) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `getAnElementExpr` instead.
|
||||
*
|
||||
* Gets the expression within the aggregate literal that is used to initialize
|
||||
* element `elementIndex`, if present.
|
||||
*
|
||||
* This predicate may have multiple results since an element can be initialized
|
||||
* multiple times in the same initializer.
|
||||
*/
|
||||
deprecated Expr getElementExpr(int elementIndex) { result = this.getElementExpr(elementIndex, _) }
|
||||
|
||||
/**
|
||||
* Gets the expression within the aggregate literal that is used to initialize
|
||||
* element `elementIndex`, if present. The expression is the `position`'th entry
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -168,14 +168,6 @@ abstract deprecated class Configuration extends string {
|
||||
*/
|
||||
predicate hasFlowToExpr(DataFlowExpr sink) { this.hasFlowTo(exprNode(sink)) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `FlowExploration<explorationLimit>` instead.
|
||||
*
|
||||
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
|
||||
* measured in approximate number of interprocedural steps.
|
||||
*/
|
||||
deprecated int explorationLimit() { none() }
|
||||
|
||||
/**
|
||||
* Holds if hidden nodes should be included in the data flow graph.
|
||||
*
|
||||
|
||||
@@ -50,9 +50,6 @@ abstract private class AbstractIRVariable extends TIRVariable {
|
||||
*/
|
||||
abstract Language::AST getAst();
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets an identifier string for the variable. This identifier is unique
|
||||
* within the function.
|
||||
@@ -96,9 +93,6 @@ class IRUserVariable extends AbstractIRVariable, TIRUserVariable {
|
||||
|
||||
final override Language::AST getAst() { result = var }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override string getUniqueId() {
|
||||
result = this.getVariable().toString() + " " + this.getVariable().getLocation().toString()
|
||||
}
|
||||
@@ -163,9 +157,6 @@ abstract private class AbstractIRGeneratedVariable extends AbstractIRVariable {
|
||||
|
||||
final override Language::AST getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
override string toString() { result = this.getBaseString() + this.getLocationString() }
|
||||
|
||||
override string getUniqueId() { none() }
|
||||
|
||||
@@ -285,9 +285,6 @@ abstract private class MemoryLocation0 extends TMemoryLocation {
|
||||
predicate isAlwaysAllocatedOnStack() { none() }
|
||||
|
||||
final predicate canReuseSsa() { none() }
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsa */
|
||||
deprecated predicate canReuseSSA() { this.canReuseSsa() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,9 +50,6 @@ abstract private class AbstractIRVariable extends TIRVariable {
|
||||
*/
|
||||
abstract Language::AST getAst();
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets an identifier string for the variable. This identifier is unique
|
||||
* within the function.
|
||||
@@ -96,9 +93,6 @@ class IRUserVariable extends AbstractIRVariable, TIRUserVariable {
|
||||
|
||||
final override Language::AST getAst() { result = var }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override string getUniqueId() {
|
||||
result = this.getVariable().toString() + " " + this.getVariable().getLocation().toString()
|
||||
}
|
||||
@@ -163,9 +157,6 @@ abstract private class AbstractIRGeneratedVariable extends AbstractIRVariable {
|
||||
|
||||
final override Language::AST getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
override string toString() { result = this.getBaseString() + this.getLocationString() }
|
||||
|
||||
override string getUniqueId() { none() }
|
||||
|
||||
@@ -216,9 +216,6 @@ abstract class TranslatedSideEffects extends TranslatedElement {
|
||||
|
||||
final override Locatable getAst() { result = this.getExpr() }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Declaration getFunction() { result = getEnclosingDeclaration(this.getExpr()) }
|
||||
|
||||
final override TranslatedElement getChild(int i) {
|
||||
@@ -616,9 +613,6 @@ class TranslatedArgumentExprSideEffect extends TranslatedArgumentSideEffect,
|
||||
|
||||
final override Locatable getAst() { result = arg }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Type getIndirectionType() {
|
||||
result = arg.getUnspecifiedType().(DerivedType).getBaseType()
|
||||
or
|
||||
@@ -651,9 +645,6 @@ class TranslatedStructorQualifierSideEffect extends TranslatedArgumentSideEffect
|
||||
|
||||
final override Locatable getAst() { result = call }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Type getIndirectionType() { result = call.getTarget().getDeclaringType() }
|
||||
|
||||
final override string getArgString() { result = "this" }
|
||||
@@ -675,9 +666,6 @@ class TranslatedCallSideEffect extends TranslatedSideEffect, TTranslatedCallSide
|
||||
|
||||
override Locatable getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override Expr getPrimaryExpr() { result = expr }
|
||||
|
||||
override predicate sortOrder(int group, int indexInGroup) {
|
||||
@@ -716,9 +704,6 @@ class TranslatedAllocationSideEffect extends TranslatedSideEffect, TTranslatedAl
|
||||
|
||||
override Locatable getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override Expr getPrimaryExpr() { result = expr }
|
||||
|
||||
override predicate sortOrder(int group, int indexInGroup) {
|
||||
|
||||
@@ -29,9 +29,6 @@ abstract class TranslatedCondition extends TranslatedElement {
|
||||
|
||||
final override Locatable getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final ConditionContext getConditionContext() { result = this.getParent() }
|
||||
|
||||
final Expr getExpr() { result = expr }
|
||||
|
||||
@@ -45,9 +45,6 @@ abstract class TranslatedDeclarationEntry extends TranslatedElement, TTranslated
|
||||
final override string toString() { result = entry.toString() }
|
||||
|
||||
final override Locatable getAst() { result = entry.getAst() }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,9 +245,6 @@ class TranslatedStaticLocalVariableInitialization extends TranslatedElement,
|
||||
|
||||
final override Locatable getAst() { result = entry.getAst() }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override LocalVariable getVariable() { result = var }
|
||||
|
||||
final override Declaration getFunction() { result = var.getFunction() }
|
||||
@@ -277,9 +271,6 @@ class TranslatedConditionDecl extends TranslatedLocalVariableDeclaration, TTrans
|
||||
|
||||
override Locatable getAst() { result = conditionDeclExpr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override Declaration getFunction() { result = getEnclosingFunction(conditionDeclExpr) }
|
||||
|
||||
override LocalVariable getVariable() { result = conditionDeclExpr.getVariable() }
|
||||
|
||||
@@ -767,7 +767,10 @@ newtype TTranslatedElement =
|
||||
} or
|
||||
// A statement
|
||||
TTranslatedStmt(Stmt stmt) { translateStmt(stmt) } or
|
||||
// The `__except` block of a `__try __except` statement
|
||||
TTranslatedMicrosoftTryExceptHandler(MicrosoftTryExceptStmt stmt) or
|
||||
// The `__finally` block of a `__try __finally` statement
|
||||
TTranslatedMicrosoftTryFinallyHandler(MicrosoftTryFinallyStmt stmt) or
|
||||
// A function
|
||||
TTranslatedFunction(Function func) { translateFunction(func) } or
|
||||
// A constructor init list
|
||||
@@ -926,9 +929,6 @@ abstract class TranslatedElement extends TTranslatedElement {
|
||||
*/
|
||||
abstract Locatable getAst();
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Locatable getAST() { result = this.getAst() }
|
||||
|
||||
/** Gets the location of this element. */
|
||||
Location getLocation() { result = this.getAst().getLocation() }
|
||||
|
||||
|
||||
@@ -67,9 +67,6 @@ class TranslatedFunction extends TranslatedRootElement, TTranslatedFunction {
|
||||
|
||||
final override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the function being translated.
|
||||
*/
|
||||
@@ -212,8 +209,13 @@ class TranslatedFunction extends TranslatedRootElement, TTranslatedFunction {
|
||||
(
|
||||
// Only generate the `Unwind` instruction if there is any exception
|
||||
// handling present in the function.
|
||||
exists(TryStmt try | try.getEnclosingFunction() = func) or
|
||||
exists(TryOrMicrosoftTryStmt try | try.getEnclosingFunction() = func)
|
||||
or
|
||||
exists(ThrowExpr throw | throw.getEnclosingFunction() = func)
|
||||
or
|
||||
exists(FunctionCall call | call.getEnclosingFunction() = func |
|
||||
getTranslatedExpr(call).(TranslatedCallExpr).mayThrowException()
|
||||
)
|
||||
)
|
||||
or
|
||||
tag = AliasedUseTag() and
|
||||
@@ -483,9 +485,6 @@ class TranslatedThisParameter extends TranslatedParameter, TTranslatedThisParame
|
||||
|
||||
final override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Function getFunction() { result = func }
|
||||
|
||||
final override predicate hasIndirection() { any() }
|
||||
@@ -518,9 +517,6 @@ class TranslatedPositionalParameter extends TranslatedParameter, TTranslatedPara
|
||||
|
||||
final override Locatable getAst() { result = param }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Function getFunction() {
|
||||
result = param.getFunction() or
|
||||
result = param.getCatchBlock().getEnclosingFunction()
|
||||
@@ -558,9 +554,6 @@ class TranslatedEllipsisParameter extends TranslatedParameter, TTranslatedEllips
|
||||
|
||||
final override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Function getFunction() { result = func }
|
||||
|
||||
final override predicate hasIndirection() { any() }
|
||||
@@ -597,9 +590,6 @@ class TranslatedConstructorInitList extends TranslatedElement, InitializationCon
|
||||
|
||||
override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override TranslatedElement getChild(int id) {
|
||||
exists(ConstructorFieldInit fieldInit |
|
||||
fieldInit = func.(Constructor).getInitializer(id) and
|
||||
@@ -677,9 +667,6 @@ class TranslatedDestructorDestructionList extends TranslatedElement,
|
||||
|
||||
override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override TranslatedElement getChild(int id) {
|
||||
exists(DestructorFieldDestruction fieldDestruction |
|
||||
fieldDestruction = func.(Destructor).getDestruction(id) and
|
||||
@@ -733,9 +720,6 @@ class TranslatedReadEffects extends TranslatedElement, TTranslatedReadEffects {
|
||||
|
||||
override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override Function getFunction() { result = func }
|
||||
|
||||
override string toString() { result = "read effects: " + func.toString() }
|
||||
@@ -839,9 +823,6 @@ class TranslatedThisReadEffect extends TranslatedReadEffect, TTranslatedThisRead
|
||||
|
||||
override Locatable getAst() { result = func }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override Function getFunction() { result = func }
|
||||
|
||||
override string toString() { result = "read effect: this" }
|
||||
@@ -865,9 +846,6 @@ class TranslatedParameterReadEffect extends TranslatedReadEffect, TTranslatedPar
|
||||
|
||||
override Locatable getAst() { result = param }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
override string toString() { result = "read effect: " + param.toString() }
|
||||
|
||||
override Function getFunction() { result = param.getFunction() }
|
||||
|
||||
@@ -153,9 +153,6 @@ abstract class TranslatedInitialization extends TranslatedElement, TTranslatedIn
|
||||
|
||||
final override Locatable getAst() { result = expr }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets the expression that is doing the initialization.
|
||||
*/
|
||||
@@ -528,9 +525,6 @@ abstract class TranslatedFieldInitialization extends TranslatedElement {
|
||||
|
||||
final override Locatable getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Declaration getFunction() {
|
||||
result = getEnclosingFunction(ast) or
|
||||
result = getEnclosingVariable(ast).(GlobalOrNamespaceVariable) or
|
||||
@@ -701,9 +695,6 @@ abstract class TranslatedElementInitialization extends TranslatedElement {
|
||||
|
||||
final override Locatable getAst() { result = initList }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Declaration getFunction() {
|
||||
result = getEnclosingFunction(initList)
|
||||
or
|
||||
@@ -912,9 +903,6 @@ abstract class TranslatedStructorCallFromStructor extends TranslatedElement, Str
|
||||
|
||||
final override Locatable getAst() { result = call }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override TranslatedElement getChild(int id) {
|
||||
id = 0 and
|
||||
result = this.getStructorCall()
|
||||
@@ -1058,9 +1046,6 @@ class TranslatedConstructorBareInit extends TranslatedElement, TTranslatedConstr
|
||||
|
||||
override Locatable getAst() { result = init }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override string toString() { result = "construct base (no constructor)" }
|
||||
|
||||
override Instruction getFirstInstruction(EdgeKind kind) {
|
||||
|
||||
@@ -79,11 +79,6 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
tag = TryExceptCompareOneBranch() and
|
||||
opcode instanceof Opcode::ConditionalBranch and
|
||||
resultType = getVoidType()
|
||||
or
|
||||
// unwind stack
|
||||
tag = UnwindTag() and
|
||||
opcode instanceof Opcode::Unwind and
|
||||
resultType = getVoidType()
|
||||
}
|
||||
|
||||
final override Instruction getInstructionRegisterOperand(InstructionTag tag, OperandTag operandTag) {
|
||||
@@ -156,7 +151,7 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
// TODO: This is not really correct. The semantics of `EXCEPTION_CONTINUE_EXECUTION` is that
|
||||
// we should continue execution at the point where the exception occurred. But we don't have
|
||||
// any instruction to model this behavior.
|
||||
result = this.getInstruction(UnwindTag())
|
||||
result = this.getExceptionSuccessorInstruction(any(GotoEdge edge))
|
||||
or
|
||||
kind instanceof FalseEdge and
|
||||
result = this.getInstruction(TryExceptGenerateZero())
|
||||
@@ -176,7 +171,7 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
tag = TryExceptCompareZeroBranch() and
|
||||
(
|
||||
kind instanceof TrueEdge and
|
||||
result = this.getInstruction(UnwindTag())
|
||||
result = this.getExceptionSuccessorInstruction(any(GotoEdge edge))
|
||||
or
|
||||
kind instanceof FalseEdge and
|
||||
result = this.getInstruction(TryExceptGenerateOne())
|
||||
@@ -196,10 +191,6 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
tag = TryExceptCompareOneBranch() and
|
||||
kind instanceof TrueEdge and
|
||||
result = this.getTranslatedHandler().getFirstInstruction(any(GotoEdge edge))
|
||||
or
|
||||
// Unwind -> Parent
|
||||
tag = UnwindTag() and
|
||||
result = this.getParent().getChildSuccessor(this, kind)
|
||||
}
|
||||
|
||||
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
|
||||
@@ -215,8 +206,6 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
|
||||
override Instruction getALastInstructionInternal() {
|
||||
result = this.getTranslatedHandler().getALastInstruction()
|
||||
or
|
||||
result = this.getInstruction(UnwindTag())
|
||||
}
|
||||
|
||||
private TranslatedExpr getTranslatedCondition() {
|
||||
@@ -236,6 +225,68 @@ class TranslatedMicrosoftTryExceptHandler extends TranslatedElement,
|
||||
}
|
||||
|
||||
final override Function getFunction() { result = tryExcept.getEnclosingFunction() }
|
||||
|
||||
override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
// A throw from within a `__except` block flows to the handler for the parent of
|
||||
// the `__try`.
|
||||
result = this.getParent().getParent().getExceptionSuccessorInstruction(kind)
|
||||
}
|
||||
}
|
||||
|
||||
TranslatedMicrosoftTryFinallyHandler getTranslatedMicrosoftTryFinallyHandler(
|
||||
MicrosoftTryFinallyStmt tryFinally
|
||||
) {
|
||||
result.getAst() = tryFinally.getFinally()
|
||||
}
|
||||
|
||||
class TranslatedMicrosoftTryFinallyHandler extends TranslatedElement,
|
||||
TTranslatedMicrosoftTryFinallyHandler
|
||||
{
|
||||
MicrosoftTryFinallyStmt tryFinally;
|
||||
|
||||
TranslatedMicrosoftTryFinallyHandler() {
|
||||
this = TTranslatedMicrosoftTryFinallyHandler(tryFinally)
|
||||
}
|
||||
|
||||
final override string toString() { result = tryFinally.toString() }
|
||||
|
||||
final override Locatable getAst() { result = tryFinally.getFinally() }
|
||||
|
||||
override Instruction getFirstInstruction(EdgeKind kind) {
|
||||
result = this.getTranslatedFinally().getFirstInstruction(kind)
|
||||
}
|
||||
|
||||
override Instruction getALastInstructionInternal() {
|
||||
result = this.getTranslatedFinally().getALastInstruction()
|
||||
}
|
||||
|
||||
override Instruction getChildSuccessorInternal(TranslatedElement child, EdgeKind kind) {
|
||||
child = this.getTranslatedFinally() and
|
||||
result = this.getParent().getChildSuccessor(this, kind)
|
||||
}
|
||||
|
||||
override Instruction getInstructionSuccessorInternal(InstructionTag tag, EdgeKind kind) { none() }
|
||||
|
||||
override TranslatedElement getChild(int id) {
|
||||
id = 0 and
|
||||
result = this.getTranslatedFinally()
|
||||
}
|
||||
|
||||
override predicate hasInstruction(Opcode opcode, InstructionTag tag, CppType resultType) {
|
||||
none()
|
||||
}
|
||||
|
||||
final override Function getFunction() { result = tryFinally.getEnclosingFunction() }
|
||||
|
||||
private TranslatedStmt getTranslatedFinally() {
|
||||
result = getTranslatedStmt(tryFinally.getFinally())
|
||||
}
|
||||
|
||||
override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
// A throw from within a `__finally` block flows to the handler for the parent of
|
||||
// the `__try`.
|
||||
result = this.getParent().getParent().getExceptionSuccessorInstruction(kind)
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt {
|
||||
@@ -268,9 +319,6 @@ abstract class TranslatedStmt extends TranslatedElement, TTranslatedStmt {
|
||||
|
||||
final override Locatable getAst() { result = stmt }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Locatable getAST() { result = this.getAst() }
|
||||
|
||||
final override Function getFunction() { result = stmt.getEnclosingFunction() }
|
||||
}
|
||||
|
||||
@@ -586,7 +634,7 @@ class TranslatedNoValueReturnStmt extends TranslatedReturnStmt, TranslatedVariab
|
||||
/**
|
||||
* A C/C++ `try` statement, or a `__try __except` or `__try __finally` statement.
|
||||
*/
|
||||
private class TryOrMicrosoftTryStmt extends Stmt {
|
||||
class TryOrMicrosoftTryStmt extends Stmt {
|
||||
TryOrMicrosoftTryStmt() {
|
||||
this instanceof TryStmt or
|
||||
this instanceof MicrosoftTryStmt
|
||||
@@ -619,7 +667,9 @@ private class TryOrMicrosoftTryStmt extends Stmt {
|
||||
}
|
||||
|
||||
/** Gets the `finally` statement (usually a BlockStmt), if any. */
|
||||
Stmt getFinally() { result = this.(MicrosoftTryFinallyStmt).getFinally() }
|
||||
TranslatedElement getTranslatedFinally() {
|
||||
result = getTranslatedMicrosoftTryFinallyHandler(this)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -689,11 +739,14 @@ class TranslatedTryStmt extends TranslatedStmt {
|
||||
|
||||
final override Instruction getExceptionSuccessorInstruction(EdgeKind kind) {
|
||||
result = this.getHandler(0).getFirstInstruction(kind)
|
||||
or
|
||||
not exists(this.getHandler(_)) and
|
||||
result = this.getFinally().getFirstInstruction(kind)
|
||||
}
|
||||
|
||||
private TranslatedElement getHandler(int index) { result = stmt.getTranslatedHandler(index) }
|
||||
|
||||
private TranslatedStmt getFinally() { result = getTranslatedStmt(stmt.getFinally()) }
|
||||
private TranslatedElement getFinally() { result = stmt.getTranslatedFinally() }
|
||||
|
||||
private TranslatedStmt getBody() { result = getTranslatedStmt(stmt.getStmt()) }
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ abstract private class AbstractIRVariable extends TIRVariable {
|
||||
*/
|
||||
abstract Language::AST getAst();
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
/**
|
||||
* Gets an identifier string for the variable. This identifier is unique
|
||||
* within the function.
|
||||
@@ -96,9 +93,6 @@ class IRUserVariable extends AbstractIRVariable, TIRUserVariable {
|
||||
|
||||
final override Language::AST getAst() { result = var }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
final override string getUniqueId() {
|
||||
result = this.getVariable().toString() + " " + this.getVariable().getLocation().toString()
|
||||
}
|
||||
@@ -163,9 +157,6 @@ abstract private class AbstractIRGeneratedVariable extends AbstractIRVariable {
|
||||
|
||||
final override Language::AST getAst() { result = ast }
|
||||
|
||||
/** DEPRECATED: Alias for getAst */
|
||||
deprecated override Language::AST getAST() { result = this.getAst() }
|
||||
|
||||
override string toString() { result = this.getBaseString() + this.getLocationString() }
|
||||
|
||||
override string getUniqueId() { none() }
|
||||
|
||||
@@ -71,9 +71,6 @@ class MemoryLocation extends TMemoryLocation {
|
||||
final string getUniqueId() { result = var.getUniqueId() }
|
||||
|
||||
final predicate canReuseSsa() { canReuseSsaForVariable(var) }
|
||||
|
||||
/** DEPRECATED: Alias for canReuseSsa */
|
||||
deprecated predicate canReuseSSA() { this.canReuseSsa() }
|
||||
}
|
||||
|
||||
predicate canReuseSsaForOldResult(Instruction instr) { none() }
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
|
||||
import semmle.code.cpp.models.interfaces.Allocation
|
||||
import semmle.code.cpp.models.interfaces.Taint
|
||||
import semmle.code.cpp.models.interfaces.DataFlow
|
||||
|
||||
/**
|
||||
* An allocation function (such as `realloc`) that has an argument for the size
|
||||
* in bytes, and an argument for an existing pointer that is to be reallocated.
|
||||
*/
|
||||
private class ReallocAllocationFunction extends AllocationFunction, TaintFunction {
|
||||
private class ReallocAllocationFunction extends AllocationFunction, DataFlowFunction {
|
||||
int sizeArg;
|
||||
int reallocArg;
|
||||
|
||||
@@ -44,7 +44,7 @@ private class ReallocAllocationFunction extends AllocationFunction, TaintFunctio
|
||||
|
||||
override int getReallocPtrArg() { result = reallocArg }
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
override predicate hasDataFlow(FunctionInput input, FunctionOutput output) {
|
||||
input.isParameterDeref(this.getReallocPtrArg()) and output.isReturnValueDeref()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ private class Swap extends DataFlowFunction {
|
||||
* obj1.swap(obj2)
|
||||
* ```
|
||||
*/
|
||||
private class MemberSwap extends TaintFunction, MemberFunction, AliasFunction {
|
||||
private class MemberSwap extends DataFlowFunction, MemberFunction, AliasFunction {
|
||||
MemberSwap() {
|
||||
this.hasName("swap") and
|
||||
this.getNumberOfParameters() = 1 and
|
||||
@@ -34,7 +34,7 @@ private class MemberSwap extends TaintFunction, MemberFunction, AliasFunction {
|
||||
this.getDeclaringType()
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
override predicate hasDataFlow(FunctionInput input, FunctionOutput output) {
|
||||
input.isQualifierObject() and
|
||||
output.isParameterDeref(0)
|
||||
or
|
||||
|
||||
@@ -14,7 +14,11 @@ int getPointedSize(Type t) {
|
||||
* BufferWrite differ.
|
||||
*/
|
||||
abstract class BufferAccess extends Expr {
|
||||
BufferAccess() { not this.isUnevaluated() }
|
||||
BufferAccess() {
|
||||
not this.isUnevaluated() and
|
||||
//A buffer access must be reachable (not in dead code)
|
||||
reachable(this)
|
||||
}
|
||||
|
||||
abstract string getName();
|
||||
|
||||
@@ -26,6 +30,8 @@ abstract class BufferAccess extends Expr {
|
||||
* - 1 = buffer range [0, getSize) is accessed entirely.
|
||||
* - 2 = buffer range [0, getSize) may be accessed partially or entirely.
|
||||
* - 3 = buffer is accessed at offset getSize - 1.
|
||||
* - 4 = buffer is accessed with null terminator read protections
|
||||
* (does not read past null terminator, regardless of access size)
|
||||
*/
|
||||
abstract Expr getBuffer(string bufferDesc, int accessType);
|
||||
|
||||
@@ -128,7 +134,7 @@ class StrncpyBA extends BufferAccess {
|
||||
or
|
||||
result = this.(FunctionCall).getArgument(1) and
|
||||
bufferDesc = "source buffer" and
|
||||
accessType = 2
|
||||
accessType = 4
|
||||
}
|
||||
|
||||
override Expr getSizeExpr() { result = this.(FunctionCall).getArgument(2) }
|
||||
|
||||
@@ -353,22 +353,6 @@ module BoostorgAsio {
|
||||
}
|
||||
|
||||
//////////////////////// Dataflow /////////////////////
|
||||
/**
|
||||
* Abstract class for flows of protocol values to the first argument of a context
|
||||
* constructor.
|
||||
*/
|
||||
abstract deprecated class SslContextCallAbstractConfig extends DataFlow::Configuration {
|
||||
bindingset[this]
|
||||
SslContextCallAbstractConfig() { any() }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(ConstructorCall cc, SslContextClass c, Expr e | e = sink.asExpr() |
|
||||
c.getAContructorCall() = cc and
|
||||
cc.getArgument(0) = e
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signature for flows of protocol values to the first argument of a context
|
||||
* constructor.
|
||||
@@ -402,20 +386,6 @@ module BoostorgAsio {
|
||||
import DataFlow::Global<C>
|
||||
}
|
||||
|
||||
/**
|
||||
* Any protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
deprecated class SslContextCallConfig extends SslContextCallAbstractConfig {
|
||||
SslContextCallConfig() { this = "SslContextCallConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Any protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
@@ -430,21 +400,6 @@ module BoostorgAsio {
|
||||
|
||||
module SslContextCallFlow = SslContextCallGlobal<SslContextCallConfig>;
|
||||
|
||||
/**
|
||||
* A banned protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
deprecated class SslContextCallBannedProtocolConfig extends SslContextCallAbstractConfig {
|
||||
SslContextCallBannedProtocolConfig() { this = "SslContextCallBannedProtocolConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%") and
|
||||
isExprBannedBoostProtocol(e)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A banned protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
@@ -461,21 +416,6 @@ module BoostorgAsio {
|
||||
module SslContextCallBannedProtocolFlow =
|
||||
SslContextCallGlobal<SslContextCallBannedProtocolConfig>;
|
||||
|
||||
/**
|
||||
* A TLS 1.2 protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
deprecated class SslContextCallTls12ProtocolConfig extends SslContextCallAbstractConfig {
|
||||
SslContextCallTls12ProtocolConfig() { this = "SslContextCallTls12ProtocolConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%") and
|
||||
isExprTls12BoostProtocol(e)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A TLS 1.2 protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
@@ -491,21 +431,6 @@ module BoostorgAsio {
|
||||
|
||||
module SslContextCallTls12ProtocolFlow = SslContextCallGlobal<SslContextCallTls12ProtocolConfig>;
|
||||
|
||||
/**
|
||||
* A TLS 1.3 protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
deprecated class SslContextCallTls13ProtocolConfig extends SslContextCallAbstractConfig {
|
||||
SslContextCallTls13ProtocolConfig() { this = "SslContextCallTls12ProtocolConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%") and
|
||||
isExprTls13BoostProtocol(e)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A TLS 1.3 protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
@@ -521,21 +446,6 @@ module BoostorgAsio {
|
||||
|
||||
module SslContextCallTls13ProtocolFlow = SslContextCallGlobal<SslContextCallTls13ProtocolConfig>;
|
||||
|
||||
/**
|
||||
* A generic TLS protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
deprecated class SslContextCallTlsProtocolConfig extends SslContextCallAbstractConfig {
|
||||
SslContextCallTlsProtocolConfig() { this = "SslContextCallTlsProtocolConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%") and
|
||||
isExprTlsBoostProtocol(e)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A generic TLS protocol value that flows to the first argument of a context constructor.
|
||||
*/
|
||||
@@ -551,30 +461,6 @@ module BoostorgAsio {
|
||||
|
||||
module SslContextCallTlsProtocolFlow = SslContextCallGlobal<SslContextCallTlsProtocolConfig>;
|
||||
|
||||
/**
|
||||
* A context constructor call that flows to a call to `SetOptions()`.
|
||||
*/
|
||||
deprecated class SslContextFlowsToSetOptionConfig extends DataFlow::Configuration {
|
||||
SslContextFlowsToSetOptionConfig() { this = "SslContextFlowsToSetOptionConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(SslContextClass c, ConstructorCall cc |
|
||||
cc = source.asExpr() and
|
||||
c.getAContructorCall() = cc
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(FunctionCall fc, SslSetOptionsFunction f, Variable v, VariableAccess va |
|
||||
va = sink.asExpr()
|
||||
|
|
||||
f.getACallToThisFunction() = fc and
|
||||
v.getAnAccess() = va and
|
||||
va = fc.getQualifier()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A context constructor call that flows to a call to `SetOptions()`.
|
||||
*/
|
||||
@@ -599,28 +485,6 @@ module BoostorgAsio {
|
||||
|
||||
module SslContextFlowsToSetOptionFlow = DataFlow::Global<SslContextFlowsToSetOptionConfig>;
|
||||
|
||||
/**
|
||||
* An option value that flows to the first parameter of a call to `SetOptions()`.
|
||||
*/
|
||||
deprecated class SslOptionConfig extends DataFlow::Configuration {
|
||||
SslOptionConfig() { this = "SslOptionConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e | e = source.asExpr() |
|
||||
e.fromSource() and
|
||||
not e.getLocation().getFile().toString().matches("%/boost/asio/%")
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(SslSetOptionsFunction f, FunctionCall call |
|
||||
sink.asExpr() = call.getArgument(0) and
|
||||
f.getACallToThisFunction() = call and
|
||||
not sink.getLocation().getFile().toString().matches("%/boost/asio/%")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An option value that flows to the first parameter of a call to `SetOptions()`.
|
||||
*/
|
||||
|
||||
@@ -384,11 +384,23 @@ function_return_type(
|
||||
*/
|
||||
coroutine(
|
||||
unique int function: @function ref,
|
||||
int traits: @type ref,
|
||||
int handle: @variable ref,
|
||||
int promise: @variable ref
|
||||
int traits: @type ref
|
||||
);
|
||||
|
||||
/*
|
||||
case @coroutine_placeholder_variable.kind of
|
||||
1 = @handle
|
||||
| 2 = @promise
|
||||
| 3 = @init_await_resume
|
||||
;
|
||||
*/
|
||||
|
||||
coroutine_placeholder_variable(
|
||||
unique int placeholder_variable: @variable ref,
|
||||
int kind: int ref,
|
||||
int function: @function ref
|
||||
)
|
||||
|
||||
/** The `new` function used for allocating the coroutine state, if any. */
|
||||
coroutine_new(
|
||||
unique int function: @function ref,
|
||||
@@ -829,22 +841,6 @@ variable_template_argument_value(
|
||||
int arg_value: @expr ref
|
||||
);
|
||||
|
||||
/*
|
||||
Fixed point types
|
||||
precision(1) = short, precision(2) = default, precision(3) = long
|
||||
is_unsigned(1) = unsigned is_unsigned(2) = signed
|
||||
is_fract_type(1) = declared with _Fract
|
||||
saturating(1) = declared with _Sat
|
||||
*/
|
||||
/* TODO
|
||||
fixedpointtypes(
|
||||
unique int id: @fixedpointtype,
|
||||
int precision: int ref,
|
||||
int is_unsigned: int ref,
|
||||
int is_fract_type: int ref,
|
||||
int saturating: int ref);
|
||||
*/
|
||||
|
||||
routinetypes(
|
||||
unique int id: @routinetype,
|
||||
int return_type: @type ref
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
description: Improve handling of coroutine placeholder variables
|
||||
compatibility: partial
|
||||
coroutine.rel: run upgrades.qlo new_coroutine
|
||||
coroutine_placeholder_variable.rel: run upgrades.qlo new_coroutine_placeholder_variable
|
||||
@@ -0,0 +1,19 @@
|
||||
class Function extends @function {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Type extends @type {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Variable extends @variable {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
query predicate new_coroutine(Function func, Type traits) { coroutine(func, traits, _, _) }
|
||||
|
||||
query predicate new_coroutine_placeholder_variable(Variable var, int kind, Function func) {
|
||||
coroutine(func, _, var, _) and kind = 1
|
||||
or
|
||||
coroutine(func, _, _, var) and kind = 2
|
||||
}
|
||||
@@ -1,3 +1,15 @@
|
||||
## 1.2.3
|
||||
|
||||
### Minor Analysis Improvements
|
||||
|
||||
* Removed false positives caused by buffer accesses in unreachable code.
|
||||
* Removed false positives caused by inconsistent type checking.
|
||||
* Add modeling of C functions that don't throw, thereby increasing the precision of the `cpp/incorrect-allocation-error-handling` ("Incorrect allocation-error handling") query. The query now produces additional true positives.
|
||||
|
||||
## 1.2.2
|
||||
|
||||
No user-facing changes.
|
||||
|
||||
## 1.2.1
|
||||
|
||||
### Minor Analysis Improvements
|
||||
|
||||
@@ -42,7 +42,9 @@ class BufferAccess extends ArrayExpr {
|
||||
not exists(Macro m |
|
||||
m.getName() = "strcmp" and
|
||||
m.getAnInvocation().getAnExpandedElement() = this
|
||||
)
|
||||
) and
|
||||
//A buffer access must be reachable (not in dead code)
|
||||
reachable(this)
|
||||
}
|
||||
|
||||
int bufferSize() { staticBuffer(this.getArrayBase(), _, result) }
|
||||
|
||||
@@ -205,20 +205,6 @@ class ChecksForLeapYearFunctionCall extends FunctionCall {
|
||||
ChecksForLeapYearFunctionCall() { this.getTarget() instanceof ChecksForLeapYearFunction }
|
||||
}
|
||||
|
||||
/**
|
||||
* Data flow configuration for finding a variable access that would flow into
|
||||
* a function call that includes an operation to check for leap year.
|
||||
*/
|
||||
deprecated class LeapYearCheckConfiguration extends DataFlow::Configuration {
|
||||
LeapYearCheckConfiguration() { this = "LeapYearCheckConfiguration" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source.asExpr() instanceof VariableAccess }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(ChecksForLeapYearFunctionCall fc | sink.asExpr() = fc.getAnArgument())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data flow configuration for finding a variable access that would flow into
|
||||
* a function call that includes an operation to check for leap year.
|
||||
@@ -233,33 +219,6 @@ private module LeapYearCheckConfig implements DataFlow::ConfigSig {
|
||||
|
||||
module LeapYearCheckFlow = DataFlow::Global<LeapYearCheckConfig>;
|
||||
|
||||
/**
|
||||
* Data flow configuration for finding an operation with hardcoded 365 that will flow into
|
||||
* a `FILEINFO` field.
|
||||
*/
|
||||
deprecated class FiletimeYearArithmeticOperationCheckConfiguration extends DataFlow::Configuration {
|
||||
FiletimeYearArithmeticOperationCheckConfiguration() {
|
||||
this = "FiletimeYearArithmeticOperationCheckConfiguration"
|
||||
}
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Expr e, Operation op | e = source.asExpr() |
|
||||
op.getAChild*().getValue().toInt() = 365 and
|
||||
op.getAChild*() = e
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr, Expr e | e = sink.asExpr() |
|
||||
dds instanceof PackedTimeType and
|
||||
fa.getQualifier().getUnderlyingType() = dds and
|
||||
fa.isModified() and
|
||||
aexpr.getAChild() = fa and
|
||||
aexpr.getChild(1).getAChild*() = e
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Data flow configuration for finding an operation with hardcoded 365 that will flow into
|
||||
* a `FILEINFO` field.
|
||||
@@ -286,51 +245,6 @@ private module FiletimeYearArithmeticOperationCheckConfig implements DataFlow::C
|
||||
module FiletimeYearArithmeticOperationCheckFlow =
|
||||
DataFlow::Global<FiletimeYearArithmeticOperationCheckConfig>;
|
||||
|
||||
/**
|
||||
* Taint configuration for finding an operation with hardcoded 365 that will flow into any known date/time field.
|
||||
*/
|
||||
deprecated class PossibleYearArithmeticOperationCheckConfiguration extends TaintTracking::Configuration
|
||||
{
|
||||
PossibleYearArithmeticOperationCheckConfiguration() {
|
||||
this = "PossibleYearArithmeticOperationCheckConfiguration"
|
||||
}
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(Operation op | op = source.asExpr() |
|
||||
op.getAChild*().getValue().toInt() = 365 and
|
||||
(
|
||||
not op.getParent() instanceof Expr or
|
||||
op.getParent() instanceof Assignment
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isAdditionalTaintStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
// flow from anything on the RHS of an assignment to a time/date structure to that
|
||||
// assignment.
|
||||
exists(StructLikeClass dds, FieldAccess fa, Assignment aexpr, Expr e |
|
||||
e = node1.asExpr() and
|
||||
fa = node2.asExpr()
|
||||
|
|
||||
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
|
||||
fa.getQualifier().getUnderlyingType() = dds and
|
||||
aexpr.getLValue() = fa and
|
||||
aexpr.getRValue().getAChild*() = e
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) {
|
||||
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
|
||||
aexpr.getRValue() = sink.asExpr()
|
||||
|
|
||||
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
|
||||
fa.getQualifier().getUnderlyingType() = dds and
|
||||
fa.isModified() and
|
||||
aexpr.getLValue() = fa
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Taint configuration for finding an operation with hardcoded 365 that will flow into any known date/time field.
|
||||
*/
|
||||
|
||||
@@ -129,24 +129,6 @@ class NetworkFunctionCall extends FunctionCall {
|
||||
NetworkFunctionCall() { this.getTarget().hasName(["ntohd", "ntohf", "ntohl", "ntohll", "ntohs"]) }
|
||||
}
|
||||
|
||||
deprecated class NetworkToBufferSizeConfiguration extends DataFlow::Configuration {
|
||||
NetworkToBufferSizeConfiguration() { this = "NetworkToBufferSizeConfiguration" }
|
||||
|
||||
override predicate isSource(DataFlow::Node node) { node.asExpr() instanceof NetworkFunctionCall }
|
||||
|
||||
override predicate isSink(DataFlow::Node node) {
|
||||
node.asExpr() = any(BufferAccess ba).getAccessedLength()
|
||||
}
|
||||
|
||||
override predicate isBarrier(DataFlow::Node node) {
|
||||
exists(GuardCondition gc, GVN gvn |
|
||||
gc.getAChild*() = gvn.getAnExpr() and
|
||||
globalValueNumber(node.asExpr()) = gvn and
|
||||
gc.controls(node.asExpr().getBasicBlock(), _)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private module NetworkToBufferSizeConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node node) { node.asExpr() instanceof NetworkFunctionCall }
|
||||
|
||||
|
||||
@@ -41,20 +41,6 @@ class ExternalApiDataNode extends DataFlow::Node {
|
||||
string getFunctionDescription() { result = this.getExternalFunction().toString() }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
deprecated class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration {
|
||||
UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfig" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) {
|
||||
exists(RemoteFlowSourceFunction remoteFlow |
|
||||
remoteFlow = source.asExpr().(Call).getTarget() and
|
||||
remoteFlow.hasRemoteFlowSource(_, _)
|
||||
)
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
private module UntrustedDataToExternalApiConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
|
||||
@@ -41,15 +41,6 @@ class ExternalApiDataNode extends DataFlow::Node {
|
||||
string getFunctionDescription() { result = this.getExternalFunction().toString() }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
deprecated class UntrustedDataToExternalApiConfig extends TaintTracking::Configuration {
|
||||
UntrustedDataToExternalApiConfig() { this = "UntrustedDataToExternalAPIConfigIR" }
|
||||
|
||||
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
override predicate isSink(DataFlow::Node sink) { sink instanceof ExternalApiDataNode }
|
||||
}
|
||||
|
||||
/** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
|
||||
private module UntrustedDataToExternalApiConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
|
||||
|
||||
@@ -26,6 +26,7 @@ from
|
||||
BufferAccess ba, string bufferDesc, int accessSize, int accessType, Element bufferAlloc,
|
||||
int bufferSize, string message
|
||||
where
|
||||
accessType != 4 and
|
||||
accessSize = ba.getSize() and
|
||||
bufferSize = getBufferSize(ba.getBuffer(bufferDesc, accessType), bufferAlloc) and
|
||||
(
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* Add modeling of C functions that don't throw, thereby increasing the precision of the `cpp/incorrect-allocation-error-handling` ("Incorrect allocation-error handling") query. The query now produces additional true positives.
|
||||
3
cpp/ql/src/change-notes/released/1.2.2.md
Normal file
3
cpp/ql/src/change-notes/released/1.2.2.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 1.2.2
|
||||
|
||||
No user-facing changes.
|
||||
7
cpp/ql/src/change-notes/released/1.2.3.md
Normal file
7
cpp/ql/src/change-notes/released/1.2.3.md
Normal file
@@ -0,0 +1,7 @@
|
||||
## 1.2.3
|
||||
|
||||
### Minor Analysis Improvements
|
||||
|
||||
* Removed false positives caused by buffer accesses in unreachable code
|
||||
* Removed false positives caused by inconsistent type checking
|
||||
* Add modeling of C functions that don't throw, thereby increasing the precision of the `cpp/incorrect-allocation-error-handling` ("Incorrect allocation-error handling") query. The query now produces additional true positives.
|
||||
@@ -1,2 +1,2 @@
|
||||
---
|
||||
lastReleaseVersion: 1.2.1
|
||||
lastReleaseVersion: 1.2.3
|
||||
|
||||
26
cpp/ql/src/experimental/Security/CWE/CWE-409/Brotli.qll
Normal file
26
cpp/ql/src/experimental/Security/CWE/CWE-409/Brotli.qll
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* https://github.com/google/brotli
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `BrotliDecoderDecompress` function is used in flow sink.
|
||||
* See https://www.brotli.org/decode.html.
|
||||
*/
|
||||
class BrotliDecoderDecompressFunction extends DecompressionFunction {
|
||||
BrotliDecoderDecompressFunction() { this.hasGlobalName("BrotliDecoderDecompress") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 1 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `BrotliDecoderDecompressStream` function is used in flow sink.
|
||||
* See https://www.brotli.org/decode.html.
|
||||
*/
|
||||
class BrotliDecoderDecompressStreamFunction extends DecompressionFunction {
|
||||
BrotliDecoderDecompressStreamFunction() { this.hasGlobalName("BrotliDecoderDecompressStream") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 2 }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import cpp
|
||||
import semmle.code.cpp.ir.dataflow.TaintTracking
|
||||
import MiniZip
|
||||
import ZlibGzopen
|
||||
import ZlibInflator
|
||||
import ZlibUncompress
|
||||
import LibArchive
|
||||
import ZSTD
|
||||
import Brotli
|
||||
|
||||
/**
|
||||
* The Decompression Sink instances, extend this class to define new decompression sinks.
|
||||
*/
|
||||
abstract class DecompressionFunction extends Function {
|
||||
abstract int getArchiveParameterIndex();
|
||||
}
|
||||
|
||||
/**
|
||||
* The Decompression Flow Steps, extend this class to define new decompression sinks.
|
||||
*/
|
||||
abstract class DecompressionFlowStep extends string {
|
||||
bindingset[this]
|
||||
DecompressionFlowStep() { any() }
|
||||
|
||||
abstract predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE qhelp PUBLIC
|
||||
"-//Semmle//qhelp//EN"
|
||||
"qhelp.dtd">
|
||||
<qhelp>
|
||||
<overview>
|
||||
<p>Extracting Compressed files with any compression algorithm like gzip can cause denial of service attacks.</p>
|
||||
<p>Attackers can compress a huge file consisting of repeated similiar bytes into a small compressed file.</p>
|
||||
</overview>
|
||||
<recommendation>
|
||||
|
||||
<p>When you want to decompress a user-provided compressed file you must be careful about the decompression ratio or read these files within a loop byte by byte to be able to manage the decompressed size in each cycle of the loop.</p>
|
||||
|
||||
</recommendation>
|
||||
<example>
|
||||
|
||||
<p>
|
||||
Reading an uncompressed Gzip file within a loop and check for a threshold size in each cycle.
|
||||
</p>
|
||||
<sample src="example_good.cpp"/>
|
||||
|
||||
<p>
|
||||
The following example is unsafe, as we do not check the uncompressed size.
|
||||
</p>
|
||||
<sample src="example_bad.cpp" />
|
||||
|
||||
</example>
|
||||
|
||||
<references>
|
||||
|
||||
<li>
|
||||
<a href="https://zlib.net/manual.html">Zlib documentation</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.bamsoftware.com/hacks/zipbomb/">An explanation of the attack</a>
|
||||
</li>
|
||||
|
||||
</references>
|
||||
</qhelp>
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @name User-controlled file decompression
|
||||
* @description User-controlled data that flows into decompression library APIs without checking the compression rate is dangerous
|
||||
* @kind path-problem
|
||||
* @problem.severity error
|
||||
* @precision low
|
||||
* @id cpp/data-decompression-bomb
|
||||
* @tags security
|
||||
* experimental
|
||||
* external/cwe/cwe-409
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import semmle.code.cpp.security.FlowSources
|
||||
import DecompressionBomb
|
||||
|
||||
predicate isSink(FunctionCall fc, DataFlow::Node sink) {
|
||||
exists(DecompressionFunction f | fc.getTarget() = f |
|
||||
fc.getArgument(f.getArchiveParameterIndex()) = [sink.asExpr(), sink.asIndirectExpr()]
|
||||
)
|
||||
}
|
||||
|
||||
module DecompressionTaintConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) { source instanceof FlowSource }
|
||||
|
||||
predicate isSink(DataFlow::Node sink) { isSink(_, sink) }
|
||||
|
||||
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
any(DecompressionFlowStep s).isAdditionalFlowStep(node1, node2)
|
||||
}
|
||||
}
|
||||
|
||||
module DecompressionTaint = TaintTracking::Global<DecompressionTaintConfig>;
|
||||
|
||||
import DecompressionTaint::PathGraph
|
||||
|
||||
from DecompressionTaint::PathNode source, DecompressionTaint::PathNode sink, FunctionCall fc
|
||||
where DecompressionTaint::flowPath(source, sink) and isSink(fc, sink.getNode())
|
||||
select sink.getNode(), source, sink, "The decompression output of $@ is not limited", fc,
|
||||
fc.getTarget().getName()
|
||||
32
cpp/ql/src/experimental/Security/CWE/CWE-409/LibArchive.qll
Normal file
32
cpp/ql/src/experimental/Security/CWE/CWE-409/LibArchive.qll
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* https://github.com/libarchive/libarchive/wiki
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `archive_read_data*` functions are used in flow sink.
|
||||
* See https://github.com/libarchive/libarchive/wiki/Examples.
|
||||
*/
|
||||
class Archive_read_data_block extends DecompressionFunction {
|
||||
Archive_read_data_block() {
|
||||
this.hasGlobalName(["archive_read_data_block", "archive_read_data", "archive_read_data_into_fd"])
|
||||
}
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `archive_read_open_filename` function as a flow step.
|
||||
*/
|
||||
class ReadOpenFunctionStep extends DecompressionFlowStep {
|
||||
ReadOpenFunctionStep() { this = "ReadOpenFunction" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc | fc.getTarget().hasGlobalName("archive_read_open_filename") |
|
||||
node1.asIndirectExpr() = fc.getArgument(1) and
|
||||
node2.asIndirectExpr() = fc.getArgument(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
56
cpp/ql/src/experimental/Security/CWE/CWE-409/MiniZip.qll
Normal file
56
cpp/ql/src/experimental/Security/CWE/CWE-409/MiniZip.qll
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* https://github.com/zlib-ng/minizip-ng
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `mz_zip_entry` function is used in flow sink.
|
||||
* See https://github.com/zlib-ng/minizip-ng/blob/master/doc/mz_zip.md.
|
||||
*/
|
||||
class Mz_zip_entry extends DecompressionFunction {
|
||||
Mz_zip_entry() { this.hasGlobalName("mz_zip_entry_read") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 1 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `mz_zip_reader_entry_*` and `mz_zip_reader_save_all` functions are used in flow sink.
|
||||
* See https://github.com/zlib-ng/minizip-ng/blob/master/doc/mz_zip_rw.md.
|
||||
*/
|
||||
class Mz_zip_reader_entry extends DecompressionFunction {
|
||||
Mz_zip_reader_entry() {
|
||||
this.hasGlobalName([
|
||||
"mz_zip_reader_entry_save", "mz_zip_reader_entry_read", "mz_zip_reader_entry_save_process",
|
||||
"mz_zip_reader_entry_save_file", "mz_zip_reader_entry_save_buffer", "mz_zip_reader_save_all"
|
||||
])
|
||||
}
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `UnzOpen*` functions are used in flow sink.
|
||||
*/
|
||||
class UnzOpenFunction extends DecompressionFunction {
|
||||
UnzOpenFunction() { this.hasGlobalName(["UnzOpen", "unzOpen64", "unzOpen2", "unzOpen2_64"]) }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `mz_zip_reader_open_file` and `mz_zip_reader_open_file_in_memory` functions as a flow step.
|
||||
*/
|
||||
class ReaderOpenFunctionStep extends DecompressionFlowStep {
|
||||
ReaderOpenFunctionStep() { this = "ReaderOpenFunctionStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc |
|
||||
fc.getTarget().hasGlobalName(["mz_zip_reader_open_file_in_memory", "mz_zip_reader_open_file"])
|
||||
|
|
||||
node1.asIndirectExpr() = fc.getArgument(1) and
|
||||
node2.asIndirectExpr() = fc.getArgument(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
88
cpp/ql/src/experimental/Security/CWE/CWE-409/ZSTD.qll
Normal file
88
cpp/ql/src/experimental/Security/CWE/CWE-409/ZSTD.qll
Normal file
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* https://github.com/facebook/zstd/blob/dev/examples/streaming_decompression.c
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `ZSTD_decompress` function is used in flow sink.
|
||||
*/
|
||||
class ZstdDecompressFunction extends DecompressionFunction {
|
||||
ZstdDecompressFunction() { this.hasGlobalName("ZSTD_decompress") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 2 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `ZSTD_decompressDCtx` function is used in flow sink.
|
||||
*/
|
||||
class ZstdDecompressDctxFunction extends DecompressionFunction {
|
||||
ZstdDecompressDctxFunction() { this.hasGlobalName("ZSTD_decompressDCtx") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 3 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `ZSTD_decompressStream` function is used in flow sink.
|
||||
*/
|
||||
class ZstdDecompressStreamFunction extends DecompressionFunction {
|
||||
ZstdDecompressStreamFunction() { this.hasGlobalName("ZSTD_decompressStream") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 2 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `ZSTD_decompress_usingDDict` function is used in flow sink.
|
||||
*/
|
||||
class ZstdDecompressUsingDdictFunction extends DecompressionFunction {
|
||||
ZstdDecompressUsingDdictFunction() { this.hasGlobalName("ZSTD_decompress_usingDDict") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 3 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `fopen_orDie` function as a flow step.
|
||||
*/
|
||||
class FopenOrDieFunctionStep extends DecompressionFlowStep {
|
||||
FopenOrDieFunctionStep() { this = "FopenOrDieFunctionStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc | fc.getTarget().hasGlobalName("fopen_orDie") |
|
||||
node1.asIndirectExpr() = fc.getArgument(0) and
|
||||
node2.asExpr() = fc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The `fread_orDie` function as a flow step.
|
||||
*/
|
||||
class FreadOrDieFunctionStep extends DecompressionFlowStep {
|
||||
FreadOrDieFunctionStep() { this = "FreadOrDieFunctionStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc | fc.getTarget().hasGlobalName("fread_orDie") |
|
||||
node1.asExpr() = fc.getArgument(2) and
|
||||
node2.asIndirectExpr() = fc.getArgument(0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The `src` member of a `ZSTD_inBuffer` variable is used in a flow steps.
|
||||
*/
|
||||
class SrcMember extends DecompressionFlowStep {
|
||||
SrcMember() { this = "SrcMember" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(VariableAccess inBufferAccess, Field srcField, ClassAggregateLiteral c |
|
||||
inBufferAccess.getType().hasName("ZSTD_inBuffer") and
|
||||
srcField.hasName("src")
|
||||
|
|
||||
node2.asExpr() = inBufferAccess and
|
||||
inBufferAccess.getTarget().getInitializer().getExpr() = c and
|
||||
node1.asIndirectExpr() = c.getFieldExpr(srcField, _)
|
||||
)
|
||||
}
|
||||
}
|
||||
71
cpp/ql/src/experimental/Security/CWE/CWE-409/ZlibGzopen.qll
Normal file
71
cpp/ql/src/experimental/Security/CWE/CWE-409/ZlibGzopen.qll
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* https://www.zlib.net/
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `gzfread` function is used in flow sink.
|
||||
*
|
||||
* `gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file)`
|
||||
*/
|
||||
class GzFreadFunction extends DecompressionFunction {
|
||||
GzFreadFunction() { this.hasGlobalName("gzfread") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 3 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `gzgets` function is used in flow sink.
|
||||
*
|
||||
* `gzgets(gzFile file, char *buf, int len)`
|
||||
*/
|
||||
class GzGetsFunction extends DecompressionFunction {
|
||||
GzGetsFunction() { this.hasGlobalName("gzgets") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `gzread` function is used in flow sink.
|
||||
*
|
||||
* `gzread(gzFile file, voidp buf, unsigned len)`
|
||||
*/
|
||||
class GzReadFunction extends DecompressionFunction {
|
||||
GzReadFunction() { this.hasGlobalName("gzread") }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `gzdopen` function is used in flow steps.
|
||||
*
|
||||
* `gzdopen(int fd, const char *mode)`
|
||||
*/
|
||||
class GzdopenFunctionStep extends DecompressionFlowStep {
|
||||
GzdopenFunctionStep() { this = "GzdopenFunctionStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc | fc.getTarget().hasGlobalName("gzdopen") |
|
||||
node1.asExpr() = fc.getArgument(0) and
|
||||
node2.asExpr() = fc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The `gzopen` function is used in flow steps.
|
||||
*
|
||||
* `gzopen(const char *path, const char *mode)`
|
||||
*/
|
||||
class GzopenFunctionStep extends DecompressionFlowStep {
|
||||
GzopenFunctionStep() { this = "GzopenFunctionStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(FunctionCall fc | fc.getTarget().hasGlobalName("gzopen") |
|
||||
node1.asIndirectExpr() = fc.getArgument(0) and
|
||||
node2.asExpr() = fc
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* https://www.zlib.net/
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `inflate` and `inflateSync` functions are used in flow sink.
|
||||
*
|
||||
* `inflate(z_stream strm, int flush)`
|
||||
*
|
||||
* `inflateSync(z_stream strm)`
|
||||
*/
|
||||
class InflateFunction extends DecompressionFunction {
|
||||
InflateFunction() { this.hasGlobalName(["inflate", "inflateSync"]) }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 0 }
|
||||
}
|
||||
|
||||
/**
|
||||
* The `next_in` member of a `z_stream` variable is used in a flow steps.
|
||||
*/
|
||||
class NextInMemberStep extends DecompressionFlowStep {
|
||||
NextInMemberStep() { this = "NextInMemberStep" }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(Variable nextInVar |
|
||||
nextInVar.getDeclaringType().hasName("z_stream") and
|
||||
nextInVar.hasName("next_in")
|
||||
|
|
||||
node1.asIndirectExpr() = nextInVar.getAnAssignedValue() and
|
||||
node2.asExpr() =
|
||||
nextInVar.getAnAccess().getQualifier().(VariableAccess).getTarget().getAnAccess()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* https://www.zlib.net/
|
||||
*/
|
||||
|
||||
import cpp
|
||||
import DecompressionBomb
|
||||
|
||||
/**
|
||||
* The `uncompress`/`uncompress2` function is used in flow sink.
|
||||
*/
|
||||
class UncompressFunction extends DecompressionFunction {
|
||||
UncompressFunction() { this.hasGlobalName(["uncompress", "uncompress2"]) }
|
||||
|
||||
override int getArchiveParameterIndex() { result = 2 }
|
||||
}
|
||||
15
cpp/ql/src/experimental/Security/CWE/CWE-409/example_bad.cpp
Normal file
15
cpp/ql/src/experimental/Security/CWE/CWE-409/example_bad.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "zlib.h"
|
||||
|
||||
void UnsafeGzread(gzFile inFileZ) {
|
||||
const int BUFFER_SIZE = 8192;
|
||||
unsigned char unzipBuffer[BUFFER_SIZE];
|
||||
unsigned int unzippedBytes;
|
||||
while (true) {
|
||||
unzippedBytes = gzread(inFileZ, unzipBuffer, BUFFER_SIZE);
|
||||
if (unzippedBytes <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// process buffer
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "zlib.h"
|
||||
|
||||
void SafeGzread(gzFile inFileZ) {
|
||||
const int MAX_READ = 1024 * 1024 * 4;
|
||||
const int BUFFER_SIZE = 8192;
|
||||
unsigned char unzipBuffer[BUFFER_SIZE];
|
||||
unsigned int unzippedBytes;
|
||||
unsigned int totalRead = 0;
|
||||
while (true) {
|
||||
unzippedBytes = gzread(inFileZ, unzipBuffer, BUFFER_SIZE);
|
||||
totalRead += unzippedBytes;
|
||||
if (unzippedBytes <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (totalRead > MAX_READ) {
|
||||
// Possible decompression bomb, stop processing.
|
||||
break;
|
||||
} else {
|
||||
// process buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
name: codeql/cpp-queries
|
||||
version: 1.2.2-dev
|
||||
version: 1.2.3
|
||||
groups:
|
||||
- cpp
|
||||
- queries
|
||||
|
||||
@@ -0,0 +1,239 @@
|
||||
edges
|
||||
| brotliTest.cpp:15:41:15:44 | **argv | brotliTest.cpp:15:41:15:44 | **argv | provenance | |
|
||||
| brotliTest.cpp:15:41:15:44 | **argv | brotliTest.cpp:18:35:18:53 | *access to array | provenance | |
|
||||
| brotliTest.cpp:15:41:15:44 | **argv | brotliTest.cpp:21:30:21:52 | *access to array | provenance | |
|
||||
| brotliTest.cpp:21:30:21:52 | *access to array | brotliTest.cpp:24:51:24:58 | **& ... | provenance | |
|
||||
| libarchiveTests.cpp:16:31:16:32 | *ar | libarchiveTests.cpp:16:31:16:32 | *ar | provenance | |
|
||||
| libarchiveTests.cpp:16:31:16:32 | *ar | libarchiveTests.cpp:22:41:22:42 | *ar | provenance | |
|
||||
| libarchiveTests.cpp:30:45:30:48 | **argv | libarchiveTests.cpp:30:45:30:48 | **argv | provenance | |
|
||||
| libarchiveTests.cpp:30:45:30:48 | **argv | libarchiveTests.cpp:34:35:34:41 | *access to array | provenance | |
|
||||
| libarchiveTests.cpp:34:32:34:32 | *a | libarchiveTests.cpp:38:27:38:27 | *a | provenance | |
|
||||
| libarchiveTests.cpp:34:35:34:41 | *access to array | libarchiveTests.cpp:34:32:34:32 | *a | provenance | Config |
|
||||
| libarchiveTests.cpp:38:27:38:27 | *a | libarchiveTests.cpp:16:31:16:32 | *ar | provenance | |
|
||||
| libarchiveTests.cpp:38:27:38:27 | *a | libarchiveTests.cpp:38:27:38:27 | read_data output argument | provenance | |
|
||||
| libarchiveTests.cpp:38:27:38:27 | read_data output argument | libarchiveTests.cpp:38:27:38:27 | *a | provenance | |
|
||||
| main.cpp:7:33:7:36 | **argv | main.cpp:8:23:8:26 | **argv | provenance | |
|
||||
| main.cpp:7:33:7:36 | **argv | main.cpp:9:27:9:30 | **argv | provenance | |
|
||||
| main.cpp:7:33:7:36 | **argv | main.cpp:10:24:10:27 | **argv | provenance | |
|
||||
| main.cpp:7:33:7:36 | **argv | main.cpp:11:21:11:24 | **argv | provenance | |
|
||||
| main.cpp:7:33:7:36 | **argv | main.cpp:12:21:12:24 | **argv | provenance | |
|
||||
| main.cpp:8:23:8:26 | **argv | brotliTest.cpp:15:41:15:44 | **argv | provenance | |
|
||||
| main.cpp:8:23:8:26 | **argv | main.cpp:8:23:8:26 | brotli_test output argument | provenance | |
|
||||
| main.cpp:8:23:8:26 | brotli_test output argument | main.cpp:9:27:9:30 | **argv | provenance | |
|
||||
| main.cpp:8:23:8:26 | brotli_test output argument | main.cpp:10:24:10:27 | **argv | provenance | |
|
||||
| main.cpp:8:23:8:26 | brotli_test output argument | main.cpp:11:21:11:24 | **argv | provenance | |
|
||||
| main.cpp:8:23:8:26 | brotli_test output argument | main.cpp:12:21:12:24 | **argv | provenance | |
|
||||
| main.cpp:9:27:9:30 | **argv | libarchiveTests.cpp:30:45:30:48 | **argv | provenance | |
|
||||
| main.cpp:9:27:9:30 | **argv | main.cpp:9:27:9:30 | libarchive_test output argument | provenance | |
|
||||
| main.cpp:9:27:9:30 | libarchive_test output argument | main.cpp:10:24:10:27 | **argv | provenance | |
|
||||
| main.cpp:9:27:9:30 | libarchive_test output argument | main.cpp:11:21:11:24 | **argv | provenance | |
|
||||
| main.cpp:9:27:9:30 | libarchive_test output argument | main.cpp:12:21:12:24 | **argv | provenance | |
|
||||
| main.cpp:10:24:10:27 | **argv | main.cpp:10:24:10:27 | minizip_test output argument | provenance | |
|
||||
| main.cpp:10:24:10:27 | **argv | minizipTest.cpp:12:42:12:45 | **argv | provenance | |
|
||||
| main.cpp:10:24:10:27 | minizip_test output argument | main.cpp:11:21:11:24 | **argv | provenance | |
|
||||
| main.cpp:10:24:10:27 | minizip_test output argument | main.cpp:12:21:12:24 | **argv | provenance | |
|
||||
| main.cpp:11:21:11:24 | **argv | main.cpp:11:21:11:24 | zlib_test output argument | provenance | |
|
||||
| main.cpp:11:21:11:24 | **argv | main.cpp:11:21:11:24 | zlib_test output argument | provenance | |
|
||||
| main.cpp:11:21:11:24 | **argv | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| main.cpp:11:21:11:24 | zlib_test output argument | main.cpp:12:21:12:24 | **argv | provenance | |
|
||||
| main.cpp:11:21:11:24 | zlib_test output argument | main.cpp:12:21:12:24 | *argv | provenance | |
|
||||
| main.cpp:12:21:12:24 | **argv | zstdTest.cpp:26:39:26:42 | **argv | provenance | |
|
||||
| main.cpp:12:21:12:24 | *argv | zstdTest.cpp:26:39:26:42 | **argv | provenance | |
|
||||
| main.cpp:12:21:12:24 | *argv | zstdTest.cpp:26:39:26:42 | *argv | provenance | |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | minizipTest.cpp:12:42:12:45 | **argv | provenance | |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | minizipTest.cpp:17:52:17:67 | *access to array | provenance | |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | minizipTest.cpp:24:41:24:47 | *access to array | provenance | |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | minizipTest.cpp:28:13:28:19 | *access to array | provenance | |
|
||||
| minizipTest.cpp:24:29:24:38 | **zip_reader | minizipTest.cpp:26:30:26:39 | **zip_reader | provenance | |
|
||||
| minizipTest.cpp:24:29:24:38 | *zip_reader | minizipTest.cpp:26:30:26:39 | *zip_reader | provenance | |
|
||||
| minizipTest.cpp:24:41:24:47 | *access to array | minizipTest.cpp:24:29:24:38 | **zip_reader | provenance | Config |
|
||||
| minizipTest.cpp:24:41:24:47 | *access to array | minizipTest.cpp:24:29:24:38 | *zip_reader | provenance | Config |
|
||||
| zlibTest.cpp:16:26:16:30 | *input | zlibTest.cpp:20:25:20:39 | *input | provenance | |
|
||||
| zlibTest.cpp:20:25:20:39 | *input | zlibTest.cpp:16:26:16:30 | *input | provenance | |
|
||||
| zlibTest.cpp:20:25:20:39 | *input | zlibTest.cpp:24:17:24:26 | & ... | provenance | Config |
|
||||
| zlibTest.cpp:20:25:20:39 | *input | zlibTest.cpp:25:13:25:22 | & ... | provenance | Config |
|
||||
| zlibTest.cpp:24:17:24:26 | & ... | zlibTest.cpp:25:13:25:22 | & ... | provenance | |
|
||||
| zlibTest.cpp:37:25:37:32 | *fileName | zlibTest.cpp:38:29:38:36 | *fileName | provenance | |
|
||||
| zlibTest.cpp:38:22:38:27 | call to gzopen | zlibTest.cpp:38:22:38:27 | call to gzopen | provenance | |
|
||||
| zlibTest.cpp:38:22:38:27 | call to gzopen | zlibTest.cpp:41:20:41:26 | inFileZ | provenance | |
|
||||
| zlibTest.cpp:38:29:38:36 | *fileName | zlibTest.cpp:37:25:37:32 | *fileName | provenance | |
|
||||
| zlibTest.cpp:38:29:38:36 | *fileName | zlibTest.cpp:38:22:38:27 | call to gzopen | provenance | Config |
|
||||
| zlibTest.cpp:47:26:47:33 | *fileName | zlibTest.cpp:48:29:48:36 | *fileName | provenance | |
|
||||
| zlibTest.cpp:48:22:48:27 | call to gzopen | zlibTest.cpp:48:22:48:27 | call to gzopen | provenance | |
|
||||
| zlibTest.cpp:48:22:48:27 | call to gzopen | zlibTest.cpp:51:38:51:44 | inFileZ | provenance | |
|
||||
| zlibTest.cpp:48:29:48:36 | *fileName | zlibTest.cpp:47:26:47:33 | *fileName | provenance | |
|
||||
| zlibTest.cpp:48:29:48:36 | *fileName | zlibTest.cpp:48:22:48:27 | call to gzopen | provenance | Config |
|
||||
| zlibTest.cpp:57:25:57:32 | *fileName | zlibTest.cpp:58:29:58:36 | *fileName | provenance | |
|
||||
| zlibTest.cpp:58:22:58:27 | call to gzopen | zlibTest.cpp:58:22:58:27 | call to gzopen | provenance | |
|
||||
| zlibTest.cpp:58:22:58:27 | call to gzopen | zlibTest.cpp:62:25:62:31 | inFileZ | provenance | |
|
||||
| zlibTest.cpp:58:29:58:36 | *fileName | zlibTest.cpp:57:25:57:32 | *fileName | provenance | |
|
||||
| zlibTest.cpp:58:29:58:36 | *fileName | zlibTest.cpp:58:22:58:27 | call to gzopen | provenance | Config |
|
||||
| zlibTest.cpp:71:26:71:30 | *input | zlibTest.cpp:71:26:71:30 | *input | provenance | |
|
||||
| zlibTest.cpp:71:26:71:30 | *input | zlibTest.cpp:77:45:77:59 | *input | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:81:19:81:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:82:18:82:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:83:19:83:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:84:18:84:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:85:19:85:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | *access to array | zlibTest.cpp:47:26:47:33 | *fileName | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | *access to array | zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:80:33:80:36 | **argv [Return] | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:82:18:82:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:83:19:83:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:84:18:84:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | zlibTest.cpp:85:19:85:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | *access to array | zlibTest.cpp:57:25:57:32 | *fileName | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | *access to array | zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | zlibTest.cpp:80:33:80:36 | **argv [Return] | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | zlibTest.cpp:83:19:83:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | zlibTest.cpp:84:18:84:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | zlibTest.cpp:85:19:85:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | *access to array | zlibTest.cpp:16:26:16:30 | *input | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | *access to array | zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | zlibTest.cpp:80:33:80:36 | **argv [Return] | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | zlibTest.cpp:84:18:84:24 | *access to array | provenance | |
|
||||
| zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | zlibTest.cpp:85:19:85:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:84:18:84:24 | *access to array | zlibTest.cpp:37:25:37:32 | *fileName | provenance | |
|
||||
| zlibTest.cpp:84:18:84:24 | *access to array | zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument | provenance | |
|
||||
| zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument | zlibTest.cpp:80:33:80:36 | **argv [Return] | provenance | |
|
||||
| zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument | zlibTest.cpp:85:19:85:25 | *access to array | provenance | |
|
||||
| zlibTest.cpp:85:19:85:25 | *access to array | zlibTest.cpp:71:26:71:30 | *input | provenance | |
|
||||
| zlibTest.cpp:85:19:85:25 | *access to array | zlibTest.cpp:85:19:85:25 | InflateString output argument | provenance | |
|
||||
| zlibTest.cpp:85:19:85:25 | InflateString output argument | zlibTest.cpp:80:33:80:36 | **argv | provenance | |
|
||||
| zlibTest.cpp:85:19:85:25 | InflateString output argument | zlibTest.cpp:80:33:80:36 | **argv [Return] | provenance | |
|
||||
| zstdTest.cpp:26:39:26:42 | **argv | zstdTest.cpp:27:35:27:41 | *access to array | provenance | |
|
||||
| zstdTest.cpp:26:39:26:42 | *argv | zstdTest.cpp:27:35:27:41 | *access to array | provenance | |
|
||||
| zstdTest.cpp:27:23:27:33 | call to fopen_orDie | zstdTest.cpp:27:23:27:33 | call to fopen_orDie | provenance | |
|
||||
| zstdTest.cpp:27:23:27:33 | call to fopen_orDie | zstdTest.cpp:35:52:35:54 | fin | provenance | |
|
||||
| zstdTest.cpp:27:35:27:41 | *access to array | zstdTest.cpp:27:23:27:33 | call to fopen_orDie | provenance | Config |
|
||||
| zstdTest.cpp:35:32:35:37 | **buffIn | zstdTest.cpp:36:32:36:37 | **buffIn | provenance | |
|
||||
| zstdTest.cpp:35:32:35:37 | *buffIn | zstdTest.cpp:36:32:36:37 | *buffIn | provenance | |
|
||||
| zstdTest.cpp:35:52:35:54 | fin | zstdTest.cpp:35:32:35:37 | **buffIn | provenance | Config |
|
||||
| zstdTest.cpp:35:52:35:54 | fin | zstdTest.cpp:35:32:35:37 | *buffIn | provenance | Config |
|
||||
| zstdTest.cpp:36:32:36:37 | **buffIn | zstdTest.cpp:35:32:35:37 | **buffIn | provenance | |
|
||||
| zstdTest.cpp:36:32:36:37 | **buffIn | zstdTest.cpp:39:69:39:74 | & ... | provenance | Config |
|
||||
| zstdTest.cpp:36:32:36:37 | **buffIn | zstdTest.cpp:39:69:39:74 | & ... | provenance | Config |
|
||||
| zstdTest.cpp:36:32:36:37 | *buffIn | zstdTest.cpp:35:32:35:37 | *buffIn | provenance | |
|
||||
| zstdTest.cpp:36:32:36:37 | *buffIn | zstdTest.cpp:39:69:39:74 | & ... | provenance | Config |
|
||||
| zstdTest.cpp:36:32:36:37 | *buffIn | zstdTest.cpp:39:69:39:74 | & ... | provenance | Config |
|
||||
| zstdTest.cpp:39:69:39:74 | & ... | zstdTest.cpp:39:69:39:74 | & ... | provenance | |
|
||||
| zstdTest.cpp:39:69:39:74 | & ... | zstdTest.cpp:39:69:39:74 | & ... | provenance | |
|
||||
nodes
|
||||
| brotliTest.cpp:15:41:15:44 | **argv | semmle.label | **argv |
|
||||
| brotliTest.cpp:15:41:15:44 | **argv | semmle.label | **argv |
|
||||
| brotliTest.cpp:18:35:18:53 | *access to array | semmle.label | *access to array |
|
||||
| brotliTest.cpp:21:30:21:52 | *access to array | semmle.label | *access to array |
|
||||
| brotliTest.cpp:24:51:24:58 | **& ... | semmle.label | **& ... |
|
||||
| libarchiveTests.cpp:16:31:16:32 | *ar | semmle.label | *ar |
|
||||
| libarchiveTests.cpp:16:31:16:32 | *ar | semmle.label | *ar |
|
||||
| libarchiveTests.cpp:22:41:22:42 | *ar | semmle.label | *ar |
|
||||
| libarchiveTests.cpp:30:45:30:48 | **argv | semmle.label | **argv |
|
||||
| libarchiveTests.cpp:30:45:30:48 | **argv | semmle.label | **argv |
|
||||
| libarchiveTests.cpp:34:32:34:32 | *a | semmle.label | *a |
|
||||
| libarchiveTests.cpp:34:35:34:41 | *access to array | semmle.label | *access to array |
|
||||
| libarchiveTests.cpp:38:27:38:27 | *a | semmle.label | *a |
|
||||
| libarchiveTests.cpp:38:27:38:27 | read_data output argument | semmle.label | read_data output argument |
|
||||
| main.cpp:7:33:7:36 | **argv | semmle.label | **argv |
|
||||
| main.cpp:8:23:8:26 | **argv | semmle.label | **argv |
|
||||
| main.cpp:8:23:8:26 | brotli_test output argument | semmle.label | brotli_test output argument |
|
||||
| main.cpp:9:27:9:30 | **argv | semmle.label | **argv |
|
||||
| main.cpp:9:27:9:30 | libarchive_test output argument | semmle.label | libarchive_test output argument |
|
||||
| main.cpp:10:24:10:27 | **argv | semmle.label | **argv |
|
||||
| main.cpp:10:24:10:27 | minizip_test output argument | semmle.label | minizip_test output argument |
|
||||
| main.cpp:11:21:11:24 | **argv | semmle.label | **argv |
|
||||
| main.cpp:11:21:11:24 | zlib_test output argument | semmle.label | zlib_test output argument |
|
||||
| main.cpp:11:21:11:24 | zlib_test output argument | semmle.label | zlib_test output argument |
|
||||
| main.cpp:12:21:12:24 | **argv | semmle.label | **argv |
|
||||
| main.cpp:12:21:12:24 | *argv | semmle.label | *argv |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | semmle.label | **argv |
|
||||
| minizipTest.cpp:12:42:12:45 | **argv | semmle.label | **argv |
|
||||
| minizipTest.cpp:17:52:17:67 | *access to array | semmle.label | *access to array |
|
||||
| minizipTest.cpp:24:29:24:38 | **zip_reader | semmle.label | **zip_reader |
|
||||
| minizipTest.cpp:24:29:24:38 | *zip_reader | semmle.label | *zip_reader |
|
||||
| minizipTest.cpp:24:41:24:47 | *access to array | semmle.label | *access to array |
|
||||
| minizipTest.cpp:26:30:26:39 | **zip_reader | semmle.label | **zip_reader |
|
||||
| minizipTest.cpp:26:30:26:39 | *zip_reader | semmle.label | *zip_reader |
|
||||
| minizipTest.cpp:28:13:28:19 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:16:26:16:30 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:16:26:16:30 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:20:25:20:39 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:24:17:24:26 | & ... | semmle.label | & ... |
|
||||
| zlibTest.cpp:25:13:25:22 | & ... | semmle.label | & ... |
|
||||
| zlibTest.cpp:37:25:37:32 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:37:25:37:32 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:38:22:38:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:38:22:38:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:38:29:38:36 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:41:20:41:26 | inFileZ | semmle.label | inFileZ |
|
||||
| zlibTest.cpp:47:26:47:33 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:47:26:47:33 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:48:22:48:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:48:22:48:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:48:29:48:36 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:51:38:51:44 | inFileZ | semmle.label | inFileZ |
|
||||
| zlibTest.cpp:57:25:57:32 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:57:25:57:32 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:58:22:58:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:58:22:58:27 | call to gzopen | semmle.label | call to gzopen |
|
||||
| zlibTest.cpp:58:29:58:36 | *fileName | semmle.label | *fileName |
|
||||
| zlibTest.cpp:62:25:62:31 | inFileZ | semmle.label | inFileZ |
|
||||
| zlibTest.cpp:71:26:71:30 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:71:26:71:30 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:77:45:77:59 | *input | semmle.label | *input |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | semmle.label | **argv |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv | semmle.label | **argv |
|
||||
| zlibTest.cpp:80:33:80:36 | **argv [Return] | semmle.label | **argv [Return] |
|
||||
| zlibTest.cpp:81:19:81:25 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument | semmle.label | UnsafeGzfread output argument |
|
||||
| zlibTest.cpp:82:18:82:24 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument | semmle.label | UnsafeGzgets output argument |
|
||||
| zlibTest.cpp:83:19:83:25 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument | semmle.label | UnsafeInflate output argument |
|
||||
| zlibTest.cpp:84:18:84:24 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument | semmle.label | UnsafeGzread output argument |
|
||||
| zlibTest.cpp:85:19:85:25 | *access to array | semmle.label | *access to array |
|
||||
| zlibTest.cpp:85:19:85:25 | InflateString output argument | semmle.label | InflateString output argument |
|
||||
| zstdTest.cpp:26:39:26:42 | **argv | semmle.label | **argv |
|
||||
| zstdTest.cpp:26:39:26:42 | *argv | semmle.label | *argv |
|
||||
| zstdTest.cpp:27:23:27:33 | call to fopen_orDie | semmle.label | call to fopen_orDie |
|
||||
| zstdTest.cpp:27:23:27:33 | call to fopen_orDie | semmle.label | call to fopen_orDie |
|
||||
| zstdTest.cpp:27:35:27:41 | *access to array | semmle.label | *access to array |
|
||||
| zstdTest.cpp:35:32:35:37 | **buffIn | semmle.label | **buffIn |
|
||||
| zstdTest.cpp:35:32:35:37 | *buffIn | semmle.label | *buffIn |
|
||||
| zstdTest.cpp:35:52:35:54 | fin | semmle.label | fin |
|
||||
| zstdTest.cpp:36:32:36:37 | **buffIn | semmle.label | **buffIn |
|
||||
| zstdTest.cpp:36:32:36:37 | *buffIn | semmle.label | *buffIn |
|
||||
| zstdTest.cpp:39:69:39:74 | & ... | semmle.label | & ... |
|
||||
| zstdTest.cpp:39:69:39:74 | & ... | semmle.label | & ... |
|
||||
subpaths
|
||||
| libarchiveTests.cpp:38:27:38:27 | *a | libarchiveTests.cpp:16:31:16:32 | *ar | libarchiveTests.cpp:16:31:16:32 | *ar | libarchiveTests.cpp:38:27:38:27 | read_data output argument |
|
||||
| main.cpp:8:23:8:26 | **argv | brotliTest.cpp:15:41:15:44 | **argv | brotliTest.cpp:15:41:15:44 | **argv | main.cpp:8:23:8:26 | brotli_test output argument |
|
||||
| main.cpp:9:27:9:30 | **argv | libarchiveTests.cpp:30:45:30:48 | **argv | libarchiveTests.cpp:30:45:30:48 | **argv | main.cpp:9:27:9:30 | libarchive_test output argument |
|
||||
| main.cpp:10:24:10:27 | **argv | minizipTest.cpp:12:42:12:45 | **argv | minizipTest.cpp:12:42:12:45 | **argv | main.cpp:10:24:10:27 | minizip_test output argument |
|
||||
| main.cpp:11:21:11:24 | **argv | zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:80:33:80:36 | **argv | main.cpp:11:21:11:24 | zlib_test output argument |
|
||||
| main.cpp:11:21:11:24 | **argv | zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:80:33:80:36 | **argv [Return] | main.cpp:11:21:11:24 | zlib_test output argument |
|
||||
| main.cpp:11:21:11:24 | **argv | zlibTest.cpp:80:33:80:36 | **argv | zlibTest.cpp:80:33:80:36 | **argv [Return] | main.cpp:11:21:11:24 | zlib_test output argument |
|
||||
| zlibTest.cpp:81:19:81:25 | *access to array | zlibTest.cpp:47:26:47:33 | *fileName | zlibTest.cpp:47:26:47:33 | *fileName | zlibTest.cpp:81:19:81:25 | UnsafeGzfread output argument |
|
||||
| zlibTest.cpp:82:18:82:24 | *access to array | zlibTest.cpp:57:25:57:32 | *fileName | zlibTest.cpp:57:25:57:32 | *fileName | zlibTest.cpp:82:18:82:24 | UnsafeGzgets output argument |
|
||||
| zlibTest.cpp:83:19:83:25 | *access to array | zlibTest.cpp:16:26:16:30 | *input | zlibTest.cpp:16:26:16:30 | *input | zlibTest.cpp:83:19:83:25 | UnsafeInflate output argument |
|
||||
| zlibTest.cpp:84:18:84:24 | *access to array | zlibTest.cpp:37:25:37:32 | *fileName | zlibTest.cpp:37:25:37:32 | *fileName | zlibTest.cpp:84:18:84:24 | UnsafeGzread output argument |
|
||||
| zlibTest.cpp:85:19:85:25 | *access to array | zlibTest.cpp:71:26:71:30 | *input | zlibTest.cpp:71:26:71:30 | *input | zlibTest.cpp:85:19:85:25 | InflateString output argument |
|
||||
#select
|
||||
| brotliTest.cpp:18:35:18:53 | *access to array | main.cpp:7:33:7:36 | **argv | brotliTest.cpp:18:35:18:53 | *access to array | The decompression output of $@ is not limited | brotliTest.cpp:18:5:18:27 | call to BrotliDecoderDecompress | BrotliDecoderDecompress |
|
||||
| brotliTest.cpp:24:51:24:58 | **& ... | main.cpp:7:33:7:36 | **argv | brotliTest.cpp:24:51:24:58 | **& ... | The decompression output of $@ is not limited | brotliTest.cpp:24:5:24:33 | call to BrotliDecoderDecompressStream | BrotliDecoderDecompressStream |
|
||||
| libarchiveTests.cpp:22:41:22:42 | *ar | main.cpp:7:33:7:36 | **argv | libarchiveTests.cpp:22:41:22:42 | *ar | The decompression output of $@ is not limited | libarchiveTests.cpp:22:17:22:39 | call to archive_read_data_block | archive_read_data_block |
|
||||
| minizipTest.cpp:17:52:17:67 | *access to array | main.cpp:7:33:7:36 | **argv | minizipTest.cpp:17:52:17:67 | *access to array | The decompression output of $@ is not limited | minizipTest.cpp:17:22:17:38 | call to mz_zip_entry_read | mz_zip_entry_read |
|
||||
| minizipTest.cpp:26:30:26:39 | **zip_reader | main.cpp:7:33:7:36 | **argv | minizipTest.cpp:26:30:26:39 | **zip_reader | The decompression output of $@ is not limited | minizipTest.cpp:26:5:26:28 | call to mz_zip_reader_entry_save | mz_zip_reader_entry_save |
|
||||
| minizipTest.cpp:26:30:26:39 | *zip_reader | main.cpp:7:33:7:36 | **argv | minizipTest.cpp:26:30:26:39 | *zip_reader | The decompression output of $@ is not limited | minizipTest.cpp:26:5:26:28 | call to mz_zip_reader_entry_save | mz_zip_reader_entry_save |
|
||||
| minizipTest.cpp:28:13:28:19 | *access to array | main.cpp:7:33:7:36 | **argv | minizipTest.cpp:28:13:28:19 | *access to array | The decompression output of $@ is not limited | minizipTest.cpp:28:5:28:11 | call to UnzOpen | UnzOpen |
|
||||
| zlibTest.cpp:25:13:25:22 | & ... | main.cpp:7:33:7:36 | **argv | zlibTest.cpp:25:13:25:22 | & ... | The decompression output of $@ is not limited | zlibTest.cpp:25:5:25:11 | call to inflate | inflate |
|
||||
| zlibTest.cpp:41:20:41:26 | inFileZ | main.cpp:7:33:7:36 | **argv | zlibTest.cpp:41:20:41:26 | inFileZ | The decompression output of $@ is not limited | zlibTest.cpp:41:13:41:18 | call to gzread | gzread |
|
||||
| zlibTest.cpp:51:38:51:44 | inFileZ | main.cpp:7:33:7:36 | **argv | zlibTest.cpp:51:38:51:44 | inFileZ | The decompression output of $@ is not limited | zlibTest.cpp:51:14:51:20 | call to gzfread | gzfread |
|
||||
| zlibTest.cpp:62:25:62:31 | inFileZ | main.cpp:7:33:7:36 | **argv | zlibTest.cpp:62:25:62:31 | inFileZ | The decompression output of $@ is not limited | zlibTest.cpp:62:18:62:23 | call to gzgets | gzgets |
|
||||
| zlibTest.cpp:77:45:77:59 | *input | main.cpp:7:33:7:36 | **argv | zlibTest.cpp:77:45:77:59 | *input | The decompression output of $@ is not limited | zlibTest.cpp:77:5:77:14 | call to uncompress | uncompress |
|
||||
| zstdTest.cpp:39:69:39:74 | & ... | main.cpp:7:33:7:36 | **argv | zstdTest.cpp:39:69:39:74 | & ... | The decompression output of $@ is not limited | zstdTest.cpp:39:32:39:52 | call to ZSTD_decompressStream | ZSTD_decompressStream |
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-409/DecompressionBombs.ql
|
||||
@@ -0,0 +1,26 @@
|
||||
typedef long unsigned int size_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
enum BrotliDecoderResult {};
|
||||
struct BrotliDecoderState;
|
||||
|
||||
BrotliDecoderResult BrotliDecoderDecompress(
|
||||
size_t encoded_size, const uint8_t encoded_buffer[],
|
||||
size_t *decoded_size, uint8_t decoded_buffer[]);
|
||||
|
||||
BrotliDecoderResult BrotliDecoderDecompressStream(
|
||||
BrotliDecoderState *state, size_t *available_in, const uint8_t **next_in,
|
||||
size_t *available_out, uint8_t **next_out, size_t *total_out);
|
||||
|
||||
void brotli_test(int argc, const char **argv) {
|
||||
uint8_t output[1024];
|
||||
size_t output_size = sizeof(output);
|
||||
BrotliDecoderDecompress(1024, (uint8_t *) argv[2], &output_size, output); // BAD
|
||||
|
||||
size_t input_size = 1024;
|
||||
const uint8_t *input_p = (const uint8_t*)argv[2];
|
||||
uint8_t *output_p = output;
|
||||
size_t out_size;
|
||||
BrotliDecoderDecompressStream(0, &input_size, &input_p, &output_size, // BAD
|
||||
&output_p, &out_size);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#define ARCHIVE_EOF 1
|
||||
#define ARCHIVE_OK 0
|
||||
#define ARCHIVE_WARN (-20)
|
||||
|
||||
struct archive;
|
||||
struct archive_entry;
|
||||
typedef int size_t;
|
||||
typedef int la_int64_t;
|
||||
|
||||
archive *archive_read_new();
|
||||
int archive_read_open_filename(archive *pArchive, const char *filename, int i);
|
||||
int archive_read_next_header(archive *a, archive_entry **entry);
|
||||
int archive_entry_size(archive_entry *pEntry);
|
||||
int archive_read_data_block(archive *pArchive, const void **pVoid, size_t *pInt, la_int64_t *pInt1);
|
||||
|
||||
static int read_data(archive *ar) {
|
||||
for (;;) {
|
||||
const void *buff;
|
||||
size_t size;
|
||||
la_int64_t offset;
|
||||
|
||||
int r = archive_read_data_block(ar, &buff, &size, &offset); // BAD
|
||||
if (r == ARCHIVE_EOF)
|
||||
return ARCHIVE_OK;
|
||||
if (r < ARCHIVE_OK)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
void libarchive_test(int argc, const char **argv) {
|
||||
archive *a = archive_read_new();
|
||||
archive_entry *entry;
|
||||
|
||||
archive_read_open_filename(a, argv[1], 10240);
|
||||
for (;;) {
|
||||
archive_read_next_header(a, &entry);
|
||||
if (archive_entry_size(entry) > 0) {
|
||||
if (read_data(a) < ARCHIVE_WARN)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
void brotli_test(int argc, const char **argv);
|
||||
void libarchive_test(int argc, const char **argv);
|
||||
void minizip_test(int argc, const char **argv);
|
||||
void zlib_test(int argc, const char **argv);
|
||||
void zstd_test(int argc, const char **argv);
|
||||
|
||||
int main(int argc, const char **argv) {
|
||||
brotli_test(argc, argv);
|
||||
libarchive_test(argc, argv);
|
||||
minizip_test(argc, argv);
|
||||
zlib_test(argc, argv);
|
||||
zstd_test(argc, argv);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
typedef signed int int32_t;
|
||||
|
||||
void *mz_zip_reader_create();
|
||||
int32_t mz_zip_reader_open_file(void *handle, const char *path);
|
||||
int32_t mz_zip_reader_goto_first_entry(void *pVoid);
|
||||
int32_t mz_zip_reader_entry_save(void *pVoid, int stream, int write);
|
||||
int32_t mz_zip_entry_read(void *pVoid, void *buf, int32_t i);
|
||||
void UnzOpen(const char *string);
|
||||
|
||||
void *mz_zip_create();
|
||||
|
||||
void minizip_test(int argc, const char **argv) {
|
||||
void *zip_handle = mz_zip_create();
|
||||
int32_t bytes_read;
|
||||
char buf[4096];
|
||||
while(true) {
|
||||
bytes_read = mz_zip_entry_read(zip_handle, (char *) argv[1], sizeof(buf)); // BAD
|
||||
if (bytes_read <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void *zip_reader = mz_zip_reader_create();
|
||||
mz_zip_reader_open_file(zip_reader, argv[1]);
|
||||
mz_zip_reader_goto_first_entry(zip_reader);
|
||||
mz_zip_reader_entry_save(zip_reader, 0, 0); // BAD
|
||||
|
||||
UnzOpen(argv[3]); // BAD
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
typedef unsigned char Bytef;
|
||||
typedef unsigned long uLong;
|
||||
typedef uLong uLongf;
|
||||
typedef unsigned int uInt;
|
||||
|
||||
struct z_stream {
|
||||
Bytef *next_in;
|
||||
Bytef *next_out;
|
||||
uInt avail_out;
|
||||
};
|
||||
|
||||
void inflateInit(z_stream *infstream);
|
||||
void inflate(z_stream *infstream, int i);
|
||||
void inflateEnd(z_stream *infstream);
|
||||
|
||||
void UnsafeInflate(char *input) {
|
||||
unsigned char output[1024];
|
||||
|
||||
z_stream infstream;
|
||||
infstream.next_in = (Bytef *) input; // input char array
|
||||
infstream.avail_out = sizeof(output); // size of output
|
||||
infstream.next_out = output; // output char array
|
||||
|
||||
inflateInit(&infstream);
|
||||
inflate(&infstream, 0); // BAD
|
||||
}
|
||||
|
||||
|
||||
struct gzFile {
|
||||
};
|
||||
|
||||
gzFile gzopen(char *str, const char *rb);
|
||||
unsigned int gzread(gzFile gz_file, unsigned char *str, int i);
|
||||
bool gzfread(char *str, int i, int i1, gzFile gz_file);
|
||||
char *gzgets(gzFile gz_file, char *buffer, int i);
|
||||
|
||||
void UnsafeGzread(char *fileName) {
|
||||
gzFile inFileZ = gzopen(fileName, "rb");
|
||||
unsigned char unzipBuffer[8192];
|
||||
while (true) {
|
||||
if (gzread(inFileZ, unzipBuffer, 8192) <= 0) { // BAD
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnsafeGzfread(char *fileName) {
|
||||
gzFile inFileZ = gzopen(fileName, "rb");
|
||||
while (true) {
|
||||
char buffer[1000];
|
||||
if (!gzfread(buffer, 999, 1, inFileZ)) { // BAD
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UnsafeGzgets(char *fileName) {
|
||||
gzFile inFileZ = gzopen(fileName, "rb");
|
||||
char *buffer = new char[4000000000];
|
||||
char *result;
|
||||
while (true) {
|
||||
result = gzgets(inFileZ, buffer, 1000000000); // BAD
|
||||
if (result == nullptr) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
|
||||
|
||||
void InflateString(char *input) {
|
||||
unsigned char output[1024];
|
||||
|
||||
uLong source_length = 500;
|
||||
uLong destination_length = sizeof(output);
|
||||
|
||||
uncompress(output, &destination_length, (Bytef *) input, source_length); // BAD
|
||||
}
|
||||
|
||||
void zlib_test(int argc, char **argv) {
|
||||
UnsafeGzfread(argv[2]);
|
||||
UnsafeGzgets(argv[2]);
|
||||
UnsafeInflate(argv[2]);
|
||||
UnsafeGzread(argv[2]);
|
||||
InflateString(argv[2]);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
typedef long unsigned int size_t;
|
||||
struct FILE;
|
||||
|
||||
FILE *fopen_orDie(const char *filename, const char *instruction);
|
||||
size_t fread_orDie(void *const pVoid, const size_t read, FILE *const pFile);
|
||||
void *const malloc_orDie(const size_t size);
|
||||
|
||||
struct ZSTD_DCtx;
|
||||
typedef struct ZSTD_inBuffer_s {
|
||||
const void *src;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
} ZSTD_inBuffer;
|
||||
typedef struct ZSTD_outBuffer_s {
|
||||
void *dst;
|
||||
size_t size;
|
||||
size_t pos;
|
||||
} ZSTD_outBuffer;
|
||||
|
||||
const size_t ZSTD_DStreamInSize();
|
||||
const size_t ZSTD_DStreamOutSize();
|
||||
ZSTD_DCtx *const ZSTD_createDCtx();
|
||||
const size_t ZSTD_decompressStream(ZSTD_DCtx *const pCtx, ZSTD_outBuffer *pS, ZSTD_inBuffer *pS1);
|
||||
void CHECK_ZSTD(const size_t ret);
|
||||
|
||||
void zstd_test(int argc, const char **argv) {
|
||||
FILE *const fin = fopen_orDie(argv[1], "rb");
|
||||
size_t const buffInSize = ZSTD_DStreamInSize();
|
||||
void *const buffIn = malloc_orDie(buffInSize);
|
||||
size_t const buffOutSize = ZSTD_DStreamOutSize();
|
||||
void *const buffOut = malloc_orDie(buffOutSize);
|
||||
|
||||
ZSTD_DCtx *const dctx = ZSTD_createDCtx();
|
||||
size_t read;
|
||||
while ((read = fread_orDie(buffIn, buffInSize, fin))) {
|
||||
ZSTD_inBuffer input = {buffIn, read, 0};
|
||||
while (input.pos < input.size) {
|
||||
ZSTD_outBuffer output = {buffOut, buffOutSize, 0};
|
||||
size_t const ret = ZSTD_decompressStream(dctx, &output, &input); // BAD
|
||||
CHECK_ZSTD(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,5 @@
|
||||
| main1.cpp:7:1:7:26 | #include "defines_issue.h" | Include | defines_issue.h | 1 |
|
||||
| main2.cpp:3:1:3:19 | #include "common.h" | Include | common.h | 1 |
|
||||
| main2.cpp:7:1:7:26 | #include "defines_issue.h" | Include | defines_issue.h | 1 |
|
||||
| nameclash.h:3:1:3:27 | #include_next "nameclash.h" | IncludeNext | nameclash.h | 1 |
|
||||
| nameclash.h:3:1:3:27 | #include_next "nameclash.h" | IncludeNext | subdir1/nameclash.h | 1 |
|
||||
| nameclash.h:3:1:3:27 | #include_next "nameclash.h" | IncludeNext | subdir2/nameclash.h | 1 |
|
||||
|
||||
@@ -33,7 +33,7 @@ argHasPostUpdate
|
||||
| test.cpp:67:29:67:35 | source1 | ArgumentNode is missing PostUpdateNode. |
|
||||
| test.cpp:813:19:813:35 | * ... | ArgumentNode is missing PostUpdateNode. |
|
||||
| test.cpp:848:23:848:25 | rpx | ArgumentNode is missing PostUpdateNode. |
|
||||
| test.cpp:1057:19:1057:21 | * ... | ArgumentNode is missing PostUpdateNode. |
|
||||
| test.cpp:1093:19:1093:21 | * ... | ArgumentNode is missing PostUpdateNode. |
|
||||
postWithInFlow
|
||||
| BarrierGuard.cpp:49:6:49:6 | x [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| BarrierGuard.cpp:60:7:60:7 | x [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
@@ -167,15 +167,17 @@ postWithInFlow
|
||||
| test.cpp:932:5:932:19 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:932:6:932:19 | global_pointer [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1045:9:1045:11 | ref arg buf | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1051:5:1051:11 | content [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1052:9:1052:9 | a [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1056:5:1056:7 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1056:6:1056:7 | pp [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1062:53:1062:53 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1072:3:1072:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1072:4:1072:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1073:3:1073:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1073:4:1073:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1066:5:1066:5 | i [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1069:5:1069:5 | i [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1087:5:1087:11 | content [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1088:9:1088:9 | a [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1092:5:1092:7 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1092:6:1092:7 | pp [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1098:53:1098:53 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1108:3:1108:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1108:4:1108:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1109:3:1109:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1109:4:1109:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
|
||||
viableImplInCallContextTooLarge
|
||||
uniqueParameterNodeAtPosition
|
||||
uniqueParameterNodePosition
|
||||
|
||||
@@ -26,6 +26,10 @@ postWithInFlow
|
||||
| test.cpp:400:10:400:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:407:10:407:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1045:9:1045:11 | memset output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1076:2:1076:3 | swap output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1076:10:1076:11 | swap output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1077:2:1077:3 | swap output argument | PostUpdateNode should not be the target of local flow. |
|
||||
| test.cpp:1077:10:1077:11 | swap output argument | PostUpdateNode should not be the target of local flow. |
|
||||
viableImplInCallContextTooLarge
|
||||
uniqueParameterNodeAtPosition
|
||||
uniqueParameterNodePosition
|
||||
|
||||
@@ -202,12 +202,12 @@
|
||||
| test.cpp:489:23:489:29 | *content | test.cpp:490:8:490:17 | * ... |
|
||||
| test.cpp:489:23:489:29 | content | test.cpp:489:23:489:29 | content |
|
||||
| test.cpp:489:23:489:29 | content | test.cpp:490:9:490:17 | p_content |
|
||||
| test.cpp:1050:12:1050:12 | definition of a | test.cpp:1051:3:1051:3 | *a |
|
||||
| test.cpp:1051:3:1051:3 | *a | test.cpp:1052:8:1052:9 | *& ... |
|
||||
| test.cpp:1051:3:1051:3 | *a [post update] | test.cpp:1052:8:1052:9 | *& ... |
|
||||
| test.cpp:1051:3:1051:3 | a | test.cpp:1052:8:1052:9 | & ... |
|
||||
| test.cpp:1051:3:1051:3 | a [post update] | test.cpp:1052:8:1052:9 | & ... |
|
||||
| test.cpp:1051:15:1051:21 | 0 | test.cpp:1051:3:1051:21 | ... = ... |
|
||||
| test.cpp:1051:15:1051:21 | *0 | test.cpp:1051:3:1051:21 | *... = ... |
|
||||
| test.cpp:1052:9:1052:9 | *a | test.cpp:1052:8:1052:9 | *& ... |
|
||||
| test.cpp:1052:9:1052:9 | a | test.cpp:1052:8:1052:9 | & ... |
|
||||
| test.cpp:1086:12:1086:12 | definition of a | test.cpp:1087:3:1087:3 | *a |
|
||||
| test.cpp:1087:3:1087:3 | *a | test.cpp:1088:8:1088:9 | *& ... |
|
||||
| test.cpp:1087:3:1087:3 | *a [post update] | test.cpp:1088:8:1088:9 | *& ... |
|
||||
| test.cpp:1087:3:1087:3 | a | test.cpp:1088:8:1088:9 | & ... |
|
||||
| test.cpp:1087:3:1087:3 | a [post update] | test.cpp:1088:8:1088:9 | & ... |
|
||||
| test.cpp:1087:15:1087:21 | 0 | test.cpp:1087:3:1087:21 | ... = ... |
|
||||
| test.cpp:1087:15:1087:21 | *0 | test.cpp:1087:3:1087:21 | *... = ... |
|
||||
| test.cpp:1088:9:1088:9 | *a | test.cpp:1088:8:1088:9 | *& ... |
|
||||
| test.cpp:1088:9:1088:9 | a | test.cpp:1088:8:1088:9 | & ... |
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user