Skip to content

Commit 8f930fc

Browse files
committed
JS: Remove recursive SourceNode from AngularJS
1 parent ee106b1 commit 8f930fc

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

javascript/ql/src/semmle/javascript/frameworks/AngularJS/AngularJSCore.qll

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,33 @@ DataFlow::SourceNode angular() {
2323
result = DataFlow::moduleImport("angular")
2424
}
2525

26-
pragma[noopt]
26+
/**
27+
* Holds if `tl` appears to be a top-level using the AngularJS library.
28+
*
29+
* Should not depend on the `SourceNode` class.
30+
*/
31+
pragma[nomagic]
32+
private predicate isAngularTopLevel(TopLevel tl) {
33+
exists(Import imprt |
34+
imprt.getTopLevel() = tl and
35+
imprt.getImportedPath().getValue() = "angular"
36+
)
37+
or
38+
exists(GlobalVarAccess global |
39+
global.getName() = "angular" and
40+
global.getTopLevel() = tl
41+
)
42+
}
43+
44+
/**
45+
* Holds if `s` is a string in a top-level using the AngularJS library.
46+
*
47+
* Should not depend on the `SourceNode` class.
48+
*/
49+
pragma[nomagic]
2750
private predicate isAngularString(Expr s) {
28-
exists(DataFlow::SourceNode angular, StmtContainer sc, TopLevel tl |
29-
angular = angular() and
30-
sc = angular.getContainer() and
31-
tl = sc.getTopLevel() and
32-
tl = s.getTopLevel()
33-
|
51+
isAngularTopLevel(s.getTopLevel()) and
52+
(
3453
s instanceof StringLiteral or
3554
s instanceof TemplateLiteral
3655
)

0 commit comments

Comments
 (0)