Skip to content

Commit d33e8ad

Browse files
authored
Merge pull request #16174 from erik-krogh/no-arr-ruby-shell
RB: don't mention arrays in the qhelp for rb/shell-command-constructed-from-input
2 parents 1c0ef90 + 4ae25c2 commit d33e8ad

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ruby/ql/src/queries/security/cwe-078/UnsafeShellCommandConstruction.qhelp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@
2020
<recommendation>
2121

2222
<p>
23-
If possible, provide the dynamic arguments to the shell as an array
23+
If possible, avoid concatenating shell strings
2424
to APIs such as <code>system(..)</code> to avoid interpretation by the shell.
2525
</p>
2626

27+
<p>
28+
Instead, provide the arguments to the shell command as separate arguments to the
29+
API, such as <code>system("echo", arg1, arg2)</code>.
30+
</p>
31+
2732
<p>
2833
Alternatively, if the shell command must be constructed
2934
dynamically, then add code to ensure that special characters
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Utils
22
def download(path)
3-
# using an array to call `system` is safe
3+
# using an API that doesn't interpret the path as a shell command
44
system("wget", path) # OK
55
end
66
end

0 commit comments

Comments
 (0)