@@ -24,20 +24,54 @@ predicate defaultTaintSanitizerGuard(DataFlow::BarrierGuard guard) { none() }
24
24
bindingset [ node]
25
25
predicate defaultImplicitTaintRead ( DataFlow:: Node node , DataFlow:: Content c ) { none ( ) }
26
26
27
+ private CfgNodes:: ExprNodes:: VariableWriteAccessCfgNode variablesInPattern (
28
+ CfgNodes:: ExprNodes:: CasePatternCfgNode p
29
+ ) {
30
+ result = p
31
+ or
32
+ exists ( CfgNodes:: ExprNodes:: AsPatternCfgNode ap | p = ap |
33
+ result = variablesInPattern ( ap .getPattern ( ) ) or
34
+ result = ap .getVariableAccess ( )
35
+ )
36
+ or
37
+ exists ( CfgNodes:: ExprNodes:: ParenthesizedPatternCfgNode pp | p = pp |
38
+ result = variablesInPattern ( pp .getPattern ( ) )
39
+ )
40
+ or
41
+ exists ( CfgNodes:: ExprNodes:: AlternativePatternCfgNode ap | p = ap |
42
+ result = variablesInPattern ( ap .getAlternative ( _) )
43
+ )
44
+ or
45
+ exists ( CfgNodes:: ExprNodes:: ArrayPatternCfgNode ap | p = ap |
46
+ result = variablesInPattern ( ap .getPrefixElement ( _) ) or
47
+ result = variablesInPattern ( ap .getSuffixElement ( _) ) or
48
+ result = ap .getRestVariableAccess ( )
49
+ )
50
+ or
51
+ exists ( CfgNodes:: ExprNodes:: FindPatternCfgNode fp | p = fp |
52
+ result = variablesInPattern ( fp .getElement ( _) ) or
53
+ result = fp .getPrefixVariableAccess ( ) or
54
+ result = fp .getSuffixVariableAccess ( )
55
+ )
56
+ or
57
+ exists ( CfgNodes:: ExprNodes:: HashPatternCfgNode hp | p = hp |
58
+ result = variablesInPattern ( hp .getValue ( _) ) or
59
+ result = hp .getRestVariableAccess ( )
60
+ )
61
+ }
62
+
27
63
/**
28
64
* Holds if the additional step from `nodeFrom` to `nodeTo` should be included
29
65
* in all global taint flow configurations.
30
66
*/
31
67
cached
32
68
predicate defaultAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
33
69
// value of `case` expression into variables in patterns
34
- exists ( VariableWriteAccess varDef , CaseExpr case , InClause clause , CfgNode nodeToCfg |
35
- clause = case .getABranch ( ) and
36
- varDef .getParent * ( ) = clause .getPattern ( ) and
37
- nodeFrom .asExpr ( ) .getExpr ( ) = case .getValue ( ) and
38
- nodeToCfg = nodeTo .( SsaDefinitionNode ) .getDefinition ( ) .getControlFlowNode ( ) and
39
- nodeToCfg = nodeFrom .asExpr ( ) .getASuccessor + ( ) and
40
- nodeToCfg .getNode ( ) = varDef
70
+ exists ( CfgNodes:: ExprNodes:: CaseExprCfgNode case , CfgNodes:: ExprNodes:: InClauseCfgNode clause |
71
+ nodeFrom .asExpr ( ) = case .getValue ( ) and
72
+ clause = case .getBranch ( _) and
73
+ nodeTo .( SsaDefinitionNode ) .getDefinition ( ) .getControlFlowNode ( ) =
74
+ variablesInPattern ( clause .getPattern ( ) )
41
75
)
42
76
or
43
77
// operation involving `nodeFrom`
0 commit comments