Sha256: 64f76fd71682acf31bcc1a8e2960f98666fffb85030eaab77141fb8d3a9bcf20
Contents?: true
Size: 919 Bytes
Versions: 1
Compression:
Stored size: 919 Bytes
Contents
require "logstop/formatter" require "logstop/railtie" if defined?(Rails) require "logstop/version" module Logstop FILTERED_STR = "[FILTERED]".freeze FILTERED_URL_STR = "\\1[FILTERED]@".freeze CREDIT_CARD_REGEX = /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/ EMAIL_REGEX = /\b[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\b/i 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 = /(\/\/\S+:)\S+@/ def self.scrub(msg, ip: false) msg = msg.to_s msg = msg.gsub(IP_REGEX, FILTERED_STR) if ip # order filters are applied is important msg .gsub(CREDIT_CARD_REGEX, FILTERED_STR) .gsub(PHONE_REGEX, FILTERED_STR) .gsub(SSN_REGEX, FILTERED_STR) .gsub(URL_PASSWORD_REGEX, FILTERED_URL_STR) .gsub(EMAIL_REGEX, FILTERED_STR) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
logstop-0.2.1 | lib/logstop.rb |