Skip to content

Commit 73ad2e9

Browse files
author
Dave Bartolomeo
committed
Merge from master
2 parents a23d5af + c77a921 commit 73ad2e9

66 files changed

Lines changed: 3896 additions & 849 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.

change-notes/1.24/analysis-csharp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The following changes in version 1.24 affect C# analysis in all applications.
1818
| **Query** | **Expected impact** | **Change** |
1919
|------------------------------|------------------------|-----------------------------------|
2020
| Useless assignment to local variable (`cs/useless-assignment-to-local`) | Fewer false positive results | Results have been removed when the variable is named `_` in a `foreach` statement. |
21+
| Potentially dangerous use of non-short-circuit logic (`cs/non-short-circuit`) | Fewer false positive results | Results have been removed when the expression contains an `out` parameter. |
2122
| Dereferenced variable may be null (`cs/dereferenced-value-may-be-null`) | More results | Results are reported from parameters with a default value of `null`. |
2223

2324
## Removal of old queries

change-notes/1.24/analysis-javascript.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
* Imports with the `.js` extension can now be resolved to a TypeScript file,
88
when the import refers to a file generated by TypeScript.
99

10-
- The analysis of sanitizer guards has improved, leading to fewer false-positive results from the security queries.
10+
* Imports that rely on path-mappings from a `tsconfig.json` file can now be resolved.
11+
12+
* The analysis of sanitizer guards has improved, leading to fewer false-positive results from the security queries.
1113

1214
* Support for the following frameworks and libraries has been improved:
1315
- [react](https://www.npmjs.com/package/react)
@@ -18,6 +20,7 @@
1820
- [Socket.IO](https://socket.io/)
1921
- [ws](https://github.com/websockets/ws)
2022
- [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
23+
- [Koa](https://www.npmjs.com/package/koa)
2124

2225
## New queries
2326

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ private import cpp
66
private import semmle.code.cpp.dataflow.internal.FlowVar
77
private import semmle.code.cpp.models.interfaces.DataFlow
88
private import semmle.code.cpp.controlflow.Guards
9-
private import semmle.code.cpp.valuenumbering.GlobalValueNumbering
109

1110
cached
1211
private newtype TNode =
@@ -689,9 +688,9 @@ class BarrierGuard extends GuardCondition {
689688

690689
/** Gets a node guarded by this guard. */
691690
final ExprNode getAGuardedNode() {
692-
exists(GVN value, boolean branch |
693-
result.getExpr() = value.getAnExpr() and
694-
this.checks(value.getAnExpr(), branch) and
691+
exists(SsaDefinition def, Variable v, boolean branch |
692+
result.getExpr() = def.getAUse(v) and
693+
this.checks(def.getAUse(v), branch) and
695694
this.controls(result.getExpr().getBasicBlock(), branch)
696695
)
697696
}

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,22 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
151151
// from `a`.
152152
i2.(PointerAddInstruction).getLeft() = i1
153153
or
154+
// Until we have from through indirections across calls, we'll take flow out
155+
// of the parameter and into its indirection.
156+
exists(IRFunction f, Parameter parameter |
157+
i1 = getInitializeParameter(f, parameter) and
158+
i2 = getInitializeIndirection(f, parameter)
159+
)
160+
or
161+
// Until we have flow through indirections across calls, we'll take flow out
162+
// of the indirection and into the argument.
163+
// When we get proper flow through indirections across calls, this code can be
164+
// moved to `adjusedSink` or possibly into the `DataFlow::ExprNode` class.
165+
exists(ReadSideEffectInstruction read |
166+
read.getAnOperand().(SideEffectOperand).getAnyDef() = i1 and
167+
read.getArgumentDef() = i2
168+
)
169+
or
154170
// Flow from argument to return value
155171
i2 =
156172
any(CallInstruction call |
@@ -176,6 +192,18 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
176192
)
177193
}
178194

195+
pragma[noinline]
196+
private InitializeIndirectionInstruction getInitializeIndirection(IRFunction f, Parameter p) {
197+
result.getParameter() = p and
198+
result.getEnclosingIRFunction() = f
199+
}
200+
201+
pragma[noinline]
202+
private InitializeParameterInstruction getInitializeParameter(IRFunction f, Parameter p) {
203+
result.getParameter() = p and
204+
result.getEnclosingIRFunction() = f
205+
}
206+
179207
/**
180208
* Get an instruction that goes into argument `argumentIndex` of `call`. This
181209
* can be either directly or through one pointer indirection.
@@ -273,23 +301,6 @@ private Element adjustedSink(DataFlow::Node sink) {
273301
// For compatibility, send flow into a `NotExpr` even if it's part of a
274302
// short-circuiting condition and thus might get skipped.
275303
result.(NotExpr).getOperand() = sink.asExpr()
276-
or
277-
// For compatibility, send flow from argument read side effects to their
278-
// corresponding argument expression
279-
exists(IndirectReadSideEffectInstruction read |
280-
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and
281-
read.getArgumentDef().getUnconvertedResultExpression() = result
282-
)
283-
or
284-
exists(BufferReadSideEffectInstruction read |
285-
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and
286-
read.getArgumentDef().getUnconvertedResultExpression() = result
287-
)
288-
or
289-
exists(SizedBufferReadSideEffectInstruction read |
290-
read.getAnOperand().(SideEffectOperand).getAnyDef() = sink.asInstruction() and
291-
read.getArgumentDef().getUnconvertedResultExpression() = result
292-
)
293304
}
294305

295306
predicate tainted(Expr source, Element tainted) {

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/AliasedSSA.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private predicate hasResultMemoryAccess(
2626
type = languageType.getIRType() and
2727
isIndirectOrBufferMemoryAccess(instr.getResultMemoryAccess()) and
2828
(if instr.hasResultMayMemoryAccess() then isMayAccess = true else isMayAccess = false) and
29-
if exists(type.getByteSize())
29+
if type.getByteSize() > 0
3030
then endBitOffset = Ints::add(startBitOffset, Ints::mul(type.getByteSize(), 8))
3131
else endBitOffset = Ints::unknown()
3232
)
@@ -43,7 +43,7 @@ private predicate hasOperandMemoryAccess(
4343
type = languageType.getIRType() and
4444
isIndirectOrBufferMemoryAccess(operand.getMemoryAccess()) and
4545
(if operand.hasMayReadMemoryAccess() then isMayAccess = true else isMayAccess = false) and
46-
if exists(type.getByteSize())
46+
if type.getByteSize() > 0
4747
then endBitOffset = Ints::add(startBitOffset, Ints::mul(type.getByteSize(), 8))
4848
else endBitOffset = Ints::unknown()
4949
)

0 commit comments

Comments
 (0)