mirror of
https://github.com/github/codeql.git
synced 2026-05-01 11:45:14 +02:00
fix performance issue by inlining a simpler version of getASourceProp
This commit is contained in:
@@ -97,7 +97,7 @@ class NodeModule extends Module {
|
||||
// }
|
||||
exists(DynamicPropertyAccess::EnumeratedPropName read, Import imp, DataFlow::PropWrite write |
|
||||
read.getSourceObject().getALocalSource().asExpr() = imp and
|
||||
read.getASourceProp() = write.getRhs() and
|
||||
getASourceProp(read) = write.getRhs() and
|
||||
write.getBase() = this.getAModuleExportsNode() and
|
||||
write.getPropertyNameExpr().flow().getImmediatePredecessor*() = read and
|
||||
result = imp.getImportedModule().getAnExportedValue(name)
|
||||
@@ -163,6 +163,21 @@ class NodeModule extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
// An copy of `DynamicPropertyAccess::EnumeratedPropName::getASourceProp` that doesn't use the callgraph.
|
||||
// This avoids making the module-imports recursive with the callgraph.
|
||||
private DataFlow::SourceNode getASourceProp(DynamicPropertyAccess::EnumeratedPropName prop) {
|
||||
exists(DataFlow::Node base, DataFlow::Node key |
|
||||
exists(DynamicPropertyAccess::DynamicPropRead read |
|
||||
not read.hasDominatingAssignment() and
|
||||
base = read.getBase() and
|
||||
key = read.getPropertyNameNode() and
|
||||
result = read
|
||||
) and
|
||||
prop.getASourceObjectRef().flowsTo(base) and
|
||||
key.getImmediatePredecessor*() = prop
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an expression that syntactically could be a alias for `module.exports`.
|
||||
* This predicate exists to reduce the size of `getAModuleExportsNode`,
|
||||
|
||||
Reference in New Issue
Block a user