From b2431d0b5003cb87b04e11f9e4025d90fccf3501 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Mon, 5 Sep 2022 16:52:52 +0200 Subject: [PATCH] Ruby: exclude 'require' and 'require_relative' definitions from call graph The syntax_suggest library redefines Kernel.require/require_relative. Somehow this causes performance issues on ruby/ruby. As a workaround we exclude 'require' and 'require_relative'. --- ruby/ql/lib/codeql/ruby/ast/internal/Module.qll | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ruby/ql/lib/codeql/ruby/ast/internal/Module.qll b/ruby/ql/lib/codeql/ruby/ast/internal/Module.qll index b26dfc88bef..eabc51a2125 100644 --- a/ruby/ql/lib/codeql/ruby/ast/internal/Module.qll +++ b/ruby/ql/lib/codeql/ruby/ast/internal/Module.qll @@ -137,7 +137,14 @@ private module Cached { } cached - Method lookupMethod(Module m, string name) { TMethod(result) = lookupMethodOrConst(m, name) } + Method lookupMethod(Module m, string name) { + // The syntax_suggest library redefines Kernel.require/require_relative. + // Somehow this causes performance issues on ruby/ruby. As a workaround + // we exclude 'require' and 'require_relative'. + // TODO: find the actual cause of the slowdown and fix things properly. + not name = ["require", "require_relative"] and + TMethod(result) = lookupMethodOrConst(m, name) + } cached Expr lookupConst(Module m, string name) {