Skip to content

Commit d77b316

Browse files
committed
add failing test for safe-ish uses of Object.send
1 parent cb33d5a commit d77b316

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

ruby/ql/test/query-tests/security/cwe-094/CodeInjection.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edges
1010
| CodeInjection.rb:38:24:38:27 | code : | CodeInjection.rb:38:10:38:28 | call to escape |
1111
| CodeInjection.rb:78:12:78:17 | call to params : | CodeInjection.rb:78:12:78:24 | ...[...] : |
1212
| CodeInjection.rb:78:12:78:24 | ...[...] : | CodeInjection.rb:80:16:80:19 | code |
13+
| CodeInjection.rb:78:12:78:24 | ...[...] : | CodeInjection.rb:82:16:82:43 | ... + ... |
1314
nodes
1415
| CodeInjection.rb:5:12:5:17 | call to params : | semmle.label | call to params : |
1516
| CodeInjection.rb:5:12:5:24 | ...[...] : | semmle.label | ...[...] : |
@@ -25,6 +26,7 @@ nodes
2526
| CodeInjection.rb:78:12:78:17 | call to params : | semmle.label | call to params : |
2627
| CodeInjection.rb:78:12:78:24 | ...[...] : | semmle.label | ...[...] : |
2728
| CodeInjection.rb:80:16:80:19 | code | semmle.label | code |
29+
| CodeInjection.rb:82:16:82:43 | ... + ... | semmle.label | ... + ... |
2830
subpaths
2931
#select
3032
| CodeInjection.rb:8:10:8:13 | code | CodeInjection.rb:5:12:5:17 | call to params : | CodeInjection.rb:8:10:8:13 | code | This code execution depends on a $@. | CodeInjection.rb:5:12:5:17 | call to params | user-provided value |
@@ -36,3 +38,4 @@ subpaths
3638
| CodeInjection.rb:38:10:38:28 | call to escape | CodeInjection.rb:5:12:5:17 | call to params : | CodeInjection.rb:38:10:38:28 | call to escape | This code execution depends on a $@. | CodeInjection.rb:5:12:5:17 | call to params | user-provided value |
3739
| CodeInjection.rb:41:40:41:43 | code | CodeInjection.rb:5:12:5:17 | call to params : | CodeInjection.rb:41:40:41:43 | code | This code execution depends on a $@. | CodeInjection.rb:5:12:5:17 | call to params | user-provided value |
3840
| CodeInjection.rb:80:16:80:19 | code | CodeInjection.rb:78:12:78:17 | call to params : | CodeInjection.rb:80:16:80:19 | code | This code execution depends on a $@. | CodeInjection.rb:78:12:78:17 | call to params | user-provided value |
41+
| CodeInjection.rb:82:16:82:43 | ... + ... | CodeInjection.rb:78:12:78:17 | call to params : | CodeInjection.rb:82:16:82:43 | ... + ... | This code execution depends on a $@. | CodeInjection.rb:78:12:78:17 | call to params | user-provided value |

ruby/ql/test/query-tests/security/cwe-094/CodeInjection.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,7 @@ def create
7878
code = params[:code]
7979

8080
obj().send(code, "foo"); # BAD
81+
82+
obj().send("prefix_" + code + "_suffix", "foo"); # GOOD - but still flagged by this query
8183
end
8284
end

0 commit comments

Comments
 (0)