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

Skip to content

Commit af25536

Browse files
committed
C#: Add localExprFlow and localExprTaint, and change notes.
1 parent b55e294 commit af25536

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

change-notes/1.23/analysis-csharp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,8 @@ The following changes in version 1.23 affect C# analysis in all applications.
4040
overriding `int explorationLimit()`.
4141
* `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).
4242
* 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.
43+
* There is now a `DataFlow::localExprFlow` predicate and a
44+
`TaintTracking::localExprTaint` predicate to make it easy to use the most
45+
common case of local data flow and taint: from one `Expr` to another.
4346

4447
## Changes to autobuilder

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ predicate localFlowStep(Node nodeFrom, Node nodeTo) {
164164
*/
165165
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
166166

167+
/**
168+
* Holds if data can flow from `e1` to `e2` in zero or more
169+
* local (intra-procedural) steps.
170+
*/
171+
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
172+
167173
/**
168174
* A data flow node that jumps between callables. This can be extended in
169175
* framework code to add additional data flow steps.

csharp/ql/src/semmle/code/csharp/dataflow/internal/TaintTrackingPublic.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ private import TaintTrackingPrivate
77
*/
88
predicate localTaint(DataFlow::Node source, DataFlow::Node sink) { localTaintStep*(source, sink) }
99

10+
/**
11+
* Holds if taint can flow from `e1` to `e2` in zero or more
12+
* local (intra-procedural) steps.
13+
*/
14+
predicate localExprTaint(Expr e1, Expr e2) {
15+
localTaint(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
16+
}
17+
1018
/** A member (property or field) that is tainted if its containing object is tainted. */
1119
abstract class TaintedMember extends AssignableMember { }
1220

0 commit comments

Comments
 (0)