Skip to content
代码片段 群组 项目
未验证 提交 1545eb75 编辑于 作者: Kassio Borges's avatar Kassio Borges 提交者: GitLab
浏览文件

Merge branch 'ameyadarshan-master-patch-18206' into 'master'

Ensure Gitlab::Popen raises error for incorrect arguments

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/146844



Merged-by: default avatarKassio Borges <kborges@gitlab.com>
Approved-by: default avatarKassio Borges <kborges@gitlab.com>
Reviewed-by: default avatarAditya Tiwari <atiwari@gitlab.com>
Co-authored-by: default avatarAditya Tiwari <atiwari@gitlab.com>
Co-authored-by: default avatarAmeya Darshan <adarshan@gitlab.com>
No related branches found
No related tags found
无相关合并请求
......@@ -31,6 +31,10 @@ def popen_with_detail(cmd, path = nil, vars = {})
raise "System commands must be given as an array of strings"
end
if cmd.one? && cmd.first.match?(/\s/)
raise "System commands must be split into an array of space-separated values"
end
path ||= Dir.pwd
vars['PWD'] = path
options = { chdir: path }
......
......@@ -57,6 +57,12 @@
end
end
context 'unsafe array command' do
it 'raises an error when it gets called with an unsafe array' do
expect { @klass.new.popen(['ls -l'], path) }.to raise_error(RuntimeError)
end
end
context 'with custom options' do
let(:vars) { { 'foobar' => 123, 'PWD' => path } }
let(:options) { { chdir: path } }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册