Skip to content

Commit 7ed60b1

Browse files
committed
Ruby: improve test case
1 parent 29ea1b2 commit 7ed60b1

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ edges
1010
| instance_variables.rb:6:16:6:21 | @field : | instance_variables.rb:6:9:6:21 | return : |
1111
| instance_variables.rb:6:16:6:21 | self [@field] : | instance_variables.rb:6:16:6:21 | @field : |
1212
| instance_variables.rb:6:16:6:21 | self [@field] : | instance_variables.rb:6:16:6:21 | @field : |
13+
| instance_variables.rb:8:5:10:7 | self in inc_field [@field] : | instance_variables.rb:9:9:9:14 | [post] self [@field] : |
14+
| instance_variables.rb:9:9:9:14 | [post] self [@field] : | instance_variables.rb:9:9:9:14 | [post] self [@field] : |
1315
| instance_variables.rb:11:5:11:8 | [post] self [@foo] : | instance_variables.rb:12:10:12:13 | self [@foo] : |
1416
| instance_variables.rb:11:5:11:8 | [post] self [@foo] : | instance_variables.rb:12:10:12:13 | self [@foo] : |
1517
| instance_variables.rb:11:12:11:22 | call to source : | instance_variables.rb:11:5:11:8 | [post] self [@foo] : |
@@ -26,6 +28,11 @@ edges
2628
| instance_variables.rb:17:6:17:8 | foo [@field] : | instance_variables.rb:5:5:7:7 | self in get_field [@field] : |
2729
| instance_variables.rb:17:6:17:8 | foo [@field] : | instance_variables.rb:17:6:17:18 | call to get_field |
2830
| instance_variables.rb:17:6:17:8 | foo [@field] : | instance_variables.rb:17:6:17:18 | call to get_field |
31+
| instance_variables.rb:20:1:20:3 | [post] bar [@field] : | instance_variables.rb:21:6:21:8 | bar [@field] : |
32+
| instance_variables.rb:20:15:20:23 | call to source : | instance_variables.rb:2:19:2:19 | x : |
33+
| instance_variables.rb:20:15:20:23 | call to source : | instance_variables.rb:20:1:20:3 | [post] bar [@field] : |
34+
| instance_variables.rb:21:6:21:8 | bar [@field] : | instance_variables.rb:8:5:10:7 | self in inc_field [@field] : |
35+
| instance_variables.rb:21:6:21:8 | bar [@field] : | instance_variables.rb:21:6:21:18 | call to inc_field |
2936
nodes
3037
| instance_variables.rb:2:19:2:19 | x : | semmle.label | x : |
3138
| instance_variables.rb:2:19:2:19 | x : | semmle.label | x : |
@@ -41,6 +48,8 @@ nodes
4148
| instance_variables.rb:6:16:6:21 | @field : | semmle.label | @field : |
4249
| instance_variables.rb:6:16:6:21 | self [@field] : | semmle.label | self [@field] : |
4350
| instance_variables.rb:6:16:6:21 | self [@field] : | semmle.label | self [@field] : |
51+
| instance_variables.rb:8:5:10:7 | self in inc_field [@field] : | semmle.label | self in inc_field [@field] : |
52+
| instance_variables.rb:9:9:9:14 | [post] self [@field] : | semmle.label | [post] self [@field] : |
4453
| instance_variables.rb:11:5:11:8 | [post] self [@foo] : | semmle.label | [post] self [@foo] : |
4554
| instance_variables.rb:11:5:11:8 | [post] self [@foo] : | semmle.label | [post] self [@foo] : |
4655
| instance_variables.rb:11:12:11:22 | call to source : | semmle.label | call to source : |
@@ -57,11 +66,19 @@ nodes
5766
| instance_variables.rb:17:6:17:8 | foo [@field] : | semmle.label | foo [@field] : |
5867
| instance_variables.rb:17:6:17:18 | call to get_field | semmle.label | call to get_field |
5968
| instance_variables.rb:17:6:17:18 | call to get_field | semmle.label | call to get_field |
69+
| instance_variables.rb:20:1:20:3 | [post] bar [@field] : | semmle.label | [post] bar [@field] : |
70+
| instance_variables.rb:20:15:20:23 | call to source : | semmle.label | call to source : |
71+
| instance_variables.rb:21:6:21:8 | bar [@field] : | semmle.label | bar [@field] : |
72+
| instance_variables.rb:21:6:21:18 | call to inc_field | semmle.label | call to inc_field |
6073
subpaths
6174
| instance_variables.rb:16:15:16:24 | call to source : | instance_variables.rb:2:19:2:19 | x : | instance_variables.rb:3:9:3:14 | [post] self [@field] : | instance_variables.rb:16:1:16:3 | [post] foo [@field] : |
6275
| instance_variables.rb:16:15:16:24 | call to source : | instance_variables.rb:2:19:2:19 | x : | instance_variables.rb:3:9:3:14 | [post] self [@field] : | instance_variables.rb:16:1:16:3 | [post] foo [@field] : |
6376
| instance_variables.rb:17:6:17:8 | foo [@field] : | instance_variables.rb:5:5:7:7 | self in get_field [@field] : | instance_variables.rb:6:9:6:21 | return : | instance_variables.rb:17:6:17:18 | call to get_field |
6477
| instance_variables.rb:17:6:17:8 | foo [@field] : | instance_variables.rb:5:5:7:7 | self in get_field [@field] : | instance_variables.rb:6:9:6:21 | return : | instance_variables.rb:17:6:17:18 | call to get_field |
78+
| instance_variables.rb:20:15:20:23 | call to source : | instance_variables.rb:2:19:2:19 | x : | instance_variables.rb:3:9:3:14 | [post] self [@field] : | instance_variables.rb:20:1:20:3 | [post] bar [@field] : |
79+
| instance_variables.rb:21:6:21:8 | bar [@field] : | instance_variables.rb:8:5:10:7 | self in inc_field [@field] : | instance_variables.rb:8:5:10:7 | self in inc_field [@field] : | instance_variables.rb:21:6:21:18 | call to inc_field |
80+
| instance_variables.rb:21:6:21:8 | bar [@field] : | instance_variables.rb:8:5:10:7 | self in inc_field [@field] : | instance_variables.rb:9:9:9:14 | [post] self [@field] : | instance_variables.rb:21:6:21:18 | call to inc_field |
6581
#select
6682
| instance_variables.rb:12:10:12:13 | @foo | instance_variables.rb:11:12:11:22 | call to source : | instance_variables.rb:12:10:12:13 | @foo | $@ | instance_variables.rb:11:12:11:22 | call to source : | call to source : |
6783
| instance_variables.rb:17:6:17:18 | call to get_field | instance_variables.rb:16:15:16:24 | call to source : | instance_variables.rb:17:6:17:18 | call to get_field | $@ | instance_variables.rb:16:15:16:24 | call to source : | call to source : |
84+
| instance_variables.rb:21:6:21:18 | call to inc_field | instance_variables.rb:20:15:20:23 | call to source : | instance_variables.rb:21:6:21:18 | call to inc_field | $@ | instance_variables.rb:20:15:20:23 | call to source : | call to source : |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ import codeql.ruby.DataFlow
77
private import TestUtilities.InlineFlowTest
88
import DataFlow::PathGraph
99

10-
from DataFlow::PathNode source, DataFlow::PathNode sink, DefaultValueFlowConf conf
10+
from DataFlow::PathNode source, DataFlow::PathNode sink, DefaultTaintFlowConf conf
1111
where conf.hasFlowPath(source, sink)
1212
select sink, source, sink, "$@", source, source.toString()

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ def inc_field
1414
end
1515
foo = Foo.new
1616
foo.set_field(source(42))
17-
sink(foo.get_field) # $ hasValueFlow=42
17+
sink(foo.get_field) # $ hasValueFlow=42
18+
19+
bar = Foo.new
20+
bar.set_field(source(5))
21+
sink(bar.inc_field) # $ hasTaintFlow=5

0 commit comments

Comments
 (0)