mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Add SystemCommandExecution concept
A SystemCommandExecution is a method call or builtin that executes a system command, either directly or via a subshell.
This commit is contained in:
65
ql/test/library-tests/frameworks/CommandExecution.rb
Normal file
65
ql/test/library-tests/frameworks/CommandExecution.rb
Normal file
@@ -0,0 +1,65 @@
|
||||
`echo foo`
|
||||
%x(echo foo)
|
||||
%x{echo foo}
|
||||
%x[echo foo]
|
||||
%x/echo foo/
|
||||
|
||||
system("echo foo")
|
||||
system("echo", "foo")
|
||||
system(["echo", "echo"], "foo")
|
||||
|
||||
system({"FOO" => "BAR"}, "echo foo")
|
||||
system({"FOO" => "BAR"}, "echo", "foo")
|
||||
system({"FOO" => "BAR"}, ["echo", "echo"], "foo")
|
||||
|
||||
system("echo foo", unsetenv_others: true)
|
||||
system("echo", "foo", unsetenv_others: true)
|
||||
system(["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
system({"FOO" => "BAR"}, "echo foo", unsetenv_others: true)
|
||||
system({"FOO" => "BAR"}, "echo", "foo", unsetenv_others: true)
|
||||
system({"FOO" => "BAR"}, ["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
exec("echo foo")
|
||||
exec("echo", "foo")
|
||||
exec(["echo", "echo"], "foo")
|
||||
|
||||
exec({"FOO" => "BAR"}, "echo foo")
|
||||
exec({"FOO" => "BAR"}, "echo", "foo")
|
||||
exec({"FOO" => "BAR"}, ["echo", "echo"], "foo")
|
||||
|
||||
exec("echo foo", unsetenv_others: true)
|
||||
exec("echo", "foo", unsetenv_others: true)
|
||||
exec(["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
exec({"FOO" => "BAR"}, "echo foo", unsetenv_others: true)
|
||||
exec({"FOO" => "BAR"}, "echo", "foo", unsetenv_others: true)
|
||||
exec({"FOO" => "BAR"}, ["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
spawn("echo foo")
|
||||
spawn("echo", "foo")
|
||||
spawn(["echo", "echo"], "foo")
|
||||
|
||||
spawn({"FOO" => "BAR"}, "echo foo")
|
||||
spawn({"FOO" => "BAR"}, "echo", "foo")
|
||||
spawn({"FOO" => "BAR"}, ["echo", "echo"], "foo")
|
||||
|
||||
spawn("echo foo", unsetenv_others: true)
|
||||
spawn("echo", "foo", unsetenv_others: true)
|
||||
spawn(["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
spawn({"FOO" => "BAR"}, "echo foo", unsetenv_others: true)
|
||||
spawn({"FOO" => "BAR"}, "echo", "foo", unsetenv_others: true)
|
||||
spawn({"FOO" => "BAR"}, ["echo", "echo"], "foo", unsetenv_others: true)
|
||||
|
||||
Open3.popen3("echo foo")
|
||||
Open3.popen2("echo foo")
|
||||
Open3.popen2e("echo foo")
|
||||
Open3.capture3("echo foo")
|
||||
Open3.capture2("echo foo")
|
||||
Open3.capture2e("echo foo")
|
||||
Open3.pipeline_rw("echo foo")
|
||||
Open3.pipeline_r("echo foo")
|
||||
Open3.pipeline_w("echo foo")
|
||||
Open3.pipeline_start("echo foo")
|
||||
Open3.pipeline("echo foo")
|
||||
57
ql/test/library-tests/frameworks/StandardLibrary.expected
Normal file
57
ql/test/library-tests/frameworks/StandardLibrary.expected
Normal file
@@ -0,0 +1,57 @@
|
||||
subshellLiteralExecutions
|
||||
| CommandExecution.rb:1:1:1:10 | `echo foo` |
|
||||
| CommandExecution.rb:2:1:2:12 | `echo foo` |
|
||||
| CommandExecution.rb:3:1:3:12 | `echo foo` |
|
||||
| CommandExecution.rb:4:1:4:12 | `echo foo` |
|
||||
| CommandExecution.rb:5:1:5:12 | `echo foo` |
|
||||
kernelSystemCallExecutions
|
||||
| CommandExecution.rb:7:1:7:18 | call to system |
|
||||
| CommandExecution.rb:8:1:8:21 | call to system |
|
||||
| CommandExecution.rb:9:1:9:31 | call to system |
|
||||
| CommandExecution.rb:11:1:11:36 | call to system |
|
||||
| CommandExecution.rb:12:1:12:39 | call to system |
|
||||
| CommandExecution.rb:13:1:13:49 | call to system |
|
||||
| CommandExecution.rb:15:1:15:41 | call to system |
|
||||
| CommandExecution.rb:16:1:16:44 | call to system |
|
||||
| CommandExecution.rb:17:1:17:54 | call to system |
|
||||
| CommandExecution.rb:19:1:19:59 | call to system |
|
||||
| CommandExecution.rb:20:1:20:62 | call to system |
|
||||
| CommandExecution.rb:21:1:21:72 | call to system |
|
||||
kernelExecCallExecutions
|
||||
| CommandExecution.rb:23:1:23:16 | call to exec |
|
||||
| CommandExecution.rb:24:1:24:19 | call to exec |
|
||||
| CommandExecution.rb:25:1:25:29 | call to exec |
|
||||
| CommandExecution.rb:27:1:27:34 | call to exec |
|
||||
| CommandExecution.rb:28:1:28:37 | call to exec |
|
||||
| CommandExecution.rb:29:1:29:47 | call to exec |
|
||||
| CommandExecution.rb:31:1:31:39 | call to exec |
|
||||
| CommandExecution.rb:32:1:32:42 | call to exec |
|
||||
| CommandExecution.rb:33:1:33:52 | call to exec |
|
||||
| CommandExecution.rb:35:1:35:57 | call to exec |
|
||||
| CommandExecution.rb:36:1:36:60 | call to exec |
|
||||
| CommandExecution.rb:37:1:37:70 | call to exec |
|
||||
kernelSpawnCallExecutions
|
||||
| CommandExecution.rb:39:1:39:17 | call to spawn |
|
||||
| CommandExecution.rb:40:1:40:20 | call to spawn |
|
||||
| CommandExecution.rb:41:1:41:30 | call to spawn |
|
||||
| CommandExecution.rb:43:1:43:35 | call to spawn |
|
||||
| CommandExecution.rb:44:1:44:38 | call to spawn |
|
||||
| CommandExecution.rb:45:1:45:48 | call to spawn |
|
||||
| CommandExecution.rb:47:1:47:40 | call to spawn |
|
||||
| CommandExecution.rb:48:1:48:43 | call to spawn |
|
||||
| CommandExecution.rb:49:1:49:53 | call to spawn |
|
||||
| CommandExecution.rb:51:1:51:58 | call to spawn |
|
||||
| CommandExecution.rb:52:1:52:61 | call to spawn |
|
||||
| CommandExecution.rb:53:1:53:71 | call to spawn |
|
||||
open3CallExecutions
|
||||
| CommandExecution.rb:55:1:55:24 | call to popen3 |
|
||||
| CommandExecution.rb:56:1:56:24 | call to popen2 |
|
||||
| CommandExecution.rb:57:1:57:25 | call to popen2e |
|
||||
| CommandExecution.rb:58:1:58:26 | call to capture3 |
|
||||
| CommandExecution.rb:59:1:59:26 | call to capture2 |
|
||||
| CommandExecution.rb:60:1:60:27 | call to capture2e |
|
||||
| CommandExecution.rb:61:1:61:29 | call to pipeline_rw |
|
||||
| CommandExecution.rb:62:1:62:28 | call to pipeline_r |
|
||||
| CommandExecution.rb:63:1:63:28 | call to pipeline_w |
|
||||
| CommandExecution.rb:64:1:64:32 | call to pipeline_start |
|
||||
| CommandExecution.rb:65:1:65:26 | call to pipeline |
|
||||
11
ql/test/library-tests/frameworks/StandardLibrary.ql
Normal file
11
ql/test/library-tests/frameworks/StandardLibrary.ql
Normal file
@@ -0,0 +1,11 @@
|
||||
import codeql.ruby.frameworks.StandardLibrary
|
||||
|
||||
query predicate subshellLiteralExecutions(SubshellLiteralExecution e) { any() }
|
||||
|
||||
query predicate kernelSystemCallExecutions(KernelSystemCall c) { any() }
|
||||
|
||||
query predicate kernelExecCallExecutions(KernelExecCall c) { any() }
|
||||
|
||||
query predicate kernelSpawnCallExecutions(KernelSpawnCall c) { any() }
|
||||
|
||||
query predicate open3CallExecutions(Open3Call c) { any() }
|
||||
Reference in New Issue
Block a user