Skip to content

Commit a195d07

Browse files
committed
JS: Resolve Angular2 templateUrl with ResolveExpr instead of PathExpr
1 parent d724874 commit a195d07

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Angular2.qll

+9-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ private import semmle.javascript.security.dataflow.ClientSideUrlRedirectCustomiz
99
private import semmle.javascript.DynamicPropertyAccess
1010
private import semmle.javascript.dataflow.internal.PreCallGraphStep
1111
private import semmle.javascript.ViewComponentInput
12+
private import semmle.javascript.internal.paths.PathExprResolver
1213

1314
/**
1415
* Provides classes for working with Angular (also known as Angular 2.x) applications.
@@ -240,18 +241,15 @@ module Angular2 {
240241

241242
class TemplateTopLevel = Templating::TemplateTopLevel;
242243

243-
/** The RHS of a `templateUrl` property, seen as a path expression. */
244-
private class TemplateUrlPath extends PathExpr {
245-
TemplateUrlPath() {
246-
exists(Property prop |
247-
prop.getName() = "templateUrl" and
248-
this = prop.getInit()
249-
)
250-
}
251-
252-
override string getValue() { result = this.(Expr).getStringValue() }
244+
private predicate shouldResolveExpr(Expr e) {
245+
exists(Property prop |
246+
prop.getName() = "templateUrl" and
247+
e = prop.getInit()
248+
)
253249
}
254250

251+
private module Resolver = ResolveExpr<shouldResolveExpr/1>;
252+
255253
/**
256254
* Holds if the value of `attrib` is interpreted as an Angular expression.
257255
*/
@@ -338,7 +336,7 @@ module Angular2 {
338336
*/
339337
pragma[noinline]
340338
File getTemplateFile() {
341-
result = decorator.getOptionArgument(0, "templateUrl").asExpr().(PathExpr).resolve()
339+
result = Resolver::resolveExpr(decorator.getOptionArgument(0, "templateUrl").asExpr())
342340
}
343341

344342
/** Gets an element in the HTML template of this component. */

0 commit comments

Comments
 (0)