Skip to content

Commit 1308070

Browse files
author
edvraa
committed
Make query symmetric
1 parent f8867e4 commit 1308070

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
import csharp
1414
import semmle.code.csharp.security.dataflow.UnsafeDeserialization::UnsafeDeserialization
1515

16-
from Call deserializeCall, InstanceMethodSink sink
16+
from Call deserializeCall, DataFlow::Node sink
1717
where
1818
deserializeCall.getAnArgument() = sink.asExpr() and
19-
not exists(
20-
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::PathNode safeCreation,
21-
DataFlow::PathNode safeTypeUsage
22-
|
23-
safeConstructorTracking.hasFlowPath(safeCreation, safeTypeUsage) and
24-
safeTypeUsage.getNode().asExpr().getParent() = deserializeCall
19+
(
20+
sink instanceof InstanceMethodSink and
21+
not exists(
22+
SafeConstructorTrackingConfig safeConstructorTracking, DataFlow::PathNode safeCreation,
23+
DataFlow::PathNode safeTypeUsage
24+
|
25+
safeConstructorTracking.hasFlowPath(safeCreation, safeTypeUsage) and
26+
safeTypeUsage.getNode().asExpr().getParent() = deserializeCall
27+
)
28+
or
29+
sink instanceof ConstructorOrStaticMethodSink and
30+
deserializeCall.getAnArgument() = sink.asExpr()
2531
)
26-
or
27-
exists(ConstructorOrStaticMethodSink sink2 | deserializeCall.getAnArgument() = sink2.asExpr())
2832
select deserializeCall,
2933
"Unsafe deserializer is used. Make sure the value being deserialized comes from a trusted source."

0 commit comments

Comments
 (0)