Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion source/predicates.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail on malformed URLs!

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(
Expand Down