Commit Graph

10829 Commits

Author SHA1 Message Date
Geoffrey White
2e5f7dc8fc C++: QLDoc (mostly placeholder). 2024-03-01 09:59:31 +00:00
Geoffrey White
8faad92cfd C++: Define DataFlowCallable.getUnderlyingCallable and use it to fix some issues. 2024-03-01 09:59:31 +00:00
Geoffrey White
0df10bda0c C++: Post-merge fixup. 2024-02-27 17:32:59 +00:00
Geoffrey White
1da611cc02 Merge branch 'main' into mad 2024-02-27 17:29:45 +00:00
Geoffrey White
bc42e2bc35 C++: Workaround to get the tests passing again. 2024-02-27 17:28:38 +00:00
Geoffrey White
408a550467 Merge pull request #15727 from geoffw0/qldoc4
C++: Mark internal files in the old dataflow library as deprecated
2024-02-26 17:45:05 +00:00
Geoffrey White
2e66392353 C++: Update deprecated note to respect identical files. 2024-02-26 16:38:27 +00:00
Geoffrey White
5c4543f167 C++: Mark internal files in the old dataflow library as deprecated (the public imports already are). 2024-02-26 14:49:10 +00:00
Jeroen Ketema
788100d475 C++: Update test after extractor changes 2024-02-26 10:04:42 +01:00
Tom Hvitved
62b16c0fa3 Share getFileBySourceArchiveName implementation 2024-02-23 11:25:49 +01:00
Mathias Vorreiter Pedersen
0bf29f0a62 Merge branch 'main' into model-experiments 2024-02-22 15:05:53 +00:00
Mathias Vorreiter Pedersen
350d5bf0ce C++: Update QLDoc on 'modeledFlowBarrier'. 2024-02-22 13:30:39 +00:00
Mathias Vorreiter Pedersen
671904d58c C++: Fix QLoc on 'PartialFlowFunction'. 2024-02-22 13:27:10 +00:00
Mathias Vorreiter Pedersen
aca3970c33 C++: Fix QLoc on 'isPartialWrite'. 2024-02-22 13:25:13 +00:00
Jeroen Ketema
f9d391d087 C++: Support destructors for range-based for-loops 2024-02-21 17:26:32 +01:00
Jeroen Ketema
11dc467add C++: Add test where the for loop should call destructors at the end of its body 2024-02-21 14:42:23 +01:00
Jeroen Ketema
8bbfb82f8e Merge pull request #15670 from jketema/destructors7
C++: Add IR tests for destruction of static locals
2024-02-21 12:54:38 +01:00
Jeroen Ketema
57cb7f8218 C++: Update tests after extractor changes related to static variables 2024-02-21 10:22:59 +01:00
Jeroen Ketema
c1f18edfed C++: Add IR tests for destruction of static locals 2024-02-21 10:22:59 +01:00
github-actions[bot]
37f8fa3413 Post-release preparation for codeql-cli-2.16.3 2024-02-20 16:50:47 +00:00
Geoffrey White
5787dcc82d C++: Make getStaticCallTarget() return a DataFlowCallable. 2024-02-20 14:49:51 +00:00
Geoffrey White
356214c11b C++: Implement SummaryReturnNode. 2024-02-20 14:48:02 +00:00
Geoffrey White
5683092d6a C++: Implement SummaryParameterNode. 2024-02-20 14:48:02 +00:00
Geoffrey White
1ace9ee50f C++: Create a proper class for DataFlowCallable, that includes summarized callables. 2024-02-20 14:48:02 +00:00
Geoffrey White
e1a5a84253 C++: Create a proper class for DataFlowCall, that includes summarized callables. 2024-02-20 14:48:02 +00:00
github-actions[bot]
6d061fbc35 Release preparation for version 2.16.3 2024-02-20 14:26:23 +00:00
Jeroen Ketema
7ec95fba6d C++: Add more range-based for-loop IR tests 2024-02-20 09:22:13 +01:00
Jeroen Ketema
2becb3043e Merge pull request #15638 from jketema/destructors5
C++: Support C++20 range-based for initializers
2024-02-19 16:22:23 +01:00
Mathias Vorreiter Pedersen
b927968e88 Merge pull request #15516 from microsoft/51-2cppnon-constant-format-alter-not-const-source
C++: Change sources in `NonConstantFormat.ql`
2024-02-17 00:01:58 +01:00
Geoffrey White
6e13b877bb C++: Add FlowSummaryNode and test it. 2024-02-16 18:06:57 +00:00
Benjamin Rodes
c38376a264 Merge branch '51-2cppnon-constant-format-alter-not-const-source' of https://github.com/microsoft/codeql into 51-2cppnon-constant-format-alter-not-const-source 2024-02-16 10:42:04 -05:00
Mathias Vorreiter Pedersen
7c22146f46 C++: Accept query test changes. 2024-02-16 16:33:44 +01:00
Mathias Vorreiter Pedersen
096073d295 C++: Add change note. 2024-02-16 16:29:34 +01:00
Benjamin Rodes
93f2e856af Formatting update. 2024-02-16 10:28:14 -05:00
Benjamin Rodes
4a9b2d5027 Comment change. 2024-02-16 10:18:07 -05:00
Benjamin Rodes
5b0a3dcdbe Accidental removal of an and. 2024-02-16 10:15:21 -05:00
Benjamin Rodes
95ebbb1bbd Ql alterations for cleanup as part of merge suggestions. 2024-02-16 10:13:50 -05:00
Ben Rodes
1fb7f089ca Update cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql
Co-authored-by: Mathias Vorreiter Pedersen <mathiasvp@github.com>
2024-02-16 10:06:34 -05:00
Jeroen Ketema
dd39fa0bde C++: Support C++20 range-based for initializers 2024-02-16 15:20:14 +01:00
Mathias Vorreiter Pedersen
be54a41593 C++: Accept query test changes. 2024-02-16 15:01:50 +01:00
Mathias Vorreiter Pedersen
06ff46091d C++: Fix joins in 'controlsBlock'. 2024-02-16 14:49:20 +01:00
Mathias Vorreiter Pedersen
b407c86d03 C++: Make Code Scanning happy. 2024-02-16 13:51:34 +01:00
Mathias Vorreiter Pedersen
57c1bf5835 C++: Add file-level QLDoc. 2024-02-16 13:47:02 +01:00
Mathias Vorreiter Pedersen
497592a4d4 C++: Add change note. 2024-02-16 13:36:25 +01:00
Geoffrey White
e187a4a7d6 C++: Add flow summaries to simpleLocalFlowStep. 2024-02-16 12:31:17 +00:00
Mathias Vorreiter Pedersen
9b2019db6b C++: Accept test changes. 2024-02-16 13:10:41 +01:00
Mathias Vorreiter Pedersen
499ab0892f C++: Currently, to catch flow in an example such as:
```cpp
char* source();
void sink(const char*);
int sprintf(char *, const char *, ...);

void call_sprintf(char* path, char* data) {
        sprintf(path, "%s", "abc"); // (1)
        sprintf(path, "%s", data); // (2)
}

void foo() {
        char path[10];
        call_sprintf(path, source()); // (3)
        sink(path);
}
```
we identify that the `*path [post update]` node at `// (2)` is a
`ReturnNodeExt` and since `*data` flows to that node flow will be carried
out to `*path [post update]` at // (3) and thus reach `sink(path)`.

The reason `*path [post update]` at `// 2` is recognized as a `ReturnNodeExt`
is because it satisfies the following condition (which is identified by the
shared dataflow library):
There is flow from the parameter node `*path` to the pre-update node of the
post-update node `*path [post update]` at `// (2)`.

However, when we start recognizing that the call to `sprintf(path, ...)` at
`// (1)` overrides the value of `*path` and no longer provide use-use flow out
of `*path` the `*path [post update]` node at `// (2)` is no longer recognized
as a `ReturnNodeExt` (because it doesn't satisfy the above criteria).

Thus, we need to identify the flow above without relying on the dataflow
library's summary mechanism. That is, instead of relying on the dataflow
library's mechanism to summarize the `*data -> *path` flow for `call_sprintf`
we need to:
- Ensure that the write to `*path` at `// (2)` is recognized as the "final"
write to the parameter, and
- Ensure that there's flow out of that parameter and back to
`*path [post update]` at `// (3)`.

Luckiky, we do all of this already to support flow out of writes to parameters
that don't have post-update nodes. For example, in something like:
```cpp
void set(int* x, int y) {
  *x = y;
}

void test() {
  int x;
  set(&x, source());
  sink(x);
}
```
So in order to make the original example work, all we need to do is to remove
the restrictions on this mechanism so that the same mechanism that makes the
above example work also makes the original example work!
2024-02-16 13:09:45 +01:00
Mathias Vorreiter Pedersen
7e9bf2a880 C++: Add a model for 'partial updating' and extend models appropriately. 2024-02-16 12:56:19 +01:00
Mathias Vorreiter Pedersen
24a63ae94d C++: Block flow by default. 2024-02-16 12:56:19 +01:00
Mathias Vorreiter Pedersen
625c47fa9c C++: Add a testcase. 2024-02-16 12:56:19 +01:00