Fix blacklist download jobs where ignore urls were not being downloaded

This commit is contained in:
Théophile Diot 2023-05-07 19:06:22 -04:00
parent 86053d3dc5
commit ae042854f0
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 5 additions and 5 deletions

View File

@ -29,7 +29,7 @@ uri_rx = re_compile(rb"^/")
def check_line(kind: str, line: bytes) -> Tuple[bool, bytes]:
if kind == "IP":
if kind in ("IP", "IGNORE_IP"):
if b"/" in line:
with suppress(ValueError):
ip_network(line.decode("utf-8"))
@ -38,18 +38,18 @@ def check_line(kind: str, line: bytes) -> Tuple[bool, bytes]:
with suppress(ValueError):
ip_address(line.decode("utf-8"))
return True, line
elif kind == "RDNS":
elif kind in ("RDNS", "IGNORE_RDNS"):
if rdns_rx.match(line):
return True, line.lower()
elif kind == "ASN":
elif kind in ("ASN", "IGNORE_ASN"):
real_line = line.replace(b"AS", b"").replace(b"as", b"")
if asn_rx.match(real_line):
return True, real_line
elif kind == "USER_AGENT":
elif kind in ("USER_AGENT", "IGNORE_USER_AGENT"):
return True, line.replace(b"\\ ", b" ").replace(b"\\.", b"%.").replace(
b"\\\\", b"\\"
).replace(b"-", b"%-")
elif kind == "URI":
elif kind in ("URI", "IGNORE_URI"):
if uri_rx.match(line):
return True, line