Skip to content

Commit 0c43ad4

Browse files
committed
Ruby: Add another captured variable data flow test
1 parent 566351a commit 0c43ad4

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

ruby/ql/test/library-tests/dataflow/global/Flow.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
testFailures
2+
| captured_variables.rb:212:14:212:14 | x | Unexpected result: hasValueFlow=17 |
23
edges
34
| blocks.rb:14:12:14:20 | call to source | blocks.rb:8:10:8:14 | yield ... | provenance | |
45
| captured_variables.rb:9:24:9:24 | x | captured_variables.rb:10:10:10:23 | -> { ... } [captured x] | provenance | |
@@ -114,6 +115,9 @@ edges
114115
| captured_variables.rb:187:18:187:19 | self [@x] | captured_variables.rb:187:18:187:19 | @x | provenance | |
115116
| captured_variables.rb:193:1:193:1 | [post] c [@x] | captured_variables.rb:194:1:194:1 | c [@x] | provenance | |
116117
| captured_variables.rb:194:1:194:1 | c [@x] | captured_variables.rb:185:5:189:7 | self in baz [@x] | provenance | |
118+
| captured_variables.rb:197:9:197:17 | call to taint | captured_variables.rb:199:10:199:10 | x | provenance | |
119+
| captured_variables.rb:206:13:206:21 | call to taint | captured_variables.rb:208:14:208:14 | x | provenance | |
120+
| captured_variables.rb:206:13:206:21 | call to taint | captured_variables.rb:212:14:212:14 | x | provenance | |
117121
| instance_variables.rb:10:19:10:19 | x | instance_variables.rb:11:18:11:18 | x | provenance | |
118122
| instance_variables.rb:11:18:11:18 | x | instance_variables.rb:11:9:11:14 | [post] self [@field] | provenance | |
119123
| instance_variables.rb:13:5:15:7 | self in get_field [@field] | instance_variables.rb:14:16:14:21 | self [@field] | provenance | |
@@ -368,6 +372,11 @@ nodes
368372
| captured_variables.rb:187:18:187:19 | self [@x] | semmle.label | self [@x] |
369373
| captured_variables.rb:193:1:193:1 | [post] c [@x] | semmle.label | [post] c [@x] |
370374
| captured_variables.rb:194:1:194:1 | c [@x] | semmle.label | c [@x] |
375+
| captured_variables.rb:197:9:197:17 | call to taint | semmle.label | call to taint |
376+
| captured_variables.rb:199:10:199:10 | x | semmle.label | x |
377+
| captured_variables.rb:206:13:206:21 | call to taint | semmle.label | call to taint |
378+
| captured_variables.rb:208:14:208:14 | x | semmle.label | x |
379+
| captured_variables.rb:212:14:212:14 | x | semmle.label | x |
371380
| instance_variables.rb:10:19:10:19 | x | semmle.label | x |
372381
| instance_variables.rb:11:9:11:14 | [post] self [@field] | semmle.label | [post] self [@field] |
373382
| instance_variables.rb:11:18:11:18 | x | semmle.label | x |
@@ -575,6 +584,9 @@ subpaths
575584
| captured_variables.rb:154:14:154:15 | @x | captured_variables.rb:147:10:147:18 | call to taint | captured_variables.rb:154:14:154:15 | @x | $@ | captured_variables.rb:147:10:147:18 | call to taint | call to taint |
576585
| captured_variables.rb:169:18:169:19 | @x | captured_variables.rb:160:14:160:22 | call to taint | captured_variables.rb:169:18:169:19 | @x | $@ | captured_variables.rb:160:14:160:22 | call to taint | call to taint |
577586
| captured_variables.rb:187:18:187:19 | @x | captured_variables.rb:178:14:178:22 | call to taint | captured_variables.rb:187:18:187:19 | @x | $@ | captured_variables.rb:178:14:178:22 | call to taint | call to taint |
587+
| captured_variables.rb:199:10:199:10 | x | captured_variables.rb:197:9:197:17 | call to taint | captured_variables.rb:199:10:199:10 | x | $@ | captured_variables.rb:197:9:197:17 | call to taint | call to taint |
588+
| captured_variables.rb:208:14:208:14 | x | captured_variables.rb:206:13:206:21 | call to taint | captured_variables.rb:208:14:208:14 | x | $@ | captured_variables.rb:206:13:206:21 | call to taint | call to taint |
589+
| captured_variables.rb:212:14:212:14 | x | captured_variables.rb:206:13:206:21 | call to taint | captured_variables.rb:212:14:212:14 | x | $@ | captured_variables.rb:206:13:206:21 | call to taint | call to taint |
578590
| instance_variables.rb:20:10:20:13 | @foo | instance_variables.rb:19:12:19:21 | call to taint | instance_variables.rb:20:10:20:13 | @foo | $@ | instance_variables.rb:19:12:19:21 | call to taint | call to taint |
579591
| instance_variables.rb:36:10:36:33 | call to get_field | instance_variables.rb:36:14:36:22 | call to taint | instance_variables.rb:36:10:36:33 | call to get_field | $@ | instance_variables.rb:36:14:36:22 | call to taint | call to taint |
580592
| instance_variables.rb:39:6:39:33 | call to get_field | instance_variables.rb:39:14:39:22 | call to taint | instance_variables.rb:39:6:39:33 | call to get_field | $@ | instance_variables.rb:39:14:39:22 | call to taint | call to taint |

ruby/ql/test/library-tests/dataflow/global/captured_variables.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,25 @@ def baz
192192
c = CaptureInstanceSelf2.new
193193
c.foo
194194
c.baz
195+
196+
class CaptureOverwrite
197+
x = taint(16)
198+
199+
sink(x) # $ hasValueFlow=16
200+
201+
x = nil
202+
203+
sink(x)
204+
205+
fn = -> {
206+
x = taint(17)
207+
208+
sink(x) # $ hasValueFlow=17
209+
210+
x = nil
211+
212+
sink(x)
213+
}
214+
215+
fn.call()
216+
end

0 commit comments

Comments
 (0)