diff --git a/python/ql/src/semmle/python/Module.qll b/python/ql/src/semmle/python/Module.qll index 275071b2925..da655f033d1 100644 --- a/python/ql/src/semmle/python/Module.qll +++ b/python/ql/src/semmle/python/Module.qll @@ -9,9 +9,13 @@ class Module extends Module_, Scope, AstNode { override string toString() { result = this.getKind() + " " + this.getName() or - /* No name is defined, which means that this is not on an import path. So it must be a script */ + /* No name is defined, which means that this module is not on an import path. So it must be a script */ not exists(this.getName()) and not this.isPackage() and result = "Script " + this.getFile().getShortName() + or + /* Package missing name, so just use the path instead */ + not exists(this.getName()) and this.isPackage() and + result = "Package at " + this.getPath().getAbsolutePath() } /** This method will be deprecated in the next release. Please use `getEnclosingScope()` instead. diff --git a/python/ql/src/semmle/python/types/ModuleObject.qll b/python/ql/src/semmle/python/types/ModuleObject.qll index 64493e08552..9b671747361 100644 --- a/python/ql/src/semmle/python/types/ModuleObject.qll +++ b/python/ql/src/semmle/python/types/ModuleObject.qll @@ -32,6 +32,9 @@ abstract class ModuleObject extends Object { override string toString() { result = "Module " + this.getName() + or + not exists(this.getName()) and + result = this.getModule().toString() } /** Gets the named attribute of this module. Using attributeRefersTo() instead