Skip to content

Commit 71f195d

Browse files
committed
Ruby: add test for Receiver in summary
1 parent f140c13 commit 71f195d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

ruby/ql/test/library-tests/dataflow/summaries/Summaries.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ edges
2727
| summaries.rb:31:27:31:33 | tainted : | summaries.rb:31:6:31:34 | call to onlyWithoutBlock |
2828
| summaries.rb:40:7:40:13 | "taint" : | summaries.rb:41:24:41:24 | t : |
2929
| summaries.rb:40:7:40:13 | "taint" : | summaries.rb:42:24:42:24 | t : |
30+
| summaries.rb:40:7:40:13 | "taint" : | summaries.rb:44:8:44:8 | t : |
3031
| summaries.rb:41:24:41:24 | t : | summaries.rb:41:8:41:25 | call to matchedByName |
3132
| summaries.rb:42:24:42:24 | t : | summaries.rb:42:8:42:25 | call to matchedByName |
33+
| summaries.rb:44:8:44:8 | t : | summaries.rb:44:8:44:27 | call to matchedByNameRcv |
3234
nodes
3335
| summaries.rb:1:11:1:26 | call to identity : | semmle.label | call to identity : |
3436
| summaries.rb:1:20:1:26 | "taint" : | semmle.label | "taint" : |
@@ -62,6 +64,8 @@ nodes
6264
| summaries.rb:41:24:41:24 | t : | semmle.label | t : |
6365
| summaries.rb:42:8:42:25 | call to matchedByName | semmle.label | call to matchedByName |
6466
| summaries.rb:42:24:42:24 | t : | semmle.label | t : |
67+
| summaries.rb:44:8:44:8 | t : | semmle.label | t : |
68+
| summaries.rb:44:8:44:27 | call to matchedByNameRcv | semmle.label | call to matchedByNameRcv |
6569
subpaths
6670
invalidSpecComponent
6771
invalidOutputSpecComponent
@@ -81,6 +85,7 @@ invalidOutputSpecComponent
8185
| summaries.rb:37:36:37:42 | tainted | summaries.rb:1:20:1:26 | "taint" : | summaries.rb:37:36:37:42 | tainted | $@ | summaries.rb:1:20:1:26 | "taint" : | "taint" : |
8286
| summaries.rb:41:8:41:25 | call to matchedByName | summaries.rb:40:7:40:13 | "taint" : | summaries.rb:41:8:41:25 | call to matchedByName | $@ | summaries.rb:40:7:40:13 | "taint" : | "taint" : |
8387
| summaries.rb:42:8:42:25 | call to matchedByName | summaries.rb:40:7:40:13 | "taint" : | summaries.rb:42:8:42:25 | call to matchedByName | $@ | summaries.rb:40:7:40:13 | "taint" : | "taint" : |
88+
| summaries.rb:44:8:44:27 | call to matchedByNameRcv | summaries.rb:40:7:40:13 | "taint" : | summaries.rb:44:8:44:27 | call to matchedByNameRcv | $@ | summaries.rb:40:7:40:13 | "taint" : | "taint" : |
8489
warning
8590
| CSV type row should have 5 columns but has 2: test;TooFewColumns |
8691
| CSV type row should have 5 columns but has 8: test;TooManyColumns;;;Member[Foo].Instance;too;many;columns |

ruby/ql/test/library-tests/dataflow/summaries/Summaries.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ private class StepsFromModel extends ModelInput::SummaryModelCsv {
7575
";;Member[Foo].Method[secondArg];Argument[1];ReturnValue;taint",
7676
";;Member[Foo].Method[onlyWithoutBlock].WithoutBlock;Argument[0];ReturnValue;taint",
7777
";;Member[Foo].Method[onlyWithBlock].WithBlock;Argument[0];ReturnValue;taint",
78-
";any;Method[matchedByName];Argument[0];ReturnValue;taint"
78+
";any;Method[matchedByName];Argument[0];ReturnValue;taint",
79+
";any;Method[matchedByNameRcv];Receiver;ReturnValue;taint"
7980
]
8081
}
8182
}

ruby/ql/test/library-tests/dataflow/summaries/summaries.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ def userDefinedFunction(x, y)
4141
sink(x.matchedByName(t))
4242
sink(y.matchedByName(t))
4343
sink(x.unmatchedName(t))
44+
sink(t.matchedByNameRcv())
4445
end

0 commit comments

Comments
 (0)