Skip to content

Commit b335b23

Browse files
committed
WIP.
1 parent cb60874 commit b335b23

2 files changed

Lines changed: 190 additions & 4 deletions

File tree

‎csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,6 +2308,30 @@ private predicate readStepDelegateCall(Node node1, ContentSet c, OutNode node2)
23082308
)
23092309
}
23102310

2311+
private predicate fieldOrPropertyPatternRead(Node node1, ContentSet c, Node node2) {
2312+
exists(PatternExpr pattern, LabeledPatternExpr label, FieldOrProperty f |
2313+
node1.asExpr() = pattern and
2314+
(
2315+
pattern.(RecursivePatternExpr).getPropertyPatterns().getPattern(_) = label
2316+
or
2317+
pattern.(PropertyPatternExpr).getPattern(_) = label
2318+
) and
2319+
c = f.getContentSet() and
2320+
// TODO: Should this be undecorated name to work for
2321+
f.getName() = label.getLabel()
2322+
|
2323+
node2.asExpr() = label.(RecursivePatternExpr)
2324+
or
2325+
node2.asExpr() = label.(PropertyPatternExpr)
2326+
or
2327+
// TODO: Should be extended to cover binding patterns as well. Add a test for it.
2328+
exists(AssignableDefinitions::PatternDefinition lvd |
2329+
node2.(AssignableDefinitionNode).getDefinition() = lvd and
2330+
label = lvd.getDeclaration()
2331+
)
2332+
)
2333+
}
2334+
23112335
/**
23122336
* Holds if data can flow from `node1` to `node2` via a read of content `c`.
23132337
*/
@@ -2319,6 +2343,8 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
23192343
or
23202344
fieldOrPropertyRead(node1.asExpr(), c, node2.asExpr())
23212345
or
2346+
fieldOrPropertyPatternRead(node1, c, node2)
2347+
or
23222348
dynamicPropertyRead(node1.asExpr(), c, node2.asExpr())
23232349
or
23242350
node2.asExpr().(AwaitExpr).getExpr() = node1.asExpr() and

0 commit comments

Comments
 (0)