Skip to content

Commit cb33d5a

Browse files
committed
add test for .send(..) in code-injection
1 parent fd8f8cb commit cb33d5a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ edges
88
| CodeInjection.rb:5:12:5:24 | ...[...] : | CodeInjection.rb:38:24:38:27 | code : |
99
| CodeInjection.rb:5:12:5:24 | ...[...] : | CodeInjection.rb:41:40:41:43 | code |
1010
| CodeInjection.rb:38:24:38:27 | code : | CodeInjection.rb:38:10:38:28 | call to escape |
11+
| CodeInjection.rb:78:12:78:17 | call to params : | CodeInjection.rb:78:12:78:24 | ...[...] : |
12+
| CodeInjection.rb:78:12:78:24 | ...[...] : | CodeInjection.rb:80:16:80:19 | code |
1113
nodes
1214
| CodeInjection.rb:5:12:5:17 | call to params : | semmle.label | call to params : |
1315
| CodeInjection.rb:5:12:5:24 | ...[...] : | semmle.label | ...[...] : |
@@ -20,6 +22,9 @@ nodes
2022
| CodeInjection.rb:38:10:38:28 | call to escape | semmle.label | call to escape |
2123
| CodeInjection.rb:38:24:38:27 | code : | semmle.label | code : |
2224
| CodeInjection.rb:41:40:41:43 | code | semmle.label | code |
25+
| CodeInjection.rb:78:12:78:17 | call to params : | semmle.label | call to params : |
26+
| CodeInjection.rb:78:12:78:24 | ...[...] : | semmle.label | ...[...] : |
27+
| CodeInjection.rb:80:16:80:19 | code | semmle.label | code |
2328
subpaths
2429
#select
2530
| 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 |
@@ -30,3 +35,4 @@ subpaths
3035
| CodeInjection.rb:32:19:32:22 | code | CodeInjection.rb:5:12:5:17 | call to params : | CodeInjection.rb:32:19:32:22 | code | This code execution depends on a $@. | CodeInjection.rb:5:12:5:17 | call to params | user-provided value |
3136
| 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 |
3237
| 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 |
38+
| 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 |

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,11 @@ def self.const_get(x)
7272
true
7373
end
7474
end
75+
76+
class UsersController < ActionController::Base
77+
def create
78+
code = params[:code]
79+
80+
obj().send(code, "foo"); # BAD
81+
end
82+
end

0 commit comments

Comments
 (0)