Created
December 17, 2014 21:58
-
-
Save dzuelke/74f34d9860ed359658d4 to your computer and use it in GitHub Desktop.
Pipe 'heroku config' output through this script to redact credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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