Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a441bfb

Browse files
author
Max Schaefer
committed
JavaScript: Add a convenience method to AMDModuleDefinition.
1 parent b130335 commit a441bfb

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

javascript/ql/src/semmle/javascript/AMD.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ class AMDModuleDefinition extends CallExpr {
8383
)
8484
}
8585

86+
/** Gets a source node whose value becomes the definition of this module. */
87+
DataFlow::SourceNode getAModuleSource() {
88+
result.flowsToExpr(getModuleExpr())
89+
}
90+
8691
/**
8792
* Holds if `p` is the parameter corresponding to dependency `dep`.
8893
*/
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| a.js:1:1:3:2 | define( ... 2 };\\n}) | a.js:2:12:2:22 | { foo: 42 } |
2-
| dir/b.js:1:1:3:2 | define( ... : 42\\n}) | dir/b.js:1:8:3:1 | {\\n bar: 42\\n} |
3-
| tst.js:1:1:6:2 | define( ... };\\n}) | tst.js:2:12:5:5 | {\\n ... r\\n } |
4-
| umd.js:4:9:4:43 | define( ... actory) | umd.js:10:12:13:5 | {\\n ... r\\n } |
1+
| a.js:1:1:3:2 | define( ... 2 };\\n}) | a.js:2:12:2:22 | { foo: 42 } | a.js:2:12:2:22 | { foo: 42 } |
2+
| dir/b.js:1:1:3:2 | define( ... : 42\\n}) | dir/b.js:1:8:3:1 | {\\n bar: 42\\n} | dir/b.js:1:8:3:1 | {\\n bar: 42\\n} |
3+
| tst.js:1:1:6:2 | define( ... };\\n}) | tst.js:2:12:5:5 | {\\n ... r\\n } | tst.js:2:12:5:5 | {\\n ... r\\n } |
4+
| umd.js:4:9:4:43 | define( ... actory) | umd.js:10:12:13:5 | {\\n ... r\\n } | umd.js:10:12:13:5 | {\\n ... r\\n } |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import javascript
22

33
from AMDModuleDefinition d
4-
select d, d.getModuleExpr()
4+
select d, d.getModuleExpr(), d.getAModuleSource()

0 commit comments

Comments
 (0)