JS: Avoid bad join order in ImplicitProcessImport

This commit is contained in:
Asger Feldthaus 2020-04-30 11:34:41 +01:00
Родитель c869812563
Коммит 6a63f5b677
1 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -7,17 +7,28 @@ import semmle.javascript.frameworks.HTTP
import semmle.javascript.security.SensitiveActions
module NodeJSLib {
private GlobalVariable processVariable() {
variables(result, "process", any(GlobalScope sc))
}
pragma[nomagic]
private GlobalVarAccess processExprInTopLevel(TopLevel tl) {
result = processVariable().getAnAccess() and
tl = result.getTopLevel()
}
pragma[nomagic]
private GlobalVarAccess processExprInNodeModule() {
result = processExprInTopLevel(any(NodeModule m))
}
/**
* An access to the global `process` variable in a Node.js module, interpreted as
* an import of the `process` module.
*/
private class ImplicitProcessImport extends DataFlow::ModuleImportNode::Range {
ImplicitProcessImport() {
exists(GlobalVariable process |
process.getName() = "process" and
this = DataFlow::exprNode(process.getAnAccess())
) and
getTopLevel() instanceof NodeModule
this = DataFlow::exprNode(processExprInNodeModule())
}
override string getPath() { result = "process" }