Skip to content

Commit f3b97f0

Browse files
committed
JS: Add steps to/from placeholder tags
1 parent f1c663b commit f3b97f0

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

javascript/ql/src/semmle/javascript/frameworks/Templating.qll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,33 @@ module Templating {
181181
}
182182
}
183183

184+
/**
185+
* A data flow step from the expression in a placeholder tag to the tag itself,
186+
* representing the value plugged into the template.
187+
*/
188+
private class TemplatePlaceholderStep extends DataFlow::SharedFlowStep {
189+
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
190+
exists(TemplatePlaceholderTag tag |
191+
pred = tag.getInnerTopLevel().getExpression().flow() and
192+
succ = tag.asDataFlowNode()
193+
)
194+
}
195+
}
196+
197+
/**
198+
* A taint step from a `TemplatePlaceholderTag` to the corresponding `GeneratedCodeExpr`,
199+
* representing that control over the generated code gives control over the expression
200+
* return value.
201+
*/
202+
private class PlaceholderToGeneratedCodeStep extends TaintTracking::SharedTaintStep {
203+
override predicate step(DataFlow::Node pred, DataFlow::Node succ) {
204+
exists(GeneratedCodeExpr expr |
205+
pred = expr.getPlaceholderTag().asDataFlowNode() and
206+
succ = expr.flow()
207+
)
208+
}
209+
}
210+
184211
/** A file that can be referenced by a template instantiation. */
185212
abstract class TemplateFile extends File {
186213
/** Gets a placeholder tag in this file. */

0 commit comments

Comments
 (0)