mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
JS: infer this to be module.exports in node modules
This commit is contained in:
@@ -45,6 +45,19 @@ private class AnalyzedThisInBoundFunction extends AnalyzedThisExpr {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flow analysis for `this` expressions in node modules.
|
||||
*
|
||||
* These expressions are assumed to refer to the `module.exports` object.
|
||||
*/
|
||||
private class AnalyzedThisAsModuleExports extends DataFlow::AnalyzedNode, DataFlow::ThisNode {
|
||||
NodeModule m;
|
||||
|
||||
AnalyzedThisAsModuleExports() { m = getBindingContainer() }
|
||||
|
||||
override AbstractValue getALocalValue() { result = TAbstractExportsObject(m) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Flow analysis for `this` expressions inside a function that is instantiated.
|
||||
*
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
| module-exports.js:3:1:3:4 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
| module-exports.js:3:1:3:4 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
|
||||
| module-exports.js:4:28:4:31 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
| module-exports.js:4:28:4:31 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
|
||||
| module-exports.js:4:28:4:31 | this | module-exports.js:4:15:4:34 | instance of anonymous function |
|
||||
@@ -7,7 +8,9 @@
|
||||
| module-exports.js:5:35:5:38 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
|
||||
| module-exports.js:5:35:5:38 | this | module-exports.js:5:22:5:41 | instance of anonymous function |
|
||||
| module-exports.js:6:21:6:24 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
| module-exports.js:6:21:6:24 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
|
||||
| module-exports.js:7:28:7:31 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
| module-exports.js:7:28:7:31 | this | module-exports.js:1:1:8:0 | exports object of module module-exports |
|
||||
| tst.js:4:9:4:12 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
| tst.js:4:9:4:12 | this | tst.js:1:1:11:1 | instance of class C_normal |
|
||||
| tst.js:8:15:8:18 | this | file://:0:0:0:0 | indefinite value (call) |
|
||||
|
||||
Reference in New Issue
Block a user