@@ -21,6 +21,8 @@ private import internal.ApiGraphModels as Shared
21
21
private import internal.ApiGraphModelsSpecific as Specific
22
22
private import semmle.javascript.dataflow.internal.FlowSummaryPrivate
23
23
private import semmle.javascript.endpoints.EndpointNaming as EndpointNaming
24
+ private import semmle.javascript.dataflow.AdditionalFlowSteps
25
+ private import semmle.javascript.dataflow.AdditionalTaintSteps
24
26
import Shared:: ModelInput as ModelInput
25
27
import Shared:: ModelOutput as ModelOutput
26
28
@@ -87,9 +89,6 @@ private predicate shouldInduceStepsFromSummary(string type, string path) {
87
89
pragma [ nomagic]
88
90
private predicate relevantInputOutputPath ( API:: InvokeNode base , AccessPath inputOrOutput ) {
89
91
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
93
92
ModelOutput:: resolvedSummaryBase ( type , path , base ) and
94
93
ModelOutput:: relevantSummaryModel ( type , path , input , output , _, _) and
95
94
inputOrOutput = [ input , output ]
@@ -118,22 +117,26 @@ private API::Node getNodeFromInputOutputPath(API::InvokeNode baseNode, AccessPat
118
117
result = getNodeFromInputOutputPath ( baseNode , path , path .getNumToken ( ) )
119
118
}
120
119
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 ) {
122
121
exists ( string type , string path , API:: InvokeNode base , AccessPath input , AccessPath output |
123
- shouldInduceStepsFromSummary ( type , path ) and
124
122
ModelOutput:: relevantSummaryModel ( type , path , input , output , kind , _) and
125
123
ModelOutput:: resolvedSummaryBase ( type , path , base ) and
126
124
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
128
129
)
129
130
}
130
131
131
132
/**
132
133
* Like `ModelOutput::summaryStep` but with API nodes mapped to data-flow nodes.
133
134
*/
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
+ ) {
135
138
exists ( API:: Node predNode , API:: Node succNode |
136
- summaryStep ( predNode , succNode , kind ) and
139
+ summaryStep ( predNode , succNode , kind , shouldInduceSteps ) and
137
140
pred = predNode .asSink ( ) and
138
141
succ = succNode .asSource ( )
139
142
)
@@ -142,14 +145,26 @@ private predicate summaryStepNodes(DataFlow::Node pred, DataFlow::Node succ, str
142
145
/** Data flow steps induced by summary models of kind `value`. */
143
146
private class DataFlowStepFromSummary extends DataFlow:: SharedFlowStep {
144
147
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 )
146
155
}
147
156
}
148
157
149
158
/** Taint steps induced by summary models of kind `taint`. */
150
159
private class TaintStepFromSummary extends TaintTracking:: SharedTaintStep {
151
160
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 )
153
168
}
154
169
}
155
170
0 commit comments