Skip to content

Commit 773556e

Browse files
author
edvraa
committed
Use hasFlow where path is not needed
1 parent 1581a27 commit 773556e

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

csharp/ql/src/Security Features/CWE-502/UnsafeDeserialization.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ where
1919
(
2020
sink instanceof InstanceMethodSink and
2121
not exists(
22-
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::PathNode safeTypeUsage
22+
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::Node safeTypeUsage
2323
|
24-
safeConstructorTracking.hasFlowPath(_, safeTypeUsage) and
25-
safeTypeUsage.getNode().asExpr().getParent() = deserializeCall
24+
safeConstructorTracking.hasFlow(_, safeTypeUsage) and
25+
safeTypeUsage.asExpr().getParent() = deserializeCall
2626
)
2727
or
2828
sink instanceof ConstructorOrStaticMethodSink

csharp/ql/src/Security Features/CWE-502/UnsafeDeserializationUntrustedInput.ql

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,28 @@ where
3333
// intersect with strong types, but user controlled or weak types deserialization usages
3434
(
3535
exists(
36-
DataFlow::PathNode weakTypeCreation, DataFlow::PathNode weakTypeUsage,
36+
DataFlow::Node weakTypeCreation, DataFlow::Node weakTypeUsage,
3737
WeakTypeCreationToUsageTrackingConfig weakTypeDeserializerTracking
3838
|
39-
weakTypeDeserializerTracking.hasFlowPath(weakTypeCreation, weakTypeUsage) and
40-
weakTypeUsage.getNode().asExpr().getParent() =
41-
deserializeCallArg.getNode().asExpr().getParent()
39+
weakTypeDeserializerTracking.hasFlow(weakTypeCreation, weakTypeUsage) and
40+
weakTypeUsage.asExpr().getParent() = deserializeCallArg.getNode().asExpr().getParent()
4241
)
4342
or
4443
exists(
45-
TaintToObjectTypeTrackingConfig userControlledTypeTracking,
46-
DataFlow::PathNode taintedTypeUsage, DataFlow::PathNode userInput2
44+
TaintToObjectTypeTrackingConfig userControlledTypeTracking, DataFlow::Node taintedTypeUsage,
45+
DataFlow::Node userInput2
4746
|
48-
userControlledTypeTracking.hasFlowPath(userInput2, taintedTypeUsage) and
49-
taintedTypeUsage.getNode().asExpr().getParent() =
50-
deserializeCallArg.getNode().asExpr().getParent()
47+
userControlledTypeTracking.hasFlow(userInput2, taintedTypeUsage) and
48+
taintedTypeUsage.asExpr().getParent() = deserializeCallArg.getNode().asExpr().getParent()
5149
)
5250
) and
5351
// exclude deserialization flows with safe instances (i.e. JavaScriptSerializer without resolver)
5452
not exists(
55-
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::PathNode safeCreation,
56-
DataFlow::PathNode safeTypeUsage
53+
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::Node safeCreation,
54+
DataFlow::Node safeTypeUsage
5755
|
58-
safeConstructorTracking.hasFlowPath(safeCreation, safeTypeUsage) and
59-
safeTypeUsage.getNode().asExpr().getParent() = deserializeCallArg.getNode().asExpr().getParent()
56+
safeConstructorTracking.hasFlow(safeCreation, safeTypeUsage) and
57+
safeTypeUsage.asExpr().getParent() = deserializeCallArg.getNode().asExpr().getParent()
6058
)
6159
or
6260
// no type check needed - straightforward taint -> sink

0 commit comments

Comments
 (0)