Skip to content

Commit ed165c6

Browse files
committed
Ruby: bugfix in self-resolution in type-tracking
1 parent a64286b commit ed165c6

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private MethodBase getAMethod(ModuleBase mod, boolean instance) {
120120
if result instanceof SingletonMethod then instance = false else instance = true
121121
or
122122
exists(SingletonClass cls |
123-
cls.getValue().(SelfVariableAccess).getCfgScope() = mod and
123+
cls.getValue().(SelfVariableAccess).getVariable().getDeclaringScope() = mod and
124124
result = cls.getAMethod().(Method) and
125125
instance = false
126126
)
@@ -133,7 +133,7 @@ private MethodBase getAMethod(ModuleBase mod, boolean instance) {
133133
pragma[nomagic]
134134
private Node fieldPredecessor(ModuleBase mod, boolean instance, string field) {
135135
exists(InstanceVariableWriteAccess access, AssignExpr assign |
136-
access.getReceiver().getCfgScope() = getAMethod(mod, instance) and
136+
access.getReceiver().getVariable().getDeclaringScope() = getAMethod(mod, instance) and
137137
field = access.getVariable().getName() and
138138
assign.getLeftOperand() = access and
139139
result.asExpr().getExpr() = assign.getRightOperand()
@@ -147,7 +147,7 @@ private Node fieldPredecessor(ModuleBase mod, boolean instance, string field) {
147147
pragma[nomagic]
148148
private Node fieldSuccessor(ModuleBase mod, boolean instance, string field) {
149149
exists(InstanceVariableReadAccess access |
150-
access.getReceiver().getCfgScope() = getAMethod(mod, instance) and
150+
access.getReceiver().getVariable().getDeclaringScope() = getAMethod(mod, instance) and
151151
result.asExpr().getExpr() = access and
152152
field = access.getVariable().getName()
153153
)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ getTarget
221221
| hello.rb:20:30:20:34 | call to world | hello.rb:5:5:7:7 | world |
222222
| instance_fields.rb:4:22:4:35 | call to new | calls.rb:117:5:117:16 | new |
223223
| instance_fields.rb:7:13:7:25 | call to target | instance_fields.rb:12:5:13:7 | target |
224-
| instance_fields.rb:7:13:7:25 | call to target | instance_fields.rb:27:5:28:7 | target |
225224
| instance_fields.rb:19:22:19:35 | call to new | calls.rb:117:5:117:16 | new |
226-
| instance_fields.rb:22:13:22:25 | call to target | instance_fields.rb:12:5:13:7 | target |
227225
| instance_fields.rb:22:13:22:25 | call to target | instance_fields.rb:27:5:28:7 | target |
228226
| modules.rb:12:5:12:26 | call to puts | calls.rb:102:5:102:30 | puts |
229227
| modules.rb:22:3:22:19 | call to puts | calls.rb:102:5:102:30 | puts |

0 commit comments

Comments
 (0)