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
This commit is contained in:
Erik Krogh Kristensen
2024-04-10 17:08:24 +02:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -20,10 +20,15 @@
<recommendation>
<p>
If possible, provide the dynamic arguments to the shell as an array
If possible, avoid concatenating shell strings
to APIs such as <code>system(..)</code> to avoid interpretation by the shell.
</p>
<p>
Instead, provide the arguments to the shell command as separate arguments to the
API, such as <code>system("echo", arg1, arg2)</code>.
</p>
<p>
Alternatively, if the shell command must be constructed
dynamically, then add code to ensure that special characters

View File

@@ -1,6 +1,6 @@
module Utils
def download(path)
# using an array to call `system` is safe
# using an API that doesn't interpret the path as a shell command
system("wget", path) # OK
end
end