Skip to content

Commit 681657f

Browse files
committed
Merge branch 'master' of github.com:github/codeql into SharedDataflow_Classes
2 parents 5da37f5 + 1f432dc commit 681657f

File tree

95 files changed

+4416
-689
lines changed

Some content is hidden

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

95 files changed

+4416
-689
lines changed

change-notes/1.26/analysis-cpp.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Improvements to C/C++ analysis
2+
3+
The following changes in version 1.26 affect C/C++ analysis in all applications.
4+
5+
## General improvements
6+
7+
## New queries
8+
9+
| **Query** | **Tags** | **Purpose** |
10+
|-----------------------------|-----------|--------------------------------------------------------------------|
11+
12+
## Changes to existing queries
13+
14+
| **Query** | **Expected impact** | **Change** |
15+
|----------------------------|------------------------|------------------------------------------------------------------|
16+
| Inconsistent direction of for loop (`cpp/inconsistent-loop-direction`) | Fewer false positive results | The query now accounts for intentional wrapping of an unsigned loop counter. |
17+
18+
## Changes to libraries
19+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Improvements to JavaScript analysis
2+
3+
## General improvements
4+
5+
* Support for the following frameworks and libraries has been improved:
6+
- [fast-json-stable-stringify](https://www.npmjs.com/package/fast-json-stable-stringify)
7+
- [fast-safe-stringify](https://www.npmjs.com/package/fast-safe-stringify)
8+
- [javascript-stringify](https://www.npmjs.com/package/javascript-stringify)
9+
- [js-stringify](https://www.npmjs.com/package/js-stringify)
10+
- [json-stable-stringify](https://www.npmjs.com/package/json-stable-stringify)
11+
- [json-stringify-safe](https://www.npmjs.com/package/json-stringify-safe)
12+
- [json3](https://www.npmjs.com/package/json3)
13+
- [object-inspect](https://www.npmjs.com/package/object-inspect)
14+
- [pretty-format](https://www.npmjs.com/package/pretty-format)
15+
- [stringify-object](https://www.npmjs.com/package/stringify-object)
16+
17+
## New queries
18+
19+
| **Query** | **Tags** | **Purpose** |
20+
|---------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
21+
22+
23+
## Changes to existing queries
24+
25+
| **Query** | **Expected impact** | **Change** |
26+
|--------------------------------|------------------------------|---------------------------------------------------------------------------|
27+
28+
29+
## Changes to libraries
30+

cpp/ql/src/Likely Bugs/Likely Typos/inconsistentLoopDirection.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ predicate illDefinedDecrForStmt(
5050
DataFlow::localFlowStep(DataFlow::exprNode(initialCondition), DataFlow::exprNode(lesserOperand)) and
5151
// `initialCondition` < `terminalCondition`
5252
(
53-
upperBound(initialCondition) < lowerBound(terminalCondition)
53+
upperBound(initialCondition) < lowerBound(terminalCondition) and
54+
(
55+
// exclude cases where the loop counter is `unsigned` (where wrapping behaviour can be used deliberately)
56+
v.getUnspecifiedType().(IntegralType).isSigned() or
57+
initialCondition.getValue().toInt() = 0
58+
)
5459
or
5560
(forstmt.conditionAlwaysFalse() or forstmt.conditionAlwaysTrue())
5661
)

cpp/ql/src/semmle/code/cpp/MemberFunction.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ abstract class ImplicitConversionFunction extends MemberFunction {
214214
}
215215

216216
/**
217+
* DEPRECATED: as of C++11 this class does not correspond perfectly with the
218+
* language definition of a converting constructor.
219+
*
217220
* A C++ constructor that also defines an implicit conversion. For example the
218221
* function `MyClass` in the following code is a `ConversionConstructor`:
219222
* ```
@@ -225,15 +228,16 @@ abstract class ImplicitConversionFunction extends MemberFunction {
225228
* };
226229
* ```
227230
*/
228-
class ConversionConstructor extends Constructor, ImplicitConversionFunction {
231+
deprecated class ConversionConstructor extends Constructor, ImplicitConversionFunction {
229232
ConversionConstructor() {
230233
strictcount(Parameter p | p = getAParameter() and not p.hasInitializer()) = 1 and
231-
not hasSpecifier("explicit") and
232-
not this instanceof CopyConstructor
234+
not hasSpecifier("explicit")
233235
}
234236

235237
override string getAPrimaryQlClass() {
236-
not this instanceof MoveConstructor and result = "ConversionConstructor"
238+
not this instanceof CopyConstructor and
239+
not this instanceof MoveConstructor and
240+
result = "ConversionConstructor"
237241
}
238242

239243
/** Gets the type this `ConversionConstructor` takes as input. */

cpp/ql/src/semmle/code/cpp/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ predicate localAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeT
6565
// tracking. The flow from expression `x` into `x++` etc. is handled in the
6666
// case above.
6767
exprTo = DataFlow::getAnAccessToAssignedVariable(exprFrom.(PostfixCrementOperation))
68+
or
69+
// In `for (char c : s) { ... c ... }`, this rule propagates taint from `s`
70+
// to `c`.
71+
exists(RangeBasedForStmt rbf |
72+
exprFrom = rbf.getRange() and
73+
// It's guaranteed up to at least C++20 that the range-based for loop
74+
// desugars to a variable with an initializer.
75+
exprTo = rbf.getVariable().getInitializer().getExpr()
76+
)
6877
)
6978
or
7079
// Taint can flow through modeled functions

cpp/ql/src/semmle/code/cpp/models/implementations/MemberFunction.qll

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ import semmle.code.cpp.models.interfaces.DataFlow
77
import semmle.code.cpp.models.interfaces.Taint
88

99
/**
10-
* Model for C++ conversion constructors.
10+
* Model for C++ conversion constructors. As of C++11 this does not correspond
11+
* perfectly with the language definition of a converting constructor, however,
12+
* it does correspond with the constructors we are confident taint should flow
13+
* through.
1114
*/
12-
class ConversionConstructorModel extends ConversionConstructor, TaintFunction {
15+
class ConversionConstructorModel extends Constructor, TaintFunction {
16+
ConversionConstructorModel() {
17+
strictcount(Parameter p | p = getAParameter() and not p.hasInitializer()) = 1 and
18+
not hasSpecifier("explicit")
19+
}
20+
1321
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
1422
// taint flow from the first constructor argument to the returned object
1523
input.isParameter(0) and

0 commit comments

Comments
 (0)