@@ -21,6 +21,8 @@ private import internal.ApiGraphModels as Shared
2121private import internal.ApiGraphModelsSpecific as Specific
2222private import semmle.javascript.dataflow.internal.FlowSummaryPrivate
2323private import semmle.javascript.endpoints.EndpointNaming as EndpointNaming
24+ private import semmle.javascript.dataflow.AdditionalFlowSteps
25+ private import semmle.javascript.dataflow.AdditionalTaintSteps
2426import Shared:: ModelInput as ModelInput
2527import Shared:: ModelOutput as ModelOutput
2628
@@ -87,9 +89,6 @@ private predicate shouldInduceStepsFromSummary(string type, string path) {
8789pragma [ nomagic]
8890private predicate relevantInputOutputPath ( API:: InvokeNode base , AccessPath inputOrOutput ) {
8991 exists ( string type , string input , string output , string path |
90- // If the summary for 'callable' could not be handled as a flow summary, we need to evaluate
91- // its inputs and outputs to a set of nodes, so we can generate steps instead.
92- shouldInduceStepsFromSummary ( type , path ) and
9392 ModelOutput:: resolvedSummaryBase ( type , path , base ) and
9493 ModelOutput:: relevantSummaryModel ( type , path , input , output , _, _) and
9594 inputOrOutput = [ input , output ]
@@ -118,22 +117,26 @@ private API::Node getNodeFromInputOutputPath(API::InvokeNode baseNode, AccessPat
118117 result = getNodeFromInputOutputPath ( baseNode , path , path .getNumToken ( ) )
119118}
120119
121- private predicate summaryStep ( API:: Node pred , API:: Node succ , string kind ) {
120+ private predicate summaryStep ( API:: Node pred , API:: Node succ , string kind , boolean shouldInduceSteps ) {
122121 exists ( string type , string path , API:: InvokeNode base , AccessPath input , AccessPath output |
123- shouldInduceStepsFromSummary ( type , path ) and
124122 ModelOutput:: relevantSummaryModel ( type , path , input , output , kind , _) and
125123 ModelOutput:: resolvedSummaryBase ( type , path , base ) and
126124 pred = getNodeFromInputOutputPath ( base , input ) and
127- succ = getNodeFromInputOutputPath ( base , output )
125+ succ = getNodeFromInputOutputPath ( base , output ) and
126+ if shouldInduceStepsFromSummary ( type , path )
127+ then shouldInduceSteps = true
128+ else shouldInduceSteps = false
128129 )
129130}
130131
131132/**
132133 * Like `ModelOutput::summaryStep` but with API nodes mapped to data-flow nodes.
133134 */
134- private predicate summaryStepNodes ( DataFlow:: Node pred , DataFlow:: Node succ , string kind ) {
135+ private predicate summaryStepNodes (
136+ DataFlow:: Node pred , DataFlow:: Node succ , string kind , boolean shouldInduceSteps
137+ ) {
135138 exists ( API:: Node predNode , API:: Node succNode |
136- summaryStep ( predNode , succNode , kind ) and
139+ summaryStep ( predNode , succNode , kind , shouldInduceSteps ) and
137140 pred = predNode .asSink ( ) and
138141 succ = succNode .asSource ( )
139142 )
@@ -142,14 +145,26 @@ private predicate summaryStepNodes(DataFlow::Node pred, DataFlow::Node succ, str
142145/** Data flow steps induced by summary models of kind `value`. */
143146private class DataFlowStepFromSummary extends DataFlow:: SharedFlowStep {
144147 override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
145- summaryStepNodes ( pred , succ , "value" )
148+ summaryStepNodes ( pred , succ , "value" , true )
149+ }
150+ }
151+
152+ private class LegacyDataFlowStepFromSummary extends LegacyFlowStep {
153+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
154+ summaryStepNodes ( pred , succ , "value" , false )
146155 }
147156}
148157
149158/** Taint steps induced by summary models of kind `taint`. */
150159private class TaintStepFromSummary extends TaintTracking:: SharedTaintStep {
151160 override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
152- summaryStepNodes ( pred , succ , "taint" )
161+ summaryStepNodes ( pred , succ , "taint" , true )
162+ }
163+ }
164+
165+ private class LegacyTaintStepFromSummary extends LegacyTaintStep {
166+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
167+ summaryStepNodes ( pred , succ , "taint" , false )
153168 }
154169}
155170
0 commit comments