Skip to content

Commit 0752dbe

Browse files
authored
Merge pull request #20360 from asgerf/js/remove-angularjs-string-special-case
JS: Remove special treatment of strings in AngularJS code
2 parents b5045b3 + 4926d27 commit 0752dbe

File tree

3 files changed

+3
-40
lines changed

3 files changed

+3
-40
lines changed

javascript/ql/lib/semmle/javascript/dataflow/Sources.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ module SourceNode {
334334
astNode instanceof Templating::PipeRefExpr or
335335
astNode instanceof Templating::TemplateVarRefExpr or
336336
astNode instanceof StringLiteral or
337+
astNode instanceof TemplateLiteral or
337338
astNode instanceof TypeAssertion or
338339
astNode instanceof SatisfiesExpr
339340
)

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

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,46 +23,6 @@ DataFlow::SourceNode angular() {
2323
result = DataFlow::moduleImport("angular")
2424
}
2525

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.getImportedPathString() = "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]
50-
private predicate isAngularString(Expr s) {
51-
isAngularTopLevel(s.getTopLevel()) and
52-
(
53-
s instanceof StringLiteral or
54-
s instanceof TemplateLiteral
55-
)
56-
}
57-
58-
/**
59-
* String literals in Angular code are often used as identifiers or references, so we
60-
* want to track them.
61-
*/
62-
private class TrackStringsInAngularCode extends DataFlow::SourceNode::Range, DataFlow::ValueNode {
63-
TrackStringsInAngularCode() { isAngularString(astNode) }
64-
}
65-
6626
/**
6727
* Holds if `m` is of the form `angular.module("name", ...)`.
6828
*/

javascript/ql/test/library-tests/DataFlow/tests.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,10 @@ sources
15641564
| tst.js:50:14:53:3 | () {\\n ... et`\\n } |
15651565
| tst.js:50:14:53:3 | return of constructor of class A |
15661566
| tst.js:51:5:51:13 | super(42) |
1567+
| tst.js:57:1:57:9 | `x: ${x}` |
15671568
| tst.js:58:1:58:3 | tag |
15681569
| tst.js:58:1:58:13 | tag `x: ${x}` |
1570+
| tst.js:58:5:58:13 | `x: ${x}` |
15691571
| tst.js:61:1:61:5 | ::o.m |
15701572
| tst.js:61:3:61:5 | o.m |
15711573
| tst.js:62:1:62:4 | o::g |

0 commit comments

Comments
 (0)