Skip to content

Commit 4cd6f45

Browse files
committed
JS: Avoid accidental recursion with API graphs
1 parent b5a4fc0 commit 4cd6f45

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,13 @@ module API {
649649
/** Gets a node corresponding to an import of module `m` without taking into account types from models. */
650650
Node getAModuleImportRaw(string m) {
651651
result = Impl::MkModuleImport(m) or
652-
result = Impl::MkModuleImport(m).(Node).getMember("default")
652+
result = Impl::MkModuleImport(m).(Node).getMember("default") or
653+
result = Impl::MkTypeUse(m, "")
653654
}
654655

655656
/** Gets a node whose type has the given qualified name, not including types from models. */
656657
Node getANodeOfTypeRaw(string moduleName, string exportedName) {
658+
exportedName != "" and
657659
result = Impl::MkTypeUse(moduleName, exportedName).(Node).getInstance()
658660
or
659661
exportedName = "" and

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ API::Node getExtraNodeFromType(string type) {
138138
parseRelevantTypeString(type, package, qualifiedName)
139139
|
140140
qualifiedName = "" and
141-
result = [API::moduleImport(package), API::moduleExport(package)]
141+
result = [API::Internal::getAModuleImportRaw(package), API::moduleExport(package)]
142142
or
143143
// Access instance of a type based on type annotations
144144
result = API::Internal::getANodeOfTypeRaw(package, qualifiedName)

0 commit comments

Comments
 (0)