fix(escape): Escape double quotes and all other characters reliably
This commit is contained in:
@@ -58,7 +58,7 @@ class Mrsk::Configuration::Role
|
||||
def traefik_labels
|
||||
if running_traefik?
|
||||
{
|
||||
"traefik.http.routers.#{config.service}.rule" => 'PathPrefix(\`/\`)',
|
||||
"traefik.http.routers.#{config.service}.rule" => "PathPrefix(`/`)",
|
||||
"traefik.http.services.#{config.service}.loadbalancer.healthcheck.path" => config.healthcheck["path"],
|
||||
"traefik.http.services.#{config.service}.loadbalancer.healthcheck.interval" => "1s",
|
||||
"traefik.http.middlewares.#{config.service}.retry.attempts" => "3",
|
||||
|
||||
@@ -5,7 +5,7 @@ module Mrsk::Utils
|
||||
def argumentize(argument, attributes, redacted: false)
|
||||
Array(attributes).flat_map do |k, v|
|
||||
if v.present?
|
||||
[ argument, redacted ? redact("#{k}=\"#{v}\"") : "#{k}=\"#{v}\"" ]
|
||||
[ argument, redacted ? redact("#{k}=#{escape_bash_string v.to_s}") : "#{k}=#{escape_bash_string v.to_s}" ]
|
||||
else
|
||||
[ argument, k ]
|
||||
end
|
||||
@@ -26,4 +26,8 @@ module Mrsk::Utils
|
||||
def redact(arg) # Used in execute_command to hide redact() args a user passes in
|
||||
arg.to_s.extend(SSHKit::Redaction) # to_s due to our inability to extend Integer, etc
|
||||
end
|
||||
|
||||
def escape_bash_string(string)
|
||||
string.dump.gsub(/`/, '\\\\`')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user