Skip to content

Commit 18d89f1

Browse files
sheenaajayDavidS
authored andcommitted
fix shell command escaping in sql task and spec_helper
1 parent 841187b commit 18d89f1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

spec/spec_helper_local.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# this could definitely be optimized
3434
add_filter do |f|
3535
# system returns true if exit status is 0, which with git-check-ignore means file is ignored
36-
system("git check-ignore --quiet #{f.filename}")
36+
system('git', 'check-ignore', '--quiet', f.filename)
3737
end
3838
end
3939
end

tasks/sql.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
def get(sql, database, user, port, password, host)
99
env_hash = {}
1010
env_hash['PGPASSWORD'] = password unless password.nil?
11-
cmd_string = "psql -c \"#{sql}\""
12-
cmd_string += " --dbname=#{database}" unless database.nil?
13-
cmd_string += " --username=#{user}" unless user.nil?
14-
cmd_string += " --port=#{port}" unless port.nil?
15-
cmd_string += " --host=#{host}" unless host.nil?
16-
stdout, stderr, status = Open3.capture3(env_hash, cmd_string)
11+
cmd_string = ['psql', '-c', sql]
12+
cmd_string << "--dbname=#{database}" unless database.nil?
13+
cmd_string << "--username=#{user}" unless user.nil?
14+
cmd_string << "--port=#{port}" unless port.nil?
15+
cmd_string << "--host=#{host}" unless host.nil?
16+
stdout, stderr, status = Open3.capture3(env_hash, *cmd_string)
1717
raise Puppet::Error, stderr if status != 0
1818
{ status: stdout.strip }
1919
end

0 commit comments

Comments
 (0)