开发者

Calling shell command from ruby with proper argument escaping

开发者 https://www.devze.com 2023-03-04 16:25 出处:网络
I want to do the following securely system \"echo \'#{params[:message]}\' > /dev/log\" What is the proper way for escaping arguments when calling a native command?

I want to do the following securely

system "echo '#{params[:message]}' > /dev/log"

What is the proper way for escaping arguments when calling a native command?

(Ex开发者_运维技巧ample evil input: '; rm -Rf *; echo 'I won.)


If you do

system "echo", params[:message]

Then the second argument, will be sent as an argument, it will not be executed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号