Skip to content

Instantly share code, notes, and snippets.

@dzuelke
Created December 17, 2014 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dzuelke/74f34d9860ed359658d4 to your computer and use it in GitHub Desktop.
Save dzuelke/74f34d9860ed359658d4 to your computer and use it in GitHub Desktop.
Pipe 'heroku config' output through this script to redact credentials
#!/usr/bin/env ruby
require 'uri'
ARGF.each_line do |line|
key, value = line.split(':', 2)
if !value
$stdout.puts key
next
else
spaces = value.length - value.strip!.length
end
begin
uri = URI.parse value
uri.password = "REDACTED" if uri.password
value = uri.to_s
rescue
# Not a URL - skipping
end
if key.downcase.scan(/_(key|secret|token|password|pass)$/).size > 0
value = "REDACTED"
end
$stdout.puts key+": "+(" "*spaces)+value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment