Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e209ed9

Browse files
author
Robert Marsh
committed
Merge branch 'master' into rdmarsh/cpp/ir-callee-side-effects
2 parents 05aebef + cd1a3e9 commit e209ed9

562 files changed

Lines changed: 31307 additions & 21288 deletions

File tree

Some content is hidden

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

.github/labeler.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"C++":
2+
- cpp/**/*
3+
- change-notes/**/*cpp*
4+
5+
"C#":
6+
- csharp/**/*
7+
- change-notes/**/*csharp*
8+
9+
Java:
10+
- java/**/*
11+
- change-notes/**/*java.*
12+
13+
JS:
14+
- javascript/**/*
15+
- change-notes/**/*javascript*
16+
17+
Python:
18+
- python/**/*
19+
- change-notes/**/*python*
20+
21+
documentation:
22+
- "**/*.qhelp"
23+
- "**/*.md"
24+
- docs/**/*

change-notes/1.23/analysis-cpp.md

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,65 @@
22

33
The following changes in version 1.23 affect C/C++ analysis in all applications.
44

5-
## General improvements
6-
75
## New queries
86

97
| **Query** | **Tags** | **Purpose** |
108
|-----------------------------|-----------|--------------------------------------------------------------------|
11-
| Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) | reliability, japanese-era | This query is a combination of two old queries that were identical in purpose but separate as an implementation detail. This new query replaces Hard-coded Japanese era start date in call (`cpp/japanese-era/constructor-or-method-with-exact-era-date`) and Hard-coded Japanese era start date in struct (`cpp/japanese-era/struct-with-exact-era-date`). |
12-
| Signed overflow check (`cpp/signed-overflow-check`) | correctness, security | Finds overflow checks that rely on signed integer addition to overflow, which has undefined behavior. Example: `a + b < a`. |
13-
| Pointer overflow check (`cpp/pointer-overflow-check`) | correctness, security | Finds overflow checks that rely on pointer addition to overflow, which has undefined behavior. Example: `ptr + a < ptr`. |
9+
| Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) | reliability, japanese-era | This query is a combination of two old queries that were identical in purpose but separate as an implementation detail. This new query replaces Hard-coded Japanese era start date in call (`cpp/japanese-era/constructor-or-method-with-exact-era-date`) and Hard-coded Japanese era start date in struct (`cpp/japanese-era/struct-with-exact-era-date`). Results are not shown on LGTM by default. |
10+
| Pointer overflow check (`cpp/pointer-overflow-check`) | correctness, security | Finds overflow checks that rely on pointer addition to overflow, which has undefined behavior. Example: `ptr + a < ptr`. Results are shown on LGTM by default. |
11+
| Signed overflow check (`cpp/signed-overflow-check`) | correctness, security | Finds overflow checks that rely on signed integer addition to overflow, which has undefined behavior. Example: `a + b < a`. Results are shown on LGTM by default. |
12+
1413

1514
## Changes to existing queries
1615

1716
| **Query** | **Expected impact** | **Change** |
1817
|----------------------------|------------------------|------------------------------------------------------------------|
19-
| Query name (`query id`) | Expected impact | Message. |
18+
| Comparison of narrow type with wide type in loop condition (`cpp/comparison-with-wider-type`) | Higher precision | The precision of this query has been increased to "high" as the alerts from this query have proved to be valuable on real-world projects. With this precision, results are now displayed by default in LGTM. |
2019
| Hard-coded Japanese era start date in call (`cpp/japanese-era/constructor-or-method-with-exact-era-date`) | Deprecated | This query has been deprecated. Use the new combined query Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) instead. |
2120
| Hard-coded Japanese era start date in struct (`cpp/japanese-era/struct-with-exact-era-date`) | Deprecated | This query has been deprecated. Use the new combined query Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) instead. |
2221
| Hard-coded Japanese era start date (`cpp/japanese-era/exact-era-date`) | More correct results | This query now checks for the beginning date of the Reiwa era (1st May 2019). |
22+
| Non-constant format string (`cpp/non-constant-format`) | Fewer false positive results | Fixed false positive results triggrered by mismatching declarations of a formatting function. |
2323
| Sign check of bitwise operation (`cpp/bitwise-sign-check`) | Fewer false positive results | Results involving `>=` or `<=` are no longer reported. |
24-
| Too few arguments to formatting function (`cpp/wrong-number-format-arguments`) | Fewer false positive results | Fixed false positives resulting from mistmatching declarations of a formatting function. |
25-
| Too many arguments to formatting function (`cpp/too-many-format-arguments`) | Fewer false positive results | Fixed false positives resulting from mistmatching declarations of a formatting function. |
26-
| Unclear comparison precedence (`cpp/comparison-precedence`) | Fewer false positive results | False positives involving template classes and functions have been fixed. |
27-
| Comparison of narrow type with wide type in loop condition (`cpp/comparison-with-wider-type`) | Higher precision | The precision of this query has been increased to "high" as the alerts from this query have proved to be valuable on real-world projects. With this precision, results are now displayed by default in LGTM. |
28-
| Non-constant format string (`cpp/non-constant-format`) | Fewer false positive results | Fixed false positives resulting from mistmatching declarations of a formatting function. |
29-
| Wrong type of arguments to formatting function (`cpp/wrong-type-format-argument`) | More correct results and fewer false positive results | This query now understands explicitly specified argument numbers in format strings, such as the `1$` in `%1$s`. |
24+
| Too few arguments to formatting function (`cpp/wrong-number-format-arguments`) | Fewer false positive results | Fixed false positive results triggered by mismatching declarations of a formatting function. |
25+
| Too many arguments to formatting function (`cpp/too-many-format-arguments`) | Fewer false positive results | Fixed false positive results triggered by mismatching declarations of a formatting function. |
26+
| Unclear comparison precedence (`cpp/comparison-precedence`) | Fewer false positive results | False positive results involving template classes and functions have been fixed. |
27+
| Wrong type of arguments to formatting function (`cpp/wrong-type-format-argument`) | More correct results and fewer false positive results | This query now understands explicitly-specified argument numbers in format strings, such as the `1$` in `%1$s`. |
3028

3129
## Changes to libraries
3230

33-
* The data-flow library has been extended with a new feature to aid debugging.
34-
Instead of specifying `isSink(Node n) { any() }` on a configuration to
35-
explore the possible flow from a source, it is recommended to use the new
36-
`Configuration::hasPartialFlow` predicate, as this gives a more complete
37-
picture of the partial flow paths from a given source. The feature is
38-
disabled by default and can be enabled for individual configurations by
39-
overriding `int explorationLimit()`.
40-
* The data-flow library now supports flow out of C++ reference parameters.
41-
* The data-flow library now allows flow through the address-of operator (`&`).
42-
* The `DataFlow::DefinitionByReferenceNode` class now considers `f(x)` to be a
43-
definition of `x` when `x` is a variable of pointer type. It no longer
44-
considers deep paths such as `f(&x.myField)` to be definitions of `x`. These
45-
changes are in line with the user expectations we've observed.
46-
* The data-flow library now makes it easier to specify barriers/sanitizers
47-
arising from guards by overriding the predicate
48-
`isBarrierGuard`/`isSanitizerGuard` on data-flow and taint-tracking
49-
configurations respectively.
50-
* There is now a `DataFlow::localExprFlow` predicate and a
51-
`TaintTracking::localExprTaint` predicate to make it easy to use the most
52-
common case of local data flow and taint: from one `Expr` to another.
31+
* The data-flow library in `semmle.code.cpp.dataflow.DataFlow` and
32+
`semmle.code.cpp.dataflow.TaintTracking` have had extensive changes:
33+
* Data flow through fields is now more complete and reliable.
34+
* The data-flow library has been extended with a new feature to aid debugging.
35+
Previously, to explore the possible flow from all sources you could specify `isSink(Node n) { any() }` on a configuration.
36+
Now you can use the new `Configuration::hasPartialFlow` predicate,
37+
which gives a more complete picture of the partial flow paths from a given source, including flow that doesn't reach any sink.
38+
The feature is disabled by default and can be enabled for individual configurations by overriding `int explorationLimit()`.
39+
* There is now flow out of C++ reference parameters.
40+
* There is now flow through the address-of operator (`&`).
41+
* The `DataFlow::DefinitionByReferenceNode` class now considers `f(x)` to be a
42+
definition of `x` when `x` is a variable of pointer type. It no longer
43+
considers deep paths such as `f(&x.myField)` to be definitions of `x`. These
44+
changes are in line with the user expectations we've observed.
45+
* It's now easier to specify barriers/sanitizers
46+
arising from guards by overriding the predicate
47+
`isBarrierGuard`/`isSanitizerGuard` on data-flow and taint-tracking
48+
configurations respectively.
49+
* There is now a `DataFlow::localExprFlow` predicate and a
50+
`TaintTracking::localExprTaint` predicate to make it easy to use the most
51+
common case of local data flow and taint: from one `Expr` to another.
5352
* The member predicates of the `FunctionInput` and `FunctionOutput` classes have been renamed for
54-
clarity (e.g. `isOutReturnPointer()` to `isReturnValueDeref()`). The existing member predicates
53+
clarity (for example, `isOutReturnPointer()` to `isReturnValueDeref()`). The existing member predicates
5554
have been deprecated, and will be removed in a future release. Code that uses the old member
5655
predicates should be updated to use the corresponding new member predicate.
57-
* The predicates `Declaration.hasStdName()` and `Declaration.hasGlobalOrStdName`
58-
have been added, simplifying handling of C++ standard library functions.
56+
* The predicate `Declaration.hasGlobalOrStdName` has been added, making it
57+
easier to recognize C library functions called from C++.
5958
* The control-flow graph is now computed in QL, not in the extractor. This can
60-
lead to regressions (or improvements) in how queries are optimized because
59+
lead to changes in how queries are optimized because
6160
optimization in QL relies on static size estimates, and the control-flow edge
6261
relations will now have different size estimates than before.
6362
* Support has been added for non-type template arguments. This means that the
6463
return type of `Declaration::getTemplateArgument()` and
65-
`Declaration::getATemplateArgument` have changed to `Locatable`. See the
66-
documentation for `Declaration::getTemplateArgument()` and
67-
`Declaration::getTemplateArgumentKind()` for details.
64+
`Declaration::getATemplateArgument` have changed to `Locatable`. For details, see the
65+
CodeQL library documentation for `Declaration::getTemplateArgument()` and
66+
`Declaration::getTemplateArgumentKind()`.

change-notes/1.23/analysis-csharp.md

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,20 @@ The following changes in version 1.23 affect C# analysis in all applications.
44

55
## New queries
66

7-
## New queries
8-
97
| **Query** | **Tags** | **Purpose** |
108
|-----------------------------|-----------|--------------------------------------------------------------------|
11-
| Deserialized delegate (`cs/deserialized-delegate`) | security, external/cwe/cwe-502 | Finds unsafe deserialization of delegate types. |
12-
| Deserialization of untrusted data (`cs/unsafe-deserialization-untrusted-input`) | security, external/cwe/cwe-502 | Finds flow of untrusted input to calls to unsafe deserializers. |
13-
| Unsafe year argument for 'DateTime' constructor (`cs/unsafe-year-construction`) | reliability, date-time | Finds incorrect manipulation of `DateTime` values, which could lead to invalid dates. |
14-
| Unsafe deserializer (`cs/unsafe-deserialization`) | security, external/cwe/cwe-502 | Finds calls to unsafe deserializers. |
15-
| Mishandling the Japanese era start date (`cs/mishandling-japanese-era`) | reliability, date-time | Finds hard-coded Japanese era start dates that could be invalid. |
9+
| Deserialized delegate (`cs/deserialized-delegate`) | security, external/cwe/cwe-502 | Finds unsafe deserialization of delegate types. Results are shown on LGTM by default. |
10+
| Deserialization of untrusted data (`cs/unsafe-deserialization-untrusted-input`) | security, external/cwe/cwe-502 | Finds flow of untrusted input to calls to unsafe deserializers. Results are shown on LGTM by default. |
11+
| Mishandling the Japanese era start date (`cs/mishandling-japanese-era`) | reliability, date-time | Finds hard-coded Japanese era start dates that could be invalid. Results are not shown on LGTM by default. |
12+
| Unsafe year argument for 'DateTime' constructor (`cs/unsafe-year-construction`) | reliability, date-time | Finds incorrect manipulation of `DateTime` values, which could lead to invalid dates. Results are not shown on LGTM by default. |
13+
| Unsafe deserializer (`cs/unsafe-deserialization`) | security, external/cwe/cwe-502 | Finds calls to unsafe deserializers. By default, the query is not run on LGTM. |
1614

1715
## Changes to existing queries
1816

1917
| **Query** | **Expected impact** | **Change** |
2018
|------------------------------|------------------------|-----------------------------------|
2119
| Dereferenced variable may be null (`cs/dereferenced-value-may-be-null`) | Fewer false positive results | More `null` checks are now taken into account, including `null` checks for `dynamic` expressions and `null` checks such as `object alwaysNull = null; if (x != alwaysNull) ...`. |
22-
| Missing Dispose call on local IDisposable (`cs/local-not-disposed`) | Fewer false positive results | The query has been rewritten in order to identify more dispose patterns. For example, a local `IDisposable` that is disposed of by passing through a fluent API is no longer reported. |
23-
24-
## Removal of old queries
20+
| Missing Dispose call on local IDisposable (`cs/local-not-disposed`) | Fewer false positive results | The query has been rewritten in order to identify more dispose patterns. For example, a local `IDisposable` that is disposed of by passing through a fluent API is no longer reported as missing a dispose call. |
2521

2622
## Changes to code extraction
2723

@@ -31,22 +27,19 @@ The following changes in version 1.23 affect C# analysis in all applications.
3127

3228
* The new class `NamespaceAccess` models accesses to namespaces, for example in `nameof` expressions.
3329
* The data-flow library now makes it easier to specify barriers/sanitizers
34-
arising from guards by overriding the predicate
30+
arising from guards. You can override the predicate
3531
`isBarrierGuard`/`isSanitizerGuard` on data-flow and taint-tracking
3632
configurations respectively.
3733
* The data-flow library has been extended with a new feature to aid debugging.
38-
Instead of specifying `isSink(Node n) { any() }` on a configuration to
39-
explore the possible flow from a source, it is recommended to use the new
40-
`Configuration::hasPartialFlow` predicate, as this gives a more complete
41-
picture of the partial flow paths from a given source. The feature is
42-
disabled by default and can be enabled for individual configurations by
34+
Previously, to explore the possible flow from all sources you could specify `isSink(Node n) { any() }` on a configuration.
35+
Now you can use the new `Configuration::hasPartialFlow` predicate,
36+
which gives a more complete picture of the partial flow paths from a given source, including flow that doesn't reach any sink.
37+
The feature is disabled by default and can be enabled for individual configurations by
4338
overriding `int explorationLimit()`.
44-
* `foreach` statements where the body is guaranteed to be executed at least once, such as `foreach (var x in new string[]{ "a", "b", "c" }) { ... }`, are now recognized by all analyses based on the control flow graph (such as SSA, data flow and taint tracking).
45-
* Fixed the control flow graph for `switch` statements where the `default` case was not the last case. This had caused the remaining cases to be unreachable. `SwitchStmt.getCase(int i)` now puts the `default` case last.
39+
* `foreach` statements where the body is guaranteed to be executed at least once, such as `foreach (var x in new string[]{ "a", "b", "c" }) { ... }`, are now recognized by all analyses based on the control-flow graph (such as SSA, data flow and taint tracking).
40+
* Fixed the control-flow graph for `switch` statements where the `default` case was not the last case. This had caused the remaining cases to be unreachable. `SwitchStmt.getCase(int i)` now puts the `default` case last.
4641
* There is now a `DataFlow::localExprFlow` predicate and a
4742
`TaintTracking::localExprTaint` predicate to make it easy to use the most
4843
common case of local data flow and taint: from one `Expr` to another.
4944
* Data is now tracked through null-coalescing expressions (`??`).
5045
* A new library `semmle.code.csharp.Unification` has been added. This library exposes two predicates `unifiable` and `subsumes` for calculating type unification and type subsumption, respectively.
51-
52-
## Changes to autobuilder

0 commit comments

Comments
 (0)