@@ -116,18 +116,30 @@ class ParameterToFieldConfig extends TaintTracking::Configuration {
116116 * `p;Foo;true;doSomething;(String);Argument[0];Argument[-1];taint`
117117 */
118118string captureFieldFlowIn ( Callable api ) {
119- exists ( DataFlow:: ParameterNode source , DataFlow:: ExprNode sink , ParameterToFieldConfig config |
120- sink .asExpr ( ) .getEnclosingCallable ( ) .getDeclaringType ( ) =
121- source .asParameter ( ) .getCallable ( ) .getDeclaringType ( ) and
119+ exists ( DataFlow:: PathNode source , DataFlow:: PathNode sink |
122120 not api .isStatic ( ) and
123- config . hasFlow ( source , sink ) and
124- source .asParameter ( ) .getCallable ( ) = api
121+ restrictedFlow ( source , sink ) and
122+ source .getNode ( ) . asParameter ( ) .getCallable ( ) = api
125123 |
126124 result =
127- asTaintModel ( api , "Argument[" + source .asParameter ( ) .getPosition ( ) + "]" , "Argument[-1]" )
125+ asTaintModel ( api , "Argument[" + source .getNode ( ) .asParameter ( ) .getPosition ( ) + "]" ,
126+ "Argument[-1]" )
128127 )
129128}
130129
130+ predicate restrictedEdge ( DataFlow:: PathNode n1 , DataFlow:: PathNode n2 ) {
131+ n1 .getASuccessor ( ) = n2 and
132+ n1 .getNode ( ) .getEnclosingCallable ( ) .getDeclaringType ( ) =
133+ n2 .getNode ( ) .getEnclosingCallable ( ) .getDeclaringType ( )
134+ }
135+
136+ predicate restrictedFlow ( DataFlow:: PathNode src , DataFlow:: PathNode sink ) {
137+ src .getConfiguration ( ) instanceof ParameterToFieldConfig and
138+ src .isSource ( ) and
139+ src .getConfiguration ( ) .isSink ( sink .getNode ( ) ) and
140+ restrictedEdge * ( src , sink )
141+ }
142+
131143class ParameterToReturnValueTaintConfig extends TaintTracking:: Configuration {
132144 ParameterToReturnValueTaintConfig ( ) { this = "ParameterToReturnValueTaintConfig" }
133145
0 commit comments