@@ -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
@@ -118,22 +120,26 @@ private API::Node getNodeFromInputOutputPath(API::InvokeNode baseNode, AccessPat
118
120
result = getNodeFromInputOutputPath ( baseNode , path , path .getNumToken ( ) )
119
121
}
120
122
121
- private predicate summaryStep ( API:: Node pred , API:: Node succ , string kind ) {
123
+ private predicate summaryStep ( API:: Node pred , API:: Node succ , string kind , boolean shouldInduceSteps ) {
122
124
exists ( string type , string path , API:: InvokeNode base , AccessPath input , AccessPath output |
123
- shouldInduceStepsFromSummary ( type , path ) and
124
125
ModelOutput:: relevantSummaryModel ( type , path , input , output , kind , _) and
125
126
ModelOutput:: resolvedSummaryBase ( type , path , base ) and
126
127
pred = getNodeFromInputOutputPath ( base , input ) and
127
- succ = getNodeFromInputOutputPath ( base , output )
128
+ succ = getNodeFromInputOutputPath ( base , output ) and
129
+ if shouldInduceStepsFromSummary ( type , path )
130
+ then shouldInduceSteps = true
131
+ else shouldInduceSteps = false
128
132
)
129
133
}
130
134
131
135
/**
132
136
* Like `ModelOutput::summaryStep` but with API nodes mapped to data-flow nodes.
133
137
*/
134
- private predicate summaryStepNodes ( DataFlow:: Node pred , DataFlow:: Node succ , string kind ) {
138
+ private predicate summaryStepNodes (
139
+ DataFlow:: Node pred , DataFlow:: Node succ , string kind , boolean shouldInduceSteps
140
+ ) {
135
141
exists ( API:: Node predNode , API:: Node succNode |
136
- summaryStep ( predNode , succNode , kind ) and
142
+ summaryStep ( predNode , succNode , kind , shouldInduceSteps ) and
137
143
pred = predNode .asSink ( ) and
138
144
succ = succNode .asSource ( )
139
145
)
@@ -142,14 +148,26 @@ private predicate summaryStepNodes(DataFlow::Node pred, DataFlow::Node succ, str
142
148
/** Data flow steps induced by summary models of kind `value`. */
143
149
private class DataFlowStepFromSummary extends DataFlow:: SharedFlowStep {
144
150
override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
145
- summaryStepNodes ( pred , succ , "value" )
151
+ summaryStepNodes ( pred , succ , "value" , true )
152
+ }
153
+ }
154
+
155
+ private class LegacyDataFlowStepFromSummary extends LegacyFlowStep {
156
+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
157
+ summaryStepNodes ( pred , succ , "value" , false )
146
158
}
147
159
}
148
160
149
161
/** Taint steps induced by summary models of kind `taint`. */
150
162
private class TaintStepFromSummary extends TaintTracking:: SharedTaintStep {
151
163
override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
152
- summaryStepNodes ( pred , succ , "taint" )
164
+ summaryStepNodes ( pred , succ , "taint" , true )
165
+ }
166
+ }
167
+
168
+ private class LegacyTaintStepFromSummary extends LegacyTaintStep {
169
+ override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
170
+ summaryStepNodes ( pred , succ , "taint" , false )
153
171
}
154
172
}
155
173
0 commit comments