Skip to content

Commit 288fbfd

Browse files
committed
Ruby: Add test for missing block flow
1 parent 30891ca commit 288fbfd

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
testFailures
22
edges
3+
| blocks.rb:14:12:14:20 | call to source | blocks.rb:8:10:8:14 | yield ... |
34
| captured_variables.rb:9:24:9:24 | x | captured_variables.rb:10:10:10:23 | -> { ... } [captured x] |
45
| captured_variables.rb:9:24:9:24 | x | captured_variables.rb:11:5:11:6 | fn [captured x] |
56
| captured_variables.rb:10:5:10:6 | fn [captured x] | captured_variables.rb:11:5:11:6 | fn [captured x] |
@@ -253,6 +254,8 @@ edges
253254
| instance_variables.rb:121:1:121:3 | bar | instance_variables.rb:122:6:122:8 | bar |
254255
| instance_variables.rb:121:7:121:24 | call to new | instance_variables.rb:121:1:121:3 | bar |
255256
nodes
257+
| blocks.rb:8:10:8:14 | yield ... | semmle.label | yield ... |
258+
| blocks.rb:14:12:14:20 | call to source | semmle.label | call to source |
256259
| captured_variables.rb:9:24:9:24 | x | semmle.label | x |
257260
| captured_variables.rb:10:5:10:6 | fn [captured x] | semmle.label | fn [captured x] |
258261
| captured_variables.rb:10:10:10:23 | -> { ... } [captured x] | semmle.label | -> { ... } [captured x] |
@@ -548,6 +551,7 @@ subpaths
548551
| instance_variables.rb:120:6:120:10 | foo16 [@field] | captured_variables.rb:60:5:62:7 | self in get_field [@field] | captured_variables.rb:61:9:61:21 | return | instance_variables.rb:120:6:120:20 | call to get_field |
549552
| instance_variables.rb:120:6:120:10 | foo16 [@field] | instance_variables.rb:13:5:15:7 | self in get_field [@field] | instance_variables.rb:14:9:14:21 | return | instance_variables.rb:120:6:120:20 | call to get_field |
550553
#select
554+
| blocks.rb:8:10:8:14 | yield ... | blocks.rb:14:12:14:20 | call to source | blocks.rb:8:10:8:14 | yield ... | $@ | blocks.rb:14:12:14:20 | call to source | call to source |
551555
| captured_variables.rb:10:20:10:20 | x | captured_variables.rb:13:20:13:29 | call to taint | captured_variables.rb:10:20:10:20 | x | $@ | captured_variables.rb:13:20:13:29 | call to taint | call to taint |
552556
| captured_variables.rb:17:14:17:14 | x | captured_variables.rb:20:25:20:34 | call to taint | captured_variables.rb:17:14:17:14 | x | $@ | captured_variables.rb:20:25:20:34 | call to taint | call to taint |
553557
| captured_variables.rb:24:14:24:14 | x | captured_variables.rb:27:48:27:57 | call to taint | captured_variables.rb:24:14:24:14 | x | $@ | captured_variables.rb:27:48:27:57 | call to taint | call to taint |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class A
2+
def m1(&block)
3+
r = block.call() # $ MISSING: hasValueFlow=1
4+
sink r
5+
end
6+
7+
def m2
8+
sink yield # $ hasValueFlow=2
9+
end
10+
end
11+
12+
A.new.m1 { source(1) }
13+
14+
A.new.m2 { source(2) }

0 commit comments

Comments
 (0)