【发布时间】:2014-07-31 02:53:42
【问题描述】:
我正在一个项目上运行刹车器 gem。它抱怨一些正在运行的 exec 命令。
当前代码:
Process.fork {exec "pdftk #{uncrypted_pdf_file} output #{pdf_file} owner_pw #{password} allow printing"}
Brakeman 抱怨说存在命令注入的可能性。例如,我尝试了几种不同的调用 exec 组合:
Process.fork {exec "pdftk", uncrypted_pdf_file, " output #{pdf_file} ", "owner_pw #{password}", "allow printing"}
但正如您所料,每个参数只是依次传递给 pdftk,因此它会失败。
有没有办法一次性调用命令并防止命令注入。在我们的特定情况下,无论如何我们控制所有变量都足够安全,但最好知道正确的方法。
【问题讨论】:
标签: ruby security exec brakeman