Skip to content

Commit 7be44d2

Browse files
author
Paolo Tranquilli
committed
Merge branch 'main' into redsun82/rust-skip-unexpanded-in-libraries
2 parents c3af98b + f6231a3 commit 7be44d2

File tree

133 files changed

+6271
-2754
lines changed

Some content is hidden

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

133 files changed

+6271
-2754
lines changed

.github/workflows/csharp-qltest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ jobs:
6666
# Update existing stubs in the repo with the freshly generated ones
6767
mv "$STUBS_PATH/output/stubs/_frameworks" ql/test/resources/stubs/
6868
git status
69-
codeql test run --threads=0 --search-path "${{ github.workspace }}" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries -- ql/test/library-tests/dataflow/flowsources/aspremote
69+
codeql test run --threads=0 --search-path "${{ github.workspace }}" --check-databases --check-diff-informed --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries -- ql/test/library-tests/dataflow/flowsources/aspremote
7070
env:
7171
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/ruby-qltest-rtjo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ jobs:
3535
key: ruby-qltest
3636
- name: Run QL tests
3737
run: |
38-
codeql test run --dynamic-join-order-mode=all --threads=0 --ram 50000 --search-path "${{ github.workspace }}" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
38+
codeql test run --dynamic-join-order-mode=all --threads=0 --ram 50000 --search-path "${{ github.workspace }}" --check-databases --check-diff-informed --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
3939
env:
4040
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/ruby-qltest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868
key: ruby-qltest
6969
- name: Run QL tests
7070
run: |
71-
codeql test run --threads=0 --ram 50000 --search-path "${{ github.workspace }}" --check-databases --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
71+
codeql test run --threads=0 --ram 50000 --search-path "${{ github.workspace }}" --check-databases --check-diff-informed --check-undefined-labels --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7272
env:
7373
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/swift.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
if: github.repository_owner == 'github'
3333
strategy:
3434
matrix:
35-
runner: [ubuntu-latest, macos-13-xlarge]
35+
runner: [ubuntu-latest, macos-15-xlarge]
3636
fail-fast: false
3737
runs-on: ${{ matrix.runner }}
3838
steps:

Cargo.lock

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ use_repo(
124124
"vendor_ts__tree-sitter-ruby-0.23.1",
125125
"vendor_ts__triomphe-0.1.14",
126126
"vendor_ts__ungrammar-1.16.1",
127+
"vendor_ts__zstd-0.13.3",
127128
)
128129

129130
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

cpp/misc/bulk_generation_targets.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"strategy": "dca",
3+
"language": "cpp",
4+
"targets": [
5+
{ "name": "openssl", "with-sources": false, "with-sinks": false },
6+
{ "name": "sqlite", "with-sources": false, "with-sinks": false }
7+
],
8+
"destination": "cpp/ql/lib/ext/generated"
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: feature
3+
---
4+
* Added the `pCmdLine` arguments of `WinMain` and `wWinMain` as local flow sources.
5+
* Added source models for `GetCommandLineA`, `GetCommandLineW`, `GetEnvironmentStringsA`, `GetEnvironmentStringsW`, `GetEnvironmentVariableA`, and `GetEnvironmentVariableW`.
6+
* Added summary models for `CommandLineToArgvA` and `CommandLineToArgvW`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added local flow source models for `ReadFile`, `ReadFileEx`, `MapViewOfFile`, `MapViewOfFile2`, `MapViewOfFile3`, `MapViewOfFile3FromApp`, `MapViewOfFileEx`, `MapViewOfFileFromApp`, `MapViewOfFileNuma2`, and `NtReadFile`.

cpp/ql/lib/ext/Boost.Asio.model.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# partial model of the Boost::Asio network library
1+
# partial model of the Boost::Asio network library
22
extensions:
33
- addsTo:
44
pack: codeql/cpp-all

cpp/ql/lib/ext/Windows.model.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# partial model of windows system calls
2+
extensions:
3+
- addsTo:
4+
pack: codeql/cpp-all
5+
extensible: sourceModel
6+
data: # namespace, type, subtypes, name, signature, ext, output, kind, provenance
7+
# processenv.h
8+
- ["", "", False, "GetCommandLineA", "", "", "ReturnValue[*]", "local", "manual"]
9+
- ["", "", False, "GetCommandLineW", "", "", "ReturnValue[*]", "local", "manual"]
10+
- ["", "", False, "GetEnvironmentStringsA", "", "", "ReturnValue[*]", "local", "manual"]
11+
- ["", "", False, "GetEnvironmentStringsW", "", "", "ReturnValue[*]", "local", "manual"]
12+
- ["", "", False, "GetEnvironmentVariableA", "", "", "Argument[*1]", "local", "manual"]
13+
- ["", "", False, "GetEnvironmentVariableW", "", "", "Argument[*1]", "local", "manual"]
14+
# fileapi.h
15+
- ["", "", False, "ReadFile", "", "", "Argument[*1]", "local", "manual"]
16+
- ["", "", False, "ReadFileEx", "", "", "Argument[*1]", "local", "manual"]
17+
# memoryapi.h
18+
- ["", "", False, "MapViewOfFile", "", "", "ReturnValue[*]", "local", "manual"]
19+
- ["", "", False, "MapViewOfFile2", "", "", "ReturnValue[*]", "local", "manual"]
20+
- ["", "", False, "MapViewOfFile3", "", "", "ReturnValue[*]", "local", "manual"]
21+
- ["", "", False, "MapViewOfFile3FromApp", "", "", "ReturnValue[*]", "local", "manual"]
22+
- ["", "", False, "MapViewOfFileEx", "", "", "ReturnValue[*]", "local", "manual"]
23+
- ["", "", False, "MapViewOfFileFromApp", "", "", "ReturnValue[*]", "local", "manual"]
24+
- ["", "", False, "MapViewOfFileNuma2", "", "", "ReturnValue[*]", "local", "manual"]
25+
# ntifs.h
26+
- ["", "", False, "NtReadFile", "", "", "Argument[*5]", "local", "manual"]
27+
- addsTo:
28+
pack: codeql/cpp-all
29+
extensible: summaryModel
30+
data: # namespace, type, subtypes, name, signature, ext, input, output, kind, provenance
31+
# shellapi.h
32+
- ["", "", False, "CommandLineToArgvA", "", "", "Argument[*0]", "ReturnValue[**]", "taint", "manual"]
33+
- ["", "", False, "CommandLineToArgvW", "", "", "Argument[*0]", "ReturnValue[**]", "taint", "manual"]
34+
# fileapi.h
35+
- ["", "", False, "ReadFileEx", "", "", "Argument[*3].Field[@hEvent]", "Argument[4].Parameter[*2].Field[@hEvent]", "value", "manual"]

cpp/ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
codeql/xml: ${workspace}
1818
dataExtensions:
1919
- ext/*.model.yml
20-
- ext/generated/*.model.yml
20+
- ext/generated/**/*.model.yml
2121
- ext/deallocation/*.model.yml
2222
- ext/allocation/*.model.yml
2323
warnOnImplicitThis: true

cpp/ql/lib/semmle/code/cpp/security/FlowSources.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private class LocalModelSource extends LocalFlowSource {
5555
}
5656

5757
/**
58-
* A local data flow source that the `argv` parameter to `main` or `wmain`.
58+
* A local data flow source that is the `argv` parameter to `main` or `wmain`.
5959
*/
6060
private class ArgvSource extends LocalFlowSource {
6161
ArgvSource() {
@@ -69,6 +69,21 @@ private class ArgvSource extends LocalFlowSource {
6969
override string getSourceType() { result = "a command-line argument" }
7070
}
7171

72+
/**
73+
* A local data flow source that is the `pCmdLine` parameter to `WinMain` or `wWinMain`.
74+
*/
75+
private class CmdLineSource extends LocalFlowSource {
76+
CmdLineSource() {
77+
exists(Function main, Parameter pCmdLine |
78+
main.hasGlobalName(["WinMain", "wWinMain"]) and
79+
main.getParameter(2) = pCmdLine and
80+
this.asParameter(1) = pCmdLine
81+
)
82+
}
83+
84+
override string getSourceType() { result = "a command-line" }
85+
}
86+
7287
/**
7388
* A remote data flow source that is defined through 'models as data'.
7489
*/

cpp/ql/test/library-tests/dataflow/dataflow-tests/TestBase.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ module IRTest {
124124

125125
/** Common data flow configuration to be used by tests. */
126126
module IRTestAllocationConfig implements DataFlow::ConfigSig {
127+
private import semmle.code.cpp.security.FlowSources
128+
127129
predicate isSource(DataFlow::Node source) {
130+
source instanceof FlowSource
131+
or
128132
source.asExpr().(FunctionCall).getTarget().getName() = "source"
129133
or
130134
source.asIndirectExpr(1).(FunctionCall).getTarget().getName() = "indirect_source"

cpp/ql/test/library-tests/dataflow/dataflow-tests/test-source-sink.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,3 +337,4 @@ irFlow
337337
| true_upon_entry.cpp:70:11:70:16 | call to source | true_upon_entry.cpp:78:8:78:8 | x |
338338
| true_upon_entry.cpp:83:11:83:16 | call to source | true_upon_entry.cpp:86:8:86:8 | x |
339339
| true_upon_entry.cpp:98:11:98:16 | call to source | true_upon_entry.cpp:105:8:105:8 | x |
340+
| winmain.cpp:4:57:4:64 | *pCmdLine | winmain.cpp:6:8:6:16 | * ... |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
void sink(char);
2+
void sink(char*);
3+
4+
int WinMain(void *hInstance, void *hPrevInstance, char *pCmdLine, int nCmdShow) { // $ ast-def=hInstance ast-def=hPrevInstance ast-def=pCmdLine ir-def=*hInstance ir-def=*hPrevInstance ir-def=*pCmdLine
5+
sink(pCmdLine);
6+
sink(*pCmdLine); // $ ir
7+
8+
return 0;
9+
}

0 commit comments

Comments
 (0)