diff --git a/ql/src/codeql_ruby/ast/Module.qll b/ql/src/codeql_ruby/ast/Module.qll index 96ee60d200a..bb267c8118a 100644 --- a/ql/src/codeql_ruby/ast/Module.qll +++ b/ql/src/codeql_ruby/ast/Module.qll @@ -213,7 +213,7 @@ class Module extends ModuleBase, ConstantWriteAccess, @module { * global scope, as in this example: * * ```rb - * class ::Foo + * module ::Foo * end * ``` */ diff --git a/ql/src/codeql_ruby/ast/internal/Call.qll b/ql/src/codeql_ruby/ast/internal/Call.qll index 48f64a6cfc6..5d72f9c62b6 100644 --- a/ql/src/codeql_ruby/ast/internal/Call.qll +++ b/ql/src/codeql_ruby/ast/internal/Call.qll @@ -53,9 +53,10 @@ module Call { final override Generated::Call generated; final override Expr getReceiver() { - if exists(generated.getReceiver()) - then result = generated.getReceiver() - else result = generated.getMethod().(Generated::ScopeResolution).getScope() + result = generated.getReceiver() + or + not exists(generated.getReceiver()) and + result = generated.getMethod().(Generated::ScopeResolution).getScope() } final override string getMethodName() { diff --git a/ql/src/codeql_ruby/controlflow/CfgNodes.qll b/ql/src/codeql_ruby/controlflow/CfgNodes.qll index 42466e3df20..58b0bf717df 100644 --- a/ql/src/codeql_ruby/controlflow/CfgNodes.qll +++ b/ql/src/codeql_ruby/controlflow/CfgNodes.qll @@ -85,6 +85,16 @@ class AstCfgNode extends CfgNode, TAstNode { or n = any(Generated::For f).getValue() and s = "In" + or + // TODO: Remove these nodes from the CFG + n = any(Generated::Class c).getName() and + s = n.toString() + or + n = any(Generated::Module m).getName() and + s = n.toString() + or + n = any(Generated::ScopeResolution sc).getName() and + s = n.toString() | result = "[" + this.getSplitsString() + "] " + s or diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index ee31803fec4..c9b537dd267 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -894,9 +894,9 @@ cfg.rb: #-----| -> character # 58| Silly -#-----| -> (no string representation) +#-----| -> Silly -# 58| (no string representation) +# 58| Silly #-----| -> Object # 58| Superclass @@ -1375,9 +1375,9 @@ cfg.rb: #-----| -> ... > ... # 115| C -#-----| -> (no string representation) +#-----| -> C -# 115| (no string representation) +# 115| C #-----| -> 42 # 116| ... = ... @@ -1426,9 +1426,9 @@ cfg.rb: #-----| -> Array # 122| M -#-----| -> (no string representation) +#-----| -> M -# 122| (no string representation) +# 122| M #-----| -> nil # 123| ... = ... @@ -1592,16 +1592,16 @@ cfg.rb: #-----| -> M # 137| M -#-----| -> (no string representation) +#-----| -> Constant -# 137| (no string representation) +# 137| Constant #-----| -> Constant # 138| Constant #-----| -> class << ... # 138| call to itself -#-----| -> (no string representation) +#-----| -> Constant # 138| M #-----| -> itself @@ -1609,7 +1609,7 @@ cfg.rb: # 138| itself #-----| -> call to itself -# 138| (no string representation) +# 138| Constant #-----| -> Constant # 140| class << ... @@ -2721,9 +2721,9 @@ loops.rb: raise.rb: # 1| ExceptionA -#-----| -> (no string representation) +#-----| -> ExceptionA -# 1| (no string representation) +# 1| ExceptionA #-----| -> Exception # 1| Superclass @@ -2733,9 +2733,9 @@ raise.rb: #-----| -> Superclass # 4| ExceptionB -#-----| -> (no string representation) +#-----| -> ExceptionB -# 4| (no string representation) +# 4| ExceptionB #-----| -> Exception # 4| Superclass