Skip to content

Commit 2706238

Browse files
committed
C#: Update queries to use localExprFlow.
1 parent af25536 commit 2706238

File tree

8 files changed

+10
-13
lines changed

8 files changed

+10
-13
lines changed

csharp/ql/src/Bad Practices/Implementation Hiding/ExposeRepresentation.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ predicate returnsCollection(Callable c, Field f) {
3232
predicate mayWriteToCollection(Expr modified) {
3333
modified instanceof CollectionModificationAccess
3434
or
35-
exists(Expr mid | mayWriteToCollection(mid) | localFlow(exprNode(modified), exprNode(mid)))
35+
exists(Expr mid | mayWriteToCollection(mid) | localExprFlow(modified, mid))
3636
or
3737
exists(MethodCall mid, Callable c | mayWriteToCollection(mid) |
3838
mid.getTarget() = c and

csharp/ql/src/Dead Code/DeadStoreOfLocal.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ predicate nonEscapingCall(Call c) {
6262
predicate mayEscape(LocalVariable v) {
6363
exists(Callable c, Expr e, Expr succ | c = getACapturingCallableAncestor(v) |
6464
e = getADelegateExpr(c) and
65-
DataFlow::localFlow(DataFlow::exprNode(e), DataFlow::exprNode(succ)) and
65+
DataFlow::localExprFlow(e, succ) and
6666
not succ = any(DelegateCall dc).getDelegateExpr() and
6767
not succ = any(Cast cast).getExpr() and
6868
not succ = any(Call call | nonEscapingCall(call)).getAnArgument() and

csharp/ql/src/Security Features/CWE-119/LocalUnvalidatedArithmetic.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ where
2222
// `add` is performing pointer arithmetic
2323
add.getType() instanceof PointerType and
2424
// one of the operands comes, in zero or more steps, from a virtual method call
25-
DataFlow::localFlow(DataFlow::exprNode(taintSrc), DataFlow::exprNode(add.getAnOperand())) and
25+
DataFlow::localExprFlow(taintSrc, add.getAnOperand()) and
2626
// virtual method call result has not been validated
2727
not exists(Expr check, ComparisonOperation cmp |
28-
DataFlow::localFlow(DataFlow::exprNode(taintSrc), DataFlow::exprNode(check))
28+
DataFlow::localExprFlow(taintSrc, check)
2929
|
3030
cmp.getAnOperand() = check and
3131
add.getAnOperand().(GuardedExpr).isGuardedBy(cmp, check, _)

csharp/ql/src/semmle/code/csharp/Property.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ class IndexerProperty extends Property {
520520
pragma[nomagic]
521521
private IndexerCall getAnIndexerCall0() {
522522
exists(Expr qualifier | qualifier = result.getQualifier() |
523-
DataFlow::localFlow(DataFlow::exprNode(this.getAnAccess()), DataFlow::exprNode(qualifier))
523+
DataFlow::localExprFlow(this.getAnAccess(), qualifier)
524524
)
525525
}
526526

csharp/ql/src/semmle/code/csharp/frameworks/system/Xml.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class XmlReaderSettingsCreation extends ObjectCreation {
156156
p = this.getType().(RefType).getAProperty() and
157157
exists(PropertyCall set, Expr arg |
158158
set.getTarget() = p.getSetter() and
159-
DataFlow::localFlow(DataFlow::exprNode(this), DataFlow::exprNode(set.getQualifier())) and
159+
DataFlow::localExprFlow(this, set.getQualifier()) and
160160
arg = set.getAnArgument() and
161161
result = getBitwiseOrOperand*(arg)
162162
)

csharp/ql/src/semmle/code/csharp/frameworks/system/text/RegularExpressions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class RegexOperation extends Call {
7171
|
7272
// e.g. `new Regex(...).Match(...)`
7373
// or `var r = new Regex(...); r.Match(...)`
74-
DataFlow::localFlow(DataFlow::exprNode(this), DataFlow::exprNode(call.getQualifier()))
74+
DataFlow::localExprFlow(this, call.getQualifier())
7575
or
7676
// e.g. `private string r = new Regex(...); public void foo() { r.Match(...); }`
7777
call.getQualifier().(FieldAccess).getTarget().getInitializer() = this

csharp/ql/src/semmle/code/csharp/security/dataflow/ZipSlip.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ module ZipSlip {
142142
// not yet been resolved.
143143
not exists(MethodCall combineCall |
144144
combineCall.getTarget().hasQualifiedName("System.IO.Path", "Combine") and
145-
DataFlow::localFlow(DataFlow::exprNode(combineCall), DataFlow::exprNode(q))
145+
DataFlow::localExprFlow(combineCall, q)
146146
)
147147
}
148148

csharp/ql/src/semmle/code/csharp/security/xml/InsecureXML.qll

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ module InsecureXML {
8787
or
8888
// values set on var that create is assigned to
8989
exists(Assignment propAssign |
90-
DataFlow::localFlow(DataFlow::exprNode(create),
91-
DataFlow::exprNode(propAssign.getLValue().(PropertyAccess).getQualifier())) and
90+
DataFlow::localExprFlow(create, propAssign.getLValue().(PropertyAccess).getQualifier()) and
9291
propAssign.getLValue().(PropertyAccess).getTarget().hasName(prop) and
9392
result = propAssign.getRValue()
9493
)
@@ -253,9 +252,7 @@ module InsecureXML {
253252
}
254253

255254
override predicate isUnsafe(string reason) {
256-
exists(ObjectCreation creation |
257-
DataFlow::localFlow(DataFlow::exprNode(creation), DataFlow::exprNode(this.getQualifier()))
258-
|
255+
exists(ObjectCreation creation | DataFlow::localExprFlow(creation, this.getQualifier()) |
259256
not exists(Expr xmlResolverVal |
260257
isSafeXmlResolver(xmlResolverVal) and
261258
xmlResolverVal = getAValueForProp(creation, "XmlResolver")

0 commit comments

Comments
 (0)