File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
src/semmle/javascript/dataflow/internal
test/library-tests/ThisExpr Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,19 @@ private class AnalyzedThisInBoundFunction extends AnalyzedThisExpr {
45
45
}
46
46
}
47
47
48
+ /**
49
+ * Flow analysis for `this` expressions in node modules.
50
+ *
51
+ * These expressions are assumed to refer to the `module.exports` object.
52
+ */
53
+ private class AnalyzedThisAsModuleExports extends DataFlow:: AnalyzedNode , DataFlow:: ThisNode {
54
+ NodeModule m ;
55
+
56
+ AnalyzedThisAsModuleExports ( ) { m = getBindingContainer ( ) }
57
+
58
+ override AbstractValue getALocalValue ( ) { result = TAbstractExportsObject ( m ) }
59
+ }
60
+
48
61
/**
49
62
* Flow analysis for `this` expressions inside a function that is instantiated.
50
63
*
Original file line number Diff line number Diff line change 1
1
| module-exports.js:3:1:3:4 | this | file://:0:0:0:0 | indefinite value (call) |
2
+ | module-exports.js:3:1:3:4 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
2
3
| module-exports.js:4:28:4:31 | this | file://:0:0:0:0 | indefinite value (call) |
3
4
| module-exports.js:4:28:4:31 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
4
5
| module-exports.js:4:28:4:31 | this | module-exports.js:4:15:4:34 | instance of anonymous function |
7
8
| module-exports.js:5:35:5:38 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
8
9
| module-exports.js:5:35:5:38 | this | module-exports.js:5:22:5:41 | instance of anonymous function |
9
10
| module-exports.js:6:21:6:24 | this | file://:0:0:0:0 | indefinite value (call) |
11
+ | module-exports.js:6:21:6:24 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
10
12
| module-exports.js:7:28:7:31 | this | file://:0:0:0:0 | indefinite value (call) |
13
+ | module-exports.js:7:28:7:31 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
11
14
| tst.js:4:9:4:12 | this | file://:0:0:0:0 | indefinite value (call) |
12
15
| tst.js:4:9:4:12 | this | tst.js:1:1:11:1 | instance of class C_normal |
13
16
| tst.js:8:15:8:18 | this | file://:0:0:0:0 | indefinite value (call) |
You can’t perform that action at this time.
0 commit comments