mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
disable import resolution on type-only import specifiers
This commit is contained in:
@@ -42,7 +42,7 @@ private predicate defn(ControlFlowNode def, Expr lhs, AST::ValueNode rhs) {
|
||||
lhs = i.getIdentifier() and rhs = i.getImportedEntity()
|
||||
)
|
||||
or
|
||||
exists(ImportSpecifier i | def = i | lhs = i.getLocal() and rhs = i)
|
||||
exists(ImportSpecifier i | def = i and not i.isTypeOnly() | lhs = i.getLocal() and rhs = i)
|
||||
or
|
||||
exists(EnumMember member | def = member.getIdentifier() |
|
||||
lhs = def and rhs = member.getInitializer()
|
||||
|
||||
@@ -881,6 +881,7 @@ module DataFlow {
|
||||
|
||||
ImportSpecifierAsPropRead() {
|
||||
astNode = imprt.getASpecifier() and
|
||||
not astNode.isTypeOnly() and
|
||||
exists(astNode.getImportedName())
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,11 @@ private import AbstractPropertiesImpl
|
||||
private class AnalyzedImportSpecifier extends AnalyzedVarDef, @import_specifier {
|
||||
ImportDeclaration id;
|
||||
|
||||
AnalyzedImportSpecifier() { this = id.getASpecifier() and exists(id.resolveImportedPath()) }
|
||||
AnalyzedImportSpecifier() {
|
||||
this = id.getASpecifier() and
|
||||
exists(id.resolveImportedPath()) and
|
||||
not this.(ImportSpecifier).isTypeOnly()
|
||||
}
|
||||
|
||||
override DataFlow::AnalyzedNode getRhs() { result.(AnalyzedImport).getImportSpecifier() = this }
|
||||
|
||||
@@ -135,10 +139,12 @@ private predicate incompleteExport(ES2015Module m, string y) {
|
||||
*/
|
||||
private class AnalyzedImport extends AnalyzedPropertyRead, DataFlow::ValueNode {
|
||||
Module imported;
|
||||
override ImportSpecifier astNode;
|
||||
|
||||
AnalyzedImport() {
|
||||
exists(ImportDeclaration id |
|
||||
astNode = id.getASpecifier() and
|
||||
not astNode.isTypeOnly() and
|
||||
imported = id.getImportedModule()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user