Ruby: Expose relevant predicates from internal/Module.qll and make sure they are cached

This commit is contained in:
Tom Hvitved
2022-09-30 14:28:58 +02:00
parent 6e1914ad01
commit 299339f817
13 changed files with 36 additions and 22 deletions

View File

@@ -11,7 +11,6 @@
*/
import codeql.ruby.AST
import codeql.ruby.ast.internal.Module
import codeql.ruby.dataflow.SSA
from DefLoc loc, Expr src, Expr target, string kind
@@ -36,7 +35,7 @@ select src, target, kind
newtype DefLoc =
/** A constant, module or class. */
ConstantDefLoc(ConstantReadAccess read, ConstantWriteAccess write) {
write = definitionOf(resolveConstant(read))
write = definitionOf(read.getAQualifiedName())
} or
/** A method call. */
MethodLoc(MethodCall call, Method meth) { meth = call.getATarget() } or
@@ -75,7 +74,7 @@ newtype DefLoc =
*/
pragma[noinline]
ConstantWriteAccess definitionOf(string fqn) {
fqn = resolveConstant(_) and
fqn = any(ConstantReadAccess read).getAQualifiedName() and
result =
min(ConstantWriteAccess w, Location l |
w.getAQualifiedName() = fqn and l = w.getLocation()