Skip to content

Commit 99646ba

Browse files
authored
Merge pull request #14367 from github/henrymercer/rc-3.11-mergeback
Merge `rc/3.11` into `main`
2 parents d258f69 + ecd8561 commit 99646ba

File tree

196 files changed

+1394
-662
lines changed

Some content is hidden

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

196 files changed

+1394
-662
lines changed

cpp/ql/lib/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## 0.9.3
2+
3+
No user-facing changes.
4+
5+
## 0.9.2
6+
7+
### Deprecated APIs
8+
9+
* `getAllocatorCall` on `DeleteExpr` and `DeleteArrayExpr` has been deprecated. `getDeallocatorCall` should be used instead.
10+
11+
### New Features
12+
13+
* Added `DeleteOrDeleteArrayExpr` as a super type of `DeleteExpr` and `DeleteArrayExpr`
14+
15+
### Minor Analysis Improvements
16+
17+
* `delete` and `delete[]` are now modeled as calls to the relevant `operator delete` in the IR. In the case of a dynamic delete call a new instruction `VirtualDeleteFunctionAddress` is used to represent a function that dispatches to the correct delete implementation.
18+
* Only the 2 level indirection of `argv` (corresponding to `**argv`) is consided for `FlowSource`.
19+
120
## 0.9.1
221

322
No user-facing changes.

cpp/ql/lib/change-notes/2023-08-24-no-taint-argv-indirections.md

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

cpp/ql/lib/change-notes/2023-08-25-delete-or-delete-array.md

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

cpp/ql/lib/change-notes/2023-08-25-getAllocatorCall-deprecated.md

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

cpp/ql/lib/change-notes/2023-08-29-delete-ir.md

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## 0.9.2
2+
3+
### Deprecated APIs
4+
5+
* `getAllocatorCall` on `DeleteExpr` and `DeleteArrayExpr` has been deprecated. `getDeallocatorCall` should be used instead.
6+
7+
### New Features
8+
9+
* Added `DeleteOrDeleteArrayExpr` as a super type of `DeleteExpr` and `DeleteArrayExpr`
10+
11+
### Minor Analysis Improvements
12+
13+
* `delete` and `delete[]` are now modeled as calls to the relevant `operator delete` in the IR. In the case of a dynamic delete call a new instruction `VirtualDeleteFunctionAddress` is used to represent a function that dispatches to the correct delete implementation.
14+
* Only the 2 level indirection of `argv` (corresponding to `**argv`) is consided for `FlowSource`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.9.3
2+
3+
No user-facing changes.

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

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

cpp/ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cpp-all
2-
version: 0.9.2-dev
2+
version: 0.10.0-dev
33
groups: cpp
44
dbscheme: semmlecode.cpp.dbscheme
55
extractor: cpp

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternals.qll

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,24 @@ private predicate adjustForPointerArith(PostUpdateNode pun, UseOrPhi use) {
645645
)
646646
}
647647

648+
/**
649+
* Holds if `nodeFrom` flows to `nodeTo` because there is `def-use` or
650+
* `use-use` flow from `defOrUse` to `use`.
651+
*
652+
* `uncertain` is `true` if the `defOrUse` is an uncertain definition.
653+
*/
654+
private predicate localSsaFlow(
655+
SsaDefOrUse defOrUse, Node nodeFrom, UseOrPhi use, Node nodeTo, boolean uncertain
656+
) {
657+
nodeToDefOrUse(nodeFrom, defOrUse, uncertain) and
658+
adjacentDefRead(defOrUse, use) and
659+
useToNode(use, nodeTo) and
660+
nodeFrom != nodeTo
661+
}
662+
648663
private predicate ssaFlowImpl(SsaDefOrUse defOrUse, Node nodeFrom, Node nodeTo, boolean uncertain) {
649664
exists(UseOrPhi use |
650-
nodeToDefOrUse(nodeFrom, defOrUse, uncertain) and
651-
adjacentDefRead(defOrUse, use) and
652-
useToNode(use, nodeTo) and
653-
nodeFrom != nodeTo
665+
localSsaFlow(defOrUse, nodeFrom, use, nodeTo, uncertain)
654666
or
655667
// Initial global variable value to a first use
656668
nodeFrom.(InitialGlobalValue).getGlobalDef() = defOrUse and
@@ -728,15 +740,62 @@ private predicate isArgumentOfCallable(DataFlowCall call, Node n) {
728740
)
729741
}
730742

731-
/** Holds if there is def-use or use-use flow from `pun` to `nodeTo`. */
732-
predicate postUpdateFlow(PostUpdateNode pun, Node nodeTo) {
733-
exists(UseOrPhi use, Node preUpdate |
743+
/**
744+
* Holds if there is use-use flow from `pun`'s pre-update node to `n`.
745+
*/
746+
private predicate postUpdateNodeToFirstUse(PostUpdateNode pun, Node n) {
747+
exists(UseOrPhi use |
734748
adjustForPointerArith(pun, use) and
735-
useToNode(use, nodeTo) and
749+
useToNode(use, n)
750+
)
751+
}
752+
753+
private predicate stepUntilNotInCall(DataFlowCall call, Node n1, Node n2) {
754+
isArgumentOfCallable(call, n1) and
755+
exists(Node mid | localSsaFlow(_, n1, _, mid, _) |
756+
isArgumentOfCallable(call, mid) and
757+
stepUntilNotInCall(call, mid, n2)
758+
or
759+
not isArgumentOfCallable(call, mid) and
760+
mid = n2
761+
)
762+
}
763+
764+
bindingset[n1, n2]
765+
pragma[inline_late]
766+
private predicate isArgumentOfSameCall(DataFlowCall call, Node n1, Node n2) {
767+
isArgumentOfCallable(call, n1) and isArgumentOfCallable(call, n2)
768+
}
769+
770+
/**
771+
* Holds if there is def-use or use-use flow from `pun` to `nodeTo`.
772+
*
773+
* Note: This is more complex than it sounds. Consider a call such as:
774+
* ```cpp
775+
* write_first_argument(x, x);
776+
* sink(x);
777+
* ```
778+
* Assume flow comes out of the first argument to `write_first_argument`. We
779+
* don't want flow to go to the `x` that's also an argument to
780+
* `write_first_argument` (because we just flowed out of that function, and we
781+
* don't want to flow back into it again).
782+
*
783+
* We do, however, want flow from the output argument to `x` on the next line, and
784+
* similarly we want flow from the second argument of `write_first_argument` to `x`
785+
* on the next line.
786+
*/
787+
predicate postUpdateFlow(PostUpdateNode pun, Node nodeTo) {
788+
exists(Node preUpdate, Node mid |
736789
preUpdate = pun.getPreUpdateNode() and
737-
not exists(DataFlowCall call |
738-
isArgumentOfCallable(call, preUpdate) and isArgumentOfCallable(call, nodeTo)
790+
postUpdateNodeToFirstUse(pun, mid)
791+
|
792+
exists(DataFlowCall call |
793+
isArgumentOfSameCall(call, preUpdate, mid) and
794+
stepUntilNotInCall(call, mid, nodeTo)
739795
)
796+
or
797+
not isArgumentOfSameCall(_, preUpdate, mid) and
798+
nodeTo = mid
740799
)
741800
}
742801

cpp/ql/src/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
## 0.7.5
2+
3+
No user-facing changes.
4+
5+
## 0.7.4
6+
7+
### New Queries
8+
9+
* Added a new query, `cpp/invalid-pointer-deref`, to detect out-of-bounds pointer reads and writes.
10+
11+
### Minor Analysis Improvements
12+
13+
* The "Comparison where assignment was intended" query (`cpp/compare-where-assign-meant`) no longer reports comparisons that appear in macro expansions.
14+
* Some queries that had repeated results corresponding to different levels of indirection for `argv` now only have a single result.
15+
* The `cpp/non-constant-format` query no longer considers an assignment on the right-hand side of another assignment to be a source of non-constant format strings. As a result, the query may now produce fewer results.
16+
117
## 0.7.3
218

319
No user-facing changes.

cpp/ql/src/change-notes/2023-08-21-invalid-pointer-deref.md

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

cpp/ql/src/change-notes/2023-08-24-no-taint-argv-indirections.md

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

cpp/ql/src/change-notes/2023-08-24-remove-non-constant-assign-sources.md

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

cpp/ql/src/change-notes/2023-08-25-compare-where-assign-meant.md

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## 0.7.4
2+
3+
### New Queries
4+
5+
* Added a new query, `cpp/invalid-pointer-deref`, to detect out-of-bounds pointer reads and writes.
6+
7+
### Minor Analysis Improvements
8+
9+
* The "Comparison where assignment was intended" query (`cpp/compare-where-assign-meant`) no longer reports comparisons that appear in macro expansions.
10+
* Some queries that had repeated results corresponding to different levels of indirection for `argv` now only have a single result.
11+
* The `cpp/non-constant-format` query no longer considers an assignment on the right-hand side of another assignment to be a source of non-constant format strings. As a result, the query may now produce fewer results.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.7.5
2+
3+
No user-facing changes.

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

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

cpp/ql/src/qlpack.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: codeql/cpp-queries
2-
version: 0.7.4-dev
3-
groups:
2+
version: 0.8.0-dev
3+
groups:
44
- cpp
55
- queries
66
dependencies:
7-
codeql/cpp-all: ${workspace}
8-
codeql/suite-helpers: ${workspace}
9-
codeql/util: ${workspace}
7+
codeql/cpp-all: ${workspace}
8+
codeql/suite-helpers: ${workspace}
9+
codeql/util: ${workspace}
1010
suites: codeql-suites
1111
extractor: cpp
1212
defaultSuiteFile: codeql-suites/cpp-code-scanning.qls
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
WARNING: Module TaintedWithPath has been deprecated and may be removed in future (tainted.ql:10,8-47)
22
WARNING: Predicate tainted has been deprecated and may be removed in future (tainted.ql:21,3-28)
3-
failures
43
testFailures
4+
failures

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,4 +788,12 @@ void test_sometimes_calls_sink_switch() {
788788
sometimes_calls_sink_switch(source(), 1);
789789
sometimes_calls_sink_switch(0, 0);
790790
sometimes_calls_sink_switch(source(), 0);
791+
}
792+
793+
void intPointerSource(int *ref_source, const int* another_arg);
794+
795+
void test() {
796+
MyStruct a;
797+
intPointerSource(a.content, a.content);
798+
indirect_sink(a.content); // $ ast ir
791799
}

cpp/ql/test/library-tests/dataflow/dataflow-tests/uninitialized.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@
4646
| test.cpp:595:8:595:9 | xs | test.cpp:597:9:597:10 | xs |
4747
| test.cpp:733:7:733:7 | x | test.cpp:734:41:734:41 | x |
4848
| test.cpp:733:7:733:7 | x | test.cpp:735:8:735:8 | x |
49+
| test.cpp:796:12:796:12 | a | test.cpp:797:20:797:20 | a |
50+
| test.cpp:796:12:796:12 | a | test.cpp:797:31:797:31 | a |
51+
| test.cpp:796:12:796:12 | a | test.cpp:798:17:798:17 | a |

cpp/ql/test/query-tests/Security/CWE/CWE-119/semmle/tests/OverflowDestination.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edges
77
| overflowdestination.cpp:50:52:50:54 | src indirection | overflowdestination.cpp:53:15:53:17 | src indirection |
88
| overflowdestination.cpp:50:52:50:54 | src indirection | overflowdestination.cpp:54:9:54:12 | memcpy output argument |
99
| overflowdestination.cpp:53:9:53:12 | memcpy output argument | overflowdestination.cpp:54:9:54:12 | memcpy output argument |
10+
| overflowdestination.cpp:54:9:54:12 | memcpy output argument | overflowdestination.cpp:54:9:54:12 | memcpy output argument |
1011
| overflowdestination.cpp:57:52:57:54 | src indirection | overflowdestination.cpp:64:16:64:19 | src2 indirection |
1112
| overflowdestination.cpp:73:8:73:10 | fgets output argument | overflowdestination.cpp:75:30:75:32 | src indirection |
1213
| overflowdestination.cpp:73:8:73:10 | fgets output argument | overflowdestination.cpp:76:30:76:32 | src indirection |

csharp/ql/campaigns/Solorigate/lib/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.6.5
2+
3+
No user-facing changes.
4+
5+
## 1.6.4
6+
7+
No user-facing changes.
8+
19
## 1.6.3
210

311
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.6.4
2+
3+
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.6.5
2+
3+
No user-facing changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 1.6.3
2+
lastReleaseVersion: 1.6.5
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: codeql/csharp-solorigate-all
2-
version: 1.6.4-dev
2+
version: 1.7.0-dev
33
groups:
4-
- csharp
5-
- solorigate
4+
- csharp
5+
- solorigate
66
library: true
77
dependencies:
8-
codeql/csharp-all: ${workspace}
8+
codeql/csharp-all: ${workspace}
99
warnOnImplicitThis: true

csharp/ql/campaigns/Solorigate/src/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 1.6.5
2+
3+
No user-facing changes.
4+
5+
## 1.6.4
6+
7+
No user-facing changes.
8+
19
## 1.6.3
210

311
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.6.4
2+
3+
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.6.5
2+
3+
No user-facing changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 1.6.3
2+
lastReleaseVersion: 1.6.5
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: codeql/csharp-solorigate-queries
2-
version: 1.6.4-dev
2+
version: 1.7.0-dev
33
groups:
4-
- csharp
5-
- solorigate
4+
- csharp
5+
- solorigate
66
defaultSuiteFile: codeql-suites/solorigate.qls
77
dependencies:
8-
codeql/csharp-all: ${workspace}
9-
codeql/csharp-solorigate-all: ${workspace}
8+
codeql/csharp-all: ${workspace}
9+
codeql/csharp-solorigate-all: ${workspace}
1010
warnOnImplicitThis: true

csharp/ql/lib/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.7.5
2+
3+
No user-facing changes.
4+
5+
## 0.7.4
6+
7+
### Minor Analysis Improvements
8+
9+
* The `--nostdlib` extractor option for the standalone extractor has been removed.
10+
111
## 0.7.3
212

313
### Minor Analysis Improvements
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
---
2-
category: minorAnalysis
3-
---
4-
* The `--nostdlib` extractor option for the standalone extractor has been removed.
1+
## 0.7.4
2+
3+
### Minor Analysis Improvements
4+
5+
* The `--nostdlib` extractor option for the standalone extractor has been removed.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.7.5
2+
3+
No user-facing changes.

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

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

0 commit comments

Comments
 (0)