Skip to content

Commit 348ad95

Browse files
committed
Ruby: fix defining every dataflow node as a command execution sink
1 parent 3bacb18 commit 348ad95

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

ruby/ql/lib/codeql/ruby/frameworks/Railties.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module Railties {
4343

4444
override DataFlow::Node getAnArgument() { result = this.getArgument([0, 1]) }
4545

46-
override predicate isShellInterpreted(DataFlow::Node arg) { any() }
46+
override predicate isShellInterpreted(DataFlow::Node arg) { arg = this.getAnArgument() }
4747
}
4848

4949
/**
@@ -57,6 +57,6 @@ module Railties {
5757

5858
override DataFlow::Node getAnArgument() { result = this.getArgument(0) }
5959

60-
override predicate isShellInterpreted(DataFlow::Node arg) { any() }
60+
override predicate isShellInterpreted(DataFlow::Node arg) { arg = this.getAnArgument() }
6161
}
6262
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
systemCommandExecutions
12
| Railties.rb:5:5:5:34 | call to execute_command |
23
| Railties.rb:6:5:6:37 | call to execute_command |
34
| Railties.rb:8:5:8:16 | call to rake |
45
| Railties.rb:10:5:10:27 | call to rails_command |
56
| Railties.rb:12:5:12:17 | call to git |
7+
shellInterpretedArguments
8+
| Railties.rb:5:5:5:34 | call to execute_command | Railties.rb:5:21:5:25 | :rake |
9+
| Railties.rb:5:5:5:34 | call to execute_command | Railties.rb:5:28:5:33 | "test" |
10+
| Railties.rb:6:5:6:37 | call to execute_command | Railties.rb:6:21:6:26 | :rails |
11+
| Railties.rb:6:5:6:37 | call to execute_command | Railties.rb:6:29:6:36 | "server" |
12+
| Railties.rb:8:5:8:16 | call to rake | Railties.rb:8:10:8:15 | "test" |
13+
| Railties.rb:10:5:10:27 | call to rails_command | Railties.rb:10:19:10:26 | "server" |
14+
| Railties.rb:12:5:12:17 | call to git | Railties.rb:12:9:12:16 | "status" |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
private import ruby
22
private import codeql.ruby.Concepts
33
private import codeql.ruby.frameworks.Railties
4+
private import codeql.ruby.DataFlow
45

56
query predicate systemCommandExecutions(SystemCommandExecution e) { any() }
7+
8+
query predicate shellInterpretedArguments(SystemCommandExecution e, DataFlow::Node arg) {
9+
e.isShellInterpreted(arg)
10+
}

0 commit comments

Comments
 (0)