Skip to content

Commit 61e9c6f

Browse files
committed
Ruby: Fix call graph for overridden private methods
1 parent e7649fc commit 61e9c6f

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,7 @@ private module Cached {
302302
result = lookupMethod(tp, method) and
303303
if result.(Method).isPrivate()
304304
then
305-
exists(SelfVariableAccess self |
306-
self = call.getReceiver().getExpr() and
307-
pragma[only_bind_out](self.getEnclosingModule().getModule().getSuperClass*()) =
308-
pragma[only_bind_out](result.getEnclosingModule().getModule())
309-
) and
305+
call.getReceiver().getExpr() instanceof SelfVariableAccess and
310306
// For now, we restrict the scope of top-level declarations to their file.
311307
// This may remove some plausible targets, but also removes a lot of
312308
// implausible targets

ruby/ql/test/library-tests/modules/callgraph.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ getTarget
191191
| private.rb:67:3:69:5 | call to private | calls.rb:109:5:109:20 | private |
192192
| private.rb:68:7:68:32 | call to puts | calls.rb:102:5:102:30 | puts |
193193
| private.rb:72:7:72:8 | call to m1 | private.rb:63:11:65:5 | m1 |
194+
| private.rb:72:7:72:8 | call to m1 | private.rb:77:11:81:5 | m1 |
194195
| private.rb:77:3:81:5 | call to private | calls.rb:109:5:109:20 | private |
195196
| private.rb:78:7:78:32 | call to puts | calls.rb:102:5:102:30 | puts |
196197
| private.rb:79:7:79:8 | call to m2 | private.rb:67:11:69:5 | m2 |

0 commit comments

Comments
 (0)