@@ -60,7 +60,7 @@ predicate localAdditionalTaintStep(DataFlow::Node pred, DataFlow::Node succ) {
6060 tupleStep ( pred , succ ) or
6161 stringConcatStep ( pred , succ ) or
6262 sliceStep ( pred , succ ) or
63- functionModelStep ( _ , pred , succ ) or
63+ any ( FunctionModel fm ) . taintStep ( pred , succ ) or
6464 any ( AdditionalTaintStep a ) .step ( pred , succ )
6565}
6666
@@ -140,23 +140,33 @@ predicate sliceStep(DataFlow::Node pred, DataFlow::Node succ) {
140140 succ .( DataFlow:: SliceNode ) .getBase ( ) = pred
141141}
142142
143- /** Holds if taint flows from `pred` to `succ` via a function model. */
144- predicate functionModelStep ( FunctionModel fn , DataFlow:: Node pred , DataFlow:: Node succ ) {
145- exists ( DataFlow:: CallNode c , FunctionInput inp , FunctionOutput outp |
146- c = fn .getACall ( ) and
147- fn .hasTaintFlow ( inp , outp ) and
148- pred = inp .getNode ( c ) and
149- succ = outp .getNode ( c )
150- )
151- }
152-
153143/**
154144 * A model of a function specifying that the function propagates taint from
155145 * a parameter or qualifier to a result.
156146 */
157147abstract class FunctionModel extends Function {
158148 /** Holds if taint propagates through this function from `input` to `output`. */
159149 abstract predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) ;
150+
151+ /** Gets an input node for this model for the call `c`. */
152+ DataFlow:: Node getAnInputNode ( DataFlow:: CallNode c ) { this .taintStepForCall ( result , _, c ) }
153+
154+ /** Gets an output node for this model for the call `c`. */
155+ DataFlow:: Node getAnOutputNode ( DataFlow:: CallNode c ) { this .taintStepForCall ( _, result , c ) }
156+
157+ /** Holds if this function model causes taint to flow from `pred` to `succ` for the call `c`. */
158+ predicate taintStepForCall ( DataFlow:: Node pred , DataFlow:: Node succ , DataFlow:: CallNode c ) {
159+ c = this .getACall ( ) and
160+ exists ( FunctionInput inp , FunctionOutput outp | this .hasTaintFlow ( inp , outp ) |
161+ pred = inp .getNode ( c ) and
162+ succ = outp .getNode ( c )
163+ )
164+ }
165+
166+ /** Holds if this function model causes taint to flow from `pred` to `succ`. */
167+ predicate taintStep ( DataFlow:: Node pred , DataFlow:: Node succ ) {
168+ this .taintStepForCall ( pred , succ , _)
169+ }
160170}
161171
162172/**
0 commit comments