From 9ef79f3422936e84c5b53e96f4afdac69b519233 Mon Sep 17 00:00:00 2001 From: Dan TS Date: Wed, 4 Jan 2023 15:58:51 -0800 Subject: [PATCH] predicates.py: strips URL params before sending URL to pipeline --- source/predicates.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/predicates.py b/source/predicates.py index c6a3ccd..41f6f46 100644 --- a/source/predicates.py +++ b/source/predicates.py @@ -1,6 +1,7 @@ """Predicates.""" import requests import re +from urllib.parse import urlparse from utility import urls_from_str, backend_base_url, backend_api_key from model import AllowDomain @@ -21,10 +22,14 @@ def str_contains_url_p(str): def url_malicious_p(url): + """Strip URL parameters to protect sensitive user information""" + url = urlparse(url) + netloc = url.netloc + """Return True or False depending on whether a URL is malicious or not.""" json_payload = { "key": backend_api_key, - "url": url + "url": netloc } r = requests.post(