Skip to content

Commit 9469917

Browse files
authored
Merge pull request #1046 from xiemaisi/rc/1.20
Merge rc/1.20 into master
2 parents d5627fd + eb08dcf commit 9469917

File tree

1,112 files changed

+9171
-7655
lines changed

Some content is hidden

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

1,112 files changed

+9171
-7655
lines changed

change-notes/1.20/analysis-cpp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@
3333
| Mismatching new/free or malloc/delete (`cpp/new-free-mismatch`) | More correct results | Data flow through global variables for this query has been improved. |
3434
| Use of inherently dangerous function (`cpp/potential-buffer-overflow`) | Cleaned up | This query no longer catches uses of `gets`, and has been renamed 'Potential buffer overflow'. |
3535
| Use of potentially dangerous function (`cpp/potentially-dangerous-function`) | More correct results | This query now catches uses of `gets`. |
36+
| Potential buffer overflow (`cpp/potential-buffer-overflow`) | Deprecated | This query has been deprecated. Use Potentially overrunning write (`cpp/overrunning-write`) and Potentially overrunning write with float to string conversion (`cpp/overrunning-write-with-float`) instead. |
3637

3738
## Changes to QL libraries
3839

40+
* The `semmle.code.cpp.dataflow.DataFlow` library now supports _definition by reference_ via output parameters of known functions.
41+
* Data flows through `memcpy` and `memmove` by default.
42+
* Custom flow into or out of arguments assigned by reference can be modelled with the new class `DataFlow::DefinitionByReferenceNode`.
43+
* The data flow library adds flow through library functions that are modeled in `semmle.code.cpp.models.interfaces.DataFlow`. Queries can add subclasses of `DataFlowFunction` to specify additional flow.
3944
* There is a new `Namespace.isInline()` predicate, which holds if the namespace was declared as `inline namespace`.
4045
* The `Expr.isConstant()` predicate now also holds for _address constant expressions_, which are addresses that will be constant after the program has been linked. These address constants do not have a result for `Expr.getValue()`.
4146
* There are new `Function.isDeclaredConstexpr()` and `Function.isConstexpr()` predicates. They can be used to tell whether a function was declared as `constexpr`, and whether it actually is `constexpr`.

change-notes/1.20/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
| **Query** | **Expected impact** | **Change** |
4040
|--------------------------------------------|------------------------------|------------------------------------------------------------------------------|
4141
| Ambiguous HTML id attribute | Fewer false-positive results | This rule now treats templates more conservatively. Its precision has been revised to 'high'. |
42+
| Assignment to exports variable | Fewer results | This rule no longer flags code that is also flagged by the rule "Useless assignment to local variable". |
4243
| Client-side cross-site scripting | More true-positive results, fewer false-positive results. | This rule now recognizes WinJS functions that are vulnerable to HTML injection. It no longer flags certain safe uses of jQuery, and recognizes custom sanitizers. |
4344
| Hard-coded credentials | Fewer false-positive results | This rule no longer flag the empty string as a hardcoded username. |
4445
| Insecure randomness | More results | This rule now flags insecure uses of `crypto.pseudoRandomBytes`. |

change-notes/1.20/extractor-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Changes to code extraction
2020

21-
* Extraction of JavaScript files (but not TypeScript files) on LGTM is now parallelized. By default, the extractor uses as many threads as there are processors, but this can be overridden by setting the `LGTM_INDEX_THREADS` environment variable. In particular, setting `LGTM_INDEX_THREADS` to 1 disables parallel extraction.
21+
* Parallel extraction of JavaScript files (but not TypeScript files) on LGTM is now supported. The `LGTM_THREADS` environment variable can be set to indicate how many files should be extracted in parallel. If this variable is not set, parallel extraction is disabled.
2222
* The extractor now offers experimental support for [E4X](https://developer.mozilla.org/en-US/docs/Archive/Web/E4X), a legacy language extension developed by Mozilla.
2323
* The extractor now supports additional [Flow](https://flow.org/) syntax.
2424
* The extractor now supports [Nullish Coalescing](https://github.com/tc39/proposal-nullish-coalescing) expressions.

cpp/config/suites/security/cwe-242

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

cpp/config/suites/security/default

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
@import "cwe-134"
1313
@import "cwe-170"
1414
@import "cwe-190"
15-
@import "cwe-242"
1615
@import "cwe-253"
1716
@import "cwe-290"
1817
@import "cwe-311"

cpp/ql/src/Critical/NewDelete.qll

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,32 +46,20 @@ predicate allocExprOrIndirect(Expr alloc, string kind) {
4646
alloc.(FunctionCall).getTarget() = rtn.getEnclosingFunction() and
4747
(
4848
allocExprOrIndirect(rtn.getExpr(), kind) or
49-
allocReaches(rtn.getExpr(), _, kind)
49+
allocReaches0(rtn.getExpr(), _, kind)
5050
)
5151
)
5252
}
5353

5454
/**
55-
* Holds if `v` is assigned value `e`, and `e` is not known to be `0`.
55+
* Holds if `v` is a non-local variable which is assigned with allocations of
56+
* type `kind`.
5657
*/
57-
private predicate nonNullGlobalAssignment(Variable v, Expr e) {
58-
not v instanceof LocalScopeVariable and
59-
v.getAnAssignedValue() = e and
60-
not e.getValue().toInt() = 0
61-
}
62-
63-
/**
64-
* Holds if `v` is a non-local variable which is assigned only with allocations of
65-
* type `kind` (it may also be assigned with NULL).
66-
*/
67-
private predicate allocReachesVariable(Variable v, Expr alloc, string kind) {
58+
private pragma[nomagic] predicate allocReachesVariable(Variable v, Expr alloc, string kind) {
6859
exists(Expr mid |
69-
nonNullGlobalAssignment(v, mid) and
70-
allocReaches(mid, alloc, kind)
71-
) and
72-
forall(Expr mid |
73-
nonNullGlobalAssignment(v, mid) |
74-
allocReaches(mid, _, kind)
60+
not v instanceof LocalScopeVariable and
61+
v.getAnAssignedValue() = mid and
62+
allocReaches0(mid, alloc, kind)
7563
)
7664
}
7765

@@ -80,22 +68,35 @@ private predicate allocReachesVariable(Variable v, Expr alloc, string kind) {
8068
* result of a previous memory allocation `alloc`. `kind` is a
8169
* string describing the type of that allocation.
8270
*/
83-
predicate allocReaches(Expr e, Expr alloc, string kind) {
71+
private predicate allocReaches0(Expr e, Expr alloc, string kind) {
8472
(
8573
// alloc
8674
allocExprOrIndirect(alloc, kind) and
8775
e = alloc
8876
) or exists(SsaDefinition def, LocalScopeVariable v |
8977
// alloc via SSA
90-
allocReaches(def.getAnUltimateDefiningValue(v), alloc, kind) and
78+
allocReaches0(def.getAnUltimateDefiningValue(v), alloc, kind) and
9179
e = def.getAUse(v)
9280
) or exists(Variable v |
93-
// alloc via a singly assigned global
81+
// alloc via a global
9482
allocReachesVariable(v, alloc, kind) and
9583
e.(VariableAccess).getTarget() = v
9684
)
9785
}
9886

87+
/**
88+
* Holds if `e` is an expression which may evaluate to the
89+
* result of previous memory allocations `alloc` only of type
90+
* `kind`.
91+
*/
92+
predicate allocReaches(Expr e, Expr alloc, string kind) {
93+
allocReaches0(e, alloc, kind) and
94+
not exists(string k2 |
95+
allocReaches0(e, _, k2) and
96+
kind != k2
97+
)
98+
}
99+
99100
/**
100101
* Holds if `free` is a use of free or delete. `freed` is the
101102
* expression that is freed / deleted and `kind` is a string

cpp/ql/src/Likely Bugs/Memory Management/PotentialBufferOverflow.ql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* @tags reliability
1010
* security
1111
* external/cwe/cwe-676
12+
* @deprecated This query is deprecated, use
13+
* Security/CWE/CWE-120/OverrunWrite.ql and
14+
* Security/CWE/CWE-120/OverrunWriteFloat.ql instead.
1215
*/
1316
import cpp
1417
import semmle.code.cpp.commons.Buffer

cpp/ql/src/Likely Bugs/OO/NonVirtualDestructor.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @id cpp/non-virtual-destructor
88
* @problem.severity warning
99
* @tags reliability
10-
* @deprecated
10+
* @deprecated This query is deprecated, and replaced by
11+
* jsf/4.10 Classes/AV Rule 78.ql, which has far fewer false
12+
* positives on typical code.
1113
*/
1214

13-
// This query is deprecated, and replaced by jsf/4.10 Classes/AV Rule 78.ql, which has far fewer false positives on typical code.
14-
1515
import cpp
1616

1717
from Class base, Destructor d1, Class derived, Destructor d2

cpp/ql/src/PointsTo/Debug.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* @description Query to help investigate mysterious results with ReturnStackAllocatedObject
44
* @kind table
55
* @id cpp/points-to/debug
6-
* @deprecated
6+
* @deprecated This query is not suitable for production use and has been deprecated.
77
*/
88

9-
// This query is not suitable for production use and has been deprecated.
10-
119
import cpp
1210
import semmle.code.cpp.pointsto.PointsTo
1311

cpp/ql/src/PointsTo/PreparedStagedPointsTo.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
* @description Query to force evaluation of staged points-to predicates
44
* @kind table
55
* @id cpp/points-to/prepared-staged-points-to
6-
* @deprecated
6+
* @deprecated This query is not suitable for production use and has been deprecated.
77
*/
88

9-
// This query is not suitable for production use and has been deprecated.
10-
119
import semmle.code.cpp.pointsto.PointsTo
1210

1311
select count(int set, Element location | setlocations(set, unresolveElement(location))),

0 commit comments

Comments
 (0)