Commit Graph

5704 Commits

Author SHA1 Message Date
Robert Marsh
818bdcf3ab C++: autoformat a test 2022-08-16 11:31:28 -04:00
Robert Marsh
5450681ade C++: Autoformat and fix a test 2022-08-12 13:49:16 -04:00
Jeroen Ketema
4d76fd198e C++: Handle block assignments in the IR 2022-08-12 18:43:23 +02:00
Jeroen Ketema
5c905b76b4 C++: Expose block assignment operations in the QL library 2022-08-12 18:43:23 +02:00
Jeroen Ketema
ebf8161f1b C++: Add block assignment expression to the database schema
These can under some circumstances be generated by the frontend as part
of compiler generated copy constructors and assignment operators.
2022-08-12 18:43:23 +02:00
Jeroen Ketema
de142b276d C++: Add IR test that exposes a gap in the extractor output 2022-08-12 18:43:23 +02:00
Geoffrey White
c62ae3b350 C++: First working. We now prefer flagging the cases where the variable was initialized, as in real world cases we haven't seen it done safely. 2022-08-11 12:27:48 +02:00
Geoffrey White
76ef779f60 C++: Add test and placeholder query. 2022-08-11 12:27:39 +02:00
Jeroen Ketema
8528e6b8e1 C++: Update test results for exposing attribute arguments as proper constants 2022-08-10 21:11:58 +02:00
Nora Dimitrijević
8e60a4a478 Update StrncpyFlippedArgs.expected
Add output lines for the newly implemented test case, test.cpp/test9().
2022-08-10 13:42:21 +02:00
Nora Dimitrijević
df419003ad Use Strcpy.qll in StrncpyFlippedArgs.ql
As a result, the query gets access to more types of strncpy-like
functions, as demonstrated by test.cpp, which now "fails" (i.e. works) for the new test
cases instroduced
in the previous commit.
2022-08-10 13:42:21 +02:00
Nora Dimitrijević
554aea1bb8 New strcpy-variant in StrncpyFlippedArgs test
Added wcsxfrm_l, which is not currently caught by the query,
meaning that in this case a successful
test implies missing functionality.
2022-08-10 13:42:21 +02:00
Geoffrey White
db8a3107b3 Merge pull request #9089 from ihsinme/ihsinme-patch-87
CPP: Add query for CWE-125 Out-of-bounds Read with different interpretation of the string when use mbtowc
2022-08-09 09:31:32 +01:00
ihsinme
9b5154f878 Update and rename DangerousUseMbtowc.qlref to DangerousWorksWithMultibyteOrWideCharacters.qlref 2022-08-08 18:39:10 +03:00
ihsinme
bce395f201 Rename DangerousUseMbtowc.expected to DangerousWorksWithMultibyteOrWideCharacters.expected 2022-08-08 18:38:24 +03:00
Jeroen Ketema
ba2cee07a9 Merge pull request #8596 from rdmarsh2/rdmarsh2/dataflow-global-vars
C++: IR data flow through global variables
2022-08-05 10:07:00 +02:00
Mathias Vorreiter Pedersen
c582d17350 Merge pull request #9952 from MathiasVP/speedup-return-stack-allocated-memory
C++: Speedup `cpp/return-stack-allocated-memory`
2022-08-03 09:41:38 +01:00
Mathias Vorreiter Pedersen
5181cc1295 C++: Add a 'allowInterproceduralFlow' predicate to the 'MustFlow' library to and use it instead of checking the enclosing callables after computing the dataflow graph. 2022-08-02 13:43:01 +01:00
Robert Marsh
3007c96c72 C++: fix a nit 2022-08-01 15:34:03 -04:00
Robert Marsh
6dbaae6bfc Merge branch 'main' into rdmarsh2/dataflow-global-vars 2022-08-01 14:56:24 -04:00
Robert Marsh
4f8373f577 Merge branch 'main' into rdmarsh2/dataflow-global-vars 2022-08-01 14:55:45 -04:00
Jeroen Ketema
c02e7a4896 C++: Update test for indexing of static template variable template arguments 2022-07-31 09:58:29 +02:00
Jeroen Ketema
20b66eaf34 C++: Support __builtin_shuffle builtin
While here write gcc instead of GNU, which is more accurate.
2022-07-29 09:08:56 +02:00
Jeroen Ketema
81e687ea98 C++: Support __builtin_bit_cast builtin 2022-07-29 09:08:56 +02:00
Jeroen Ketema
a85d3f9b7f C++: Support __has_unique_object_representations builtin 2022-07-29 09:08:56 +02:00
Jeroen Ketema
0c03935437 C++: Support __is_aggregate builtin
Fix some whitespace issues while here.
2022-07-29 09:08:56 +02:00
Jeroen Ketema
c4283dd23f C++: Support __is_assignable builtin
While here fix the documentation of `__is_trivially_assignable` and
`__is_nothrow_assignable`.
2022-07-29 09:08:56 +02:00
Jeroen Ketema
23c19311fb Merge pull request #9700 from jketema/resolve-global-variable
C++: Ensure only one `Variable` exists for every global variable
2022-07-22 17:57:21 +02:00
ihsinme
e77a989133 Update DangerousUseMbtowc.expected 2022-07-12 20:22:31 +03:00
Geoffrey White
f29104ccce C++: Accept test results. 2022-07-12 16:49:04 +01:00
Jeroen Ketema
e5eabc4e47 C++: Slightly tweak nullness test and update test results 2022-07-12 15:23:33 +02:00
Jeroen Ketema
93a4a32527 Merge pull request #9786 from jketema/lossy
C++: LossyFunctionResultCast updates
2022-07-11 14:14:33 +02:00
Jeroen Ketema
6b2154eb8b C++: Add tests for AnalysedExpr::isNullCheck and AnalysedExpr::isValidCheck 2022-07-11 11:54:48 +02:00
Jeroen Ketema
7d6fb7f91a C++: Rename LossyFunctionResultCast tests to be correctly named 2022-07-06 21:52:13 +02:00
ihsinme
4e28887689 Create test3.cpp 2022-07-04 11:13:07 +03:00
ihsinme
1ce42dcd30 Create test2.cpp 2022-07-04 11:12:34 +03:00
ihsinme
6d800de377 Create test1.cpp 2022-07-04 11:11:49 +03:00
Jeroen Ketema
82c9b8b494 C++: Ensure only one Variable exists for every global variable
Depending on the extraction order, before this change there might be multiple
`GlobalVariable`s per declared global variable. See the tests in
`cpp/ql/test/library-tests/variables/global`. This change ensures that only one
of those `GlobalVariable`s is visible to the user if we can locate a unique
definition. If not, the old situation persists.

Note that an exception needs to be made for templated variables. Here, the
definition refers to the non-instantiated template, while a declaration that
is not a definition refers to an instantiation. In case the instantiation refers
to a template parameter, the mangled names of the template and the instantiation
will be identical. This happens for example in the following case:
```
template <typename T>
T x = T(42);           // Uninstantiated templated variable

template <typename T>
class C {
  T y = x<T>;          // Instantiation using a template parameter
};
```
Since the uninstantiated template and the instantiation are two different
entities, we do not unify them as described above.
2022-06-28 15:32:43 +02:00
Geoffrey White
20c3182437 Merge pull request #9087 from ihsinme/ihsinme-patch-88
CPP: Add query for CWE-670: Always-Incorrect Control Flow Implementation when use SSL_shutdown
2022-06-23 09:16:55 +01:00
Robert Marsh
813a8548d7 C++: accept test changes for globals in data flow 2022-06-22 16:42:42 -04:00
Jeroen Ketema
f9e09da604 Merge pull request #9643 from jketema/namespace-variable-test
C++: Add variable in namespace test
2022-06-22 15:58:26 +02:00
Mathias Vorreiter Pedersen
1febe87356 Merge pull request #9644 from jketema/class-entry-fix
C++: Ensure we can round trip between (forward) class declarations
2022-06-22 14:12:11 +01:00
Jeroen Ketema
b1dd8da587 C++: Fix query formatting 2022-06-22 12:59:49 +02:00
Anders Schack-Mulligen
df6d68b215 Merge pull request #9618 from aschackmull/dataflow/deprecate-barrierguard-class
Dataflow: Deprecate BarrierGuard class
2022-06-22 10:44:08 +02:00
Jeroen Ketema
880c785efe C++: Ensure we can round trip between (forward) class declarations
This was already possible when the forward class declaration and the class
definition occurred in the same scope. However, there is a common C++ usage
pattern in which this is not the case (when only a pointer to the class is
needed). In this latter scenario we could not round trip between the (forward)
`DeclarationEntry` and the `Declaration`.

Effectively this changes the code to:
```
if exists(TypeDeclarationEntry e | e.getType() = this)
then result.getType() = this
else ...
```
We use `type_decls` instead to stay close to the original code.
2022-06-22 07:58:45 +02:00
Jeroen Ketema
0f37e4e7b2 C++: Add variable in namespace test 2022-06-22 07:56:27 +02:00
Jeroen Ketema
a8833a0c70 C++: Test showing going from a forward class declaration to a class but not back 2022-06-22 07:53:50 +02:00
Jeroen Ketema
40e0356177 C++: Test that we can go from a DeclarationEntry to a Declaration and back 2022-06-22 07:53:50 +02:00
Jeroen Ketema
1f97f1d931 C++: Add global variable tests 2022-06-21 10:43:40 +02:00
Robert Marsh
d28c39cd73 C++: update test expectations 2022-06-20 15:56:00 -04:00