From fe8945b5c9dfe4fbc76e7dc663e9063d2260719c Mon Sep 17 00:00:00 2001 From: Asger F Date: Thu, 3 Nov 2022 10:10:47 +0100 Subject: [PATCH] Ruby: Rename getCanonicalEnclosing/Nested module getCanonicalEnclosingModule -> getParentModule getCanonicalNestedModule -> getNestedModule --- ruby/ql/lib/codeql/ruby/ast/Module.qll | 10 +++++----- .../codeql/ruby/dataflow/internal/DataFlowPublic.qll | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ruby/ql/lib/codeql/ruby/ast/Module.qll b/ruby/ql/lib/codeql/ruby/ast/Module.qll index 7d5c2fae540..d71b3add04e 100644 --- a/ruby/ql/lib/codeql/ruby/ast/Module.qll +++ b/ruby/ql/lib/codeql/ruby/ast/Module.qll @@ -151,24 +151,24 @@ class Module extends TModule { /** * Gets the enclosing module, as it appears in the qualified name of this module. * - * For example, the canonical enclosing module of `A::B` is `A`, and `A` itself has no canonical enclosing module. + * For example, the parent module of `A::B` is `A`, and `A` itself has no parent module. */ pragma[nomagic] - Module getCanonicalEnclosingModule() { result.getQualifiedName() = this.getEnclosingModuleName() } + Module getParentModule() { result.getQualifiedName() = this.getEnclosingModuleName() } /** * Gets a module named `name` declared inside this one (not aliased), provided * that such a module is defined or reopened in the current codebase. * - * For example, for `A::B` the canonical nested module named `C` would be `A::B::C`. + * For example, for `A::B` the nested module named `C` would be `A::B::C`. * * Note that this is not the same as constant lookup. If `A::B::C` would resolve to a * module whose qualified name is not `A::B::C`, then it will not be found by * this predicate. */ pragma[nomagic] - Module getCanonicalNestedModule(string name) { - result.getCanonicalEnclosingModule() = this and + Module getNestedModule(string name) { + result.getParentModule() = this and result.getOwnModuleName() = name } } diff --git a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll index 3faff651988..192bbdac14f 100644 --- a/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll +++ b/ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll @@ -927,7 +927,7 @@ class ModuleNode instanceof Module { * * For example, the canonical enclosing module of `A::B` is `A`, and `A` itself has no canonical enclosing module. */ - ModuleNode getCanonicalEnclosingModule() { result = super.getCanonicalEnclosingModule() } + ModuleNode getCanonicalEnclosingModule() { result = super.getParentModule() } /** * Gets a module named `name` declared inside this one (not aliased), provided @@ -939,7 +939,7 @@ class ModuleNode instanceof Module { * module whose qualified name is not `A::B::C`, then it will not be found by * this predicate. */ - ModuleNode getCanonicalNestedModule(string name) { result = super.getCanonicalNestedModule(name) } + ModuleNode getCanonicalNestedModule(string name) { result = super.getNestedModule(name) } } /** @@ -1152,7 +1152,7 @@ class ConstRef extends LocalSourceNode { */ predicate isPossiblyGlobal() { exists(Module mod | - not exists(mod.getCanonicalEnclosingModule()) and + not exists(mod.getParentModule()) and mod.getAnImmediateReference() = access ) or @@ -1237,7 +1237,7 @@ class ConstRef extends LocalSourceNode { name = this.getName() or exists(Module mod | - this.getExactTarget() = mod.getCanonicalNestedModule(name) and + this.getExactTarget() = mod.getNestedModule(name) and scope = MkExactLookup(mod) ) }