diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index 00fd66d8f24..824ea6af3fd 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -880,6 +880,8 @@ module Trees { } private class LambdaTree extends BodyStmtTree, Lambda { + final override predicate propagatesAbnormal(AstNode child) { none() } + /** Gets the `i`th child in the body of this block. */ final override AstNode getBodyChild(int i, boolean rescuable) { result = this.getParameter(i) and rescuable = false @@ -1158,6 +1160,8 @@ module Trees { } private class SingletonMethodTree extends BodyStmtTree, SingletonMethod { + final override predicate propagatesAbnormal(AstNode child) { none() } + /** Gets the `i`th child in the body of this block. */ final override AstNode getBodyChild(int i, boolean rescuable) { result = this.getParameter(i) and rescuable = false diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index c4cb7e4a166..0f839d6d344 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -4253,7 +4253,7 @@ raise.rb: #-----| -> element # 154| m14 -#-----| -> exit raise.rb (normal) +#-----| -> m15 # 154| exit m14 @@ -4304,3 +4304,96 @@ raise.rb: # 155| element #-----| -> call to nil? + +# 158| enter m15 +#-----| -> self + +# 158| m15 +#-----| -> self + +# 158| exit m15 + +# 158| exit m15 (normal) +#-----| -> exit m15 + +# 159| call to foo +#-----| -> exit m15 (normal) + +# 159| self +#-----| -> do ... end + +# 159| enter do ... end +#-----| -> self + +# 159| do ... end +#-----| -> call to foo + +# 159| exit do ... end + +# 159| exit do ... end (normal) +#-----| -> exit do ... end + +# 160| call to bar +#-----| -> exit do ... end (normal) + +# 160| self +#-----| -> -> { ... } + +# 160| enter -> { ... } +#-----| -> x + +# 160| -> { ... } +#-----| -> call to bar + +# 160| exit -> { ... } + +# 160| exit -> { ... } (abnormal) +#-----| -> exit -> { ... } + +# 160| exit -> { ... } (normal) +#-----| -> exit -> { ... } + +# 160| x +#-----| -> x + +# 161| call to raise +#-----| raise -> exit -> { ... } (abnormal) + +# 161| ... unless ... +#-----| -> exit -> { ... } (normal) + +# 161| self +#-----| -> "" + +# 161| "" +#-----| -> call to raise + +# 161| x +#-----| true -> ... unless ... +#-----| false -> self + +# 166| C +#-----| -> exit raise.rb (normal) + +# 167| enter m +#-----| -> self + +# 167| m +#-----| -> C + +# 167| exit m + +# 167| exit m (abnormal) +#-----| -> exit m + +# 167| self +#-----| -> m + +# 168| call to raise +#-----| raise -> exit m (abnormal) + +# 168| self +#-----| -> "" + +# 168| "" +#-----| -> call to raise diff --git a/ql/test/library-tests/controlflow/graph/raise.rb b/ql/test/library-tests/controlflow/graph/raise.rb index f4e24402649..e5f0c0e50f5 100644 --- a/ql/test/library-tests/controlflow/graph/raise.rb +++ b/ql/test/library-tests/controlflow/graph/raise.rb @@ -154,3 +154,17 @@ end def m14 element element.each { |elem| raise "" if element.nil? } end + +def m15 + foo do + bar ->(x) do + raise "" unless x + end + end +end + +class C + def self.m() + raise "" + end +end