lib/logstop.rb in logstop-0.2.7 vs lib/logstop.rb in logstop-0.2.8

- old
+ new

@@ -12,20 +12,21 @@ IP_REGEX = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/ PHONE_REGEX = /\b(?:\+\d{1,2}\s)?\(?\d{3}\)?[\s+.-]\d{3}[\s+.-]\d{4}\b/ SSN_REGEX = /\b\d{3}[\s+-]\d{2}[\s+-]\d{4}\b/ URL_PASSWORD_REGEX = /((?:\/\/|%2F%2F)\S+(?::|%3A))\S+(@|%40)/ - def self.scrub(msg, ip: false, scrubber: nil) + def self.scrub(msg, url_password: true, email: true, credit_card: true, phone: true, ssn: true, ip: false, scrubber: nil) msg = msg.to_s.dup # order filters are applied is important - msg.gsub!(URL_PASSWORD_REGEX, FILTERED_URL_STR) - msg.gsub!(EMAIL_REGEX, FILTERED_STR) - msg.gsub!(CREDIT_CARD_REGEX, FILTERED_STR) - msg.gsub!(CREDIT_CARD_REGEX_DELIMITERS, FILTERED_STR) - msg.gsub!(PHONE_REGEX, FILTERED_STR) - msg.gsub!(SSN_REGEX, FILTERED_STR) - + msg.gsub!(URL_PASSWORD_REGEX, FILTERED_URL_STR) if url_password + msg.gsub!(EMAIL_REGEX, FILTERED_STR) if email + if credit_card + msg.gsub!(CREDIT_CARD_REGEX, FILTERED_STR) + msg.gsub!(CREDIT_CARD_REGEX_DELIMITERS, FILTERED_STR) + end + msg.gsub!(PHONE_REGEX, FILTERED_STR) if phone + msg.gsub!(SSN_REGEX, FILTERED_STR) if ssn msg.gsub!(IP_REGEX, FILTERED_STR) if ip msg = scrubber.call(msg) if scrubber msg