diff --git a/ql/src/codeql_ql/ast/Ast.qll b/ql/src/codeql_ql/ast/Ast.qll index 758c8c7418e..2f0724abb0f 100644 --- a/ql/src/codeql_ql/ast/Ast.qll +++ b/ql/src/codeql_ql/ast/Ast.qll @@ -2143,7 +2143,7 @@ module YAML { exists(YAMLEntry entry | entry.isRoot() and entry.getKey().getQualifiedName() = name and - result = entry.getValue().getValue() and + result = entry.getValue().getValue().trim() and entry.getLocation().getFile() = file ) } @@ -2190,6 +2190,13 @@ module YAML { ) } + /** + * Gets a QLPack that this QLPack depends on. + */ + QLPack getADependency() { + exists(string name | hasDependency(name, _) | result.getName().replaceAll("-", "/") = name) + } + Location getLocation() { // hacky, just pick the first node in the file. result = diff --git a/ql/src/codeql_ql/ast/internal/Module.qll b/ql/src/codeql_ql/ast/internal/Module.qll index 1443876c30d..a64ccfd0f2d 100644 --- a/ql/src/codeql_ql/ast/internal/Module.qll +++ b/ql/src/codeql_ql/ast/internal/Module.qll @@ -100,8 +100,10 @@ private predicate resolveQualifiedName(Import imp, ContainerOrModule m, int i) { exists(Container c, Container parent | // should ideally look at `qlpack.yml` files parent = imp.getLocation().getFile().getParentContainer+() and - exists(parent.getFile("qlpack.yml")) and - c.getParentContainer() = parent and + exists(YAML::QLPack pack | + pack.getFile().getParentContainer() = parent and + c.getParentContainer() = pack.getADependency*().getFile().getParentContainer() + ) and q = m.getName() | m = TFile(c)