Skip to content

Commit

Permalink
Filter private keys in logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz authored and jlsherrill committed Apr 30, 2020
1 parent d4377ea commit 3f1d54d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/runcible/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,24 @@ def add_oauth_header(method, path, headers)
return headers
end

def log_message
filter_sensitive_data(self.logs.join("\n"))
end

def filter_sensitive_data(payload)
payload.gsub(/-----BEGIN RSA PRIVATE KEY-----[\s\S]*-----END RSA PRIVATE KEY-----/, '[private key filtered]')
end

def log_debug
self.config[:logging][:logger].debug(self.logs.join("\n")) if self.config[:logging][:debug]
logger.debug(log_message) if self.config[:logging][:debug]
end

def log_exception
self.config[:logging][:logger].error(self.logs.join("\n")) if self.config[:logging][:exception]
logger.error(log_message) if self.config[:logging][:exception]
end

def log_info
self.config[:logging][:logger].info(self.logs.join("\n")) if self.config[:logging][:info]
logger.info(log_message) if self.config[:logging][:info]
end

def logger
Expand Down

0 comments on commit 3f1d54d

Please sign in to comment.