File tree Expand file tree Collapse file tree 5 files changed +38
-0
lines changed
src/semmle/javascript/dataflow/internal
test/library-tests/ThisExpr Expand file tree Collapse file tree 5 files changed +38
-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
+ | 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 |
3
+ | module-exports.js:4:28:4:31 | this | file://:0:0:0:0 | indefinite value (call) |
4
+ | module-exports.js:4:28:4:31 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
5
+ | module-exports.js:4:28:4:31 | this | module-exports.js:4:15:4:34 | instance of anonymous function |
6
+ | module-exports.js:5:35:5:38 | this | file://:0:0:0:0 | indefinite value (call) |
7
+ | module-exports.js:5:35:5:38 | this | file://:0:0:0:0 | indefinite value (heap) |
8
+ | module-exports.js:5:35:5:38 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
9
+ | module-exports.js:5:35:5:38 | this | module-exports.js:5:22:5:41 | instance of anonymous function |
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 |
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 |
1
14
| tst.js:4:9:4:12 | this | file://:0:0:0:0 | indefinite value (call) |
2
15
| tst.js:4:9:4:12 | this | tst.js:1:1:11:1 | instance of class C_normal |
3
16
| tst.js:8:15:8:18 | this | file://:0:0:0:0 | indefinite value (call) |
Original file line number Diff line number Diff line change 1
1
missingBasicBlock
2
2
basicBlock
3
+ | module-exports.js:1:1:1:0 | this | module-exports.js:1:1:1:0 | entry node of <toplevel> |
4
+ | module-exports.js:4:15:4:14 | this | module-exports.js:4:15:4:14 | entry node of function() { this; } |
5
+ | module-exports.js:5:22:5:21 | this | module-exports.js:5:22:5:21 | entry node of function() { this; } |
3
6
| tst.js:1:1:1:0 | this | tst.js:1:1:1:0 | entry node of <toplevel> |
4
7
| tst.js:1:16:1:15 | this | tst.js:1:16:1:15 | entry node of () {} |
5
8
| tst.js:3:7:3:6 | this | tst.js:3:7:3:6 | entry node of () {\\n ... ;\\n } |
Original file line number Diff line number Diff line change
1
+ | module-exports.js:4:28:4:31 | this | module-exports.js:4:15:4:34 | function() { this; } |
2
+ | module-exports.js:5:35:5:38 | this | module-exports.js:5:22:5:41 | function() { this; } |
1
3
| tst.js:4:9:4:12 | this | tst.js:3:7:5:5 | () {\\n ... ;\\n } |
2
4
| tst.js:8:15:8:18 | this | tst.js:7:7:9:5 | () {\\n ... ;\\n } |
3
5
| tst.js:17:13:17:16 | this | tst.js:16:10:18:9 | functio ... } |
Original file line number Diff line number Diff line change
1
+ var fs = require ( 'fs' ) ;
2
+
3
+ this ;
4
+ exports . foo = function ( ) { this ; } ;
5
+ module . exports . bar = function ( ) { this ; } ;
6
+ exports . baz = ( ) => this ;
7
+ module . exports . qux = ( ) => this ;
You can’t perform that action at this time.
0 commit comments