fix: Properly match hostnames

Fix #6
pull/10/head
Raphaël Vinot 2020-04-20 10:23:29 +02:00
parent dd8a9378d6
commit afa7eb4cde
1 changed files with 5 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import collections
from glob import glob
from ipaddress import ip_address, ip_network
from pathlib import Path
from urllib.parse import urlparse
try:
import jsonschema
@ -99,7 +99,10 @@ class WarningList():
# Expected to match on hostnames in URLs (i.e. the search query is a URL)
# So we do a reverse search if any of the entries in the list are present in the URL
# i.e.: value = 'http://foo.blah.de/meh' self.list == ['blah.de', 'blah.fr']
return any(v in value for v in self.list)
parsed_url = urlparse(value)
if parsed_url.hostname:
value = parsed_url.hostname
return any(value.endswith(v) for v in self.list)
elif self.type == 'cidr':
try:
value = ip_address(value)