Ejemplo n.º 1
0
    def filter(self, record):
        if not plexpy.CONFIG.LOG_BLACKLIST:
            return True

        try:
            # Currently only checking for ipv4 addresses
            ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})',
                              record.msg)
            for ip in ipv4:
                if helpers.is_public_ip(ip):
                    record.msg = record.msg.replace(
                        ip,
                        ip.partition('.')[0] + '.***.***.***')

            args = []
            for arg in record.args:
                ipv4 = re.findall(r'[0-9]+(?:\.[0-9]+){3}(?!\d*-[a-z0-9]{6})',
                                  arg) if isinstance(arg, basestring) else []
                for ip in ipv4:
                    if helpers.is_public_ip(ip):
                        arg = arg.replace(
                            ip,
                            ip.partition('.')[0] + '.***.***.***')
                args.append(arg)
            record.args = tuple(args)
        except:
            pass

        return True
Ejemplo n.º 2
0
 def replace(self, text, ip):
     if helpers.is_public_ip(ip.replace('-', '.')):
         partition = '-' if '-' in ip else '.'
         return text.replace(
             ip,
             ip.partition(partition)[0] + (partition + '***') * 3)
     return text
Ejemplo n.º 3
0
 def replace(self, text, ip):
     if helpers.is_public_ip(ip.replace('-', '.')):
         partition = '-' if '-' in ip else '.'
         return text.replace(ip, partition.join(['***'] * 4))
     return text
Ejemplo n.º 4
0
 def replace(self, text, ip):
     if helpers.is_public_ip(ip):
         return text.replace(ip, ip.partition('.')[0] + '.***.***.***')
     return text
Ejemplo n.º 5
0
 def replace(self, text, ip):
     if helpers.is_public_ip(ip.replace('-', '.')):
         return text.replace(ip, '-'.join(['***'] * 4))
     return text