You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.0 KiB
90 lines
3.0 KiB
from flask import url_for
|
|
from .util import set_original_response, set_modified_response, live_server_setup, wait_for_all_checks
|
|
import time
|
|
|
|
def test_setup(client, live_server):
|
|
live_server_setup(live_server)
|
|
|
|
def test_bad_access(client, live_server):
|
|
#live_server_setup(live_server)
|
|
res = client.post(
|
|
url_for("import_page"),
|
|
data={"urls": 'https://localhost'},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b"1 Imported" in res.data
|
|
wait_for_all_checks(client)
|
|
|
|
# Attempt to add a body with a GET method
|
|
res = client.post(
|
|
url_for("edit_page", uuid="first"),
|
|
data={
|
|
"url": 'javascript:alert(document.domain)',
|
|
"tags": "",
|
|
"method": "GET",
|
|
"fetch_backend": "html_requests",
|
|
"body": ""},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b'Watch protocol is not permitted by SAFE_PROTOCOL_REGEX' in res.data
|
|
|
|
res = client.post(
|
|
url_for("form_quick_watch_add"),
|
|
data={"url": ' javascript:alert(123)', "tags": ''},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b'Watch protocol is not permitted by SAFE_PROTOCOL_REGEX' in res.data
|
|
|
|
res = client.post(
|
|
url_for("form_quick_watch_add"),
|
|
data={"url": '%20%20%20javascript:alert(123)%20%20', "tags": ''},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b'Watch protocol is not permitted by SAFE_PROTOCOL_REGEX' in res.data
|
|
|
|
|
|
res = client.post(
|
|
url_for("form_quick_watch_add"),
|
|
data={"url": ' source:javascript:alert(document.domain)', "tags": ''},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b'Watch protocol is not permitted by SAFE_PROTOCOL_REGEX' in res.data
|
|
|
|
# file:// is permitted by default, but it will be caught by ALLOW_FILE_URI
|
|
|
|
client.post(
|
|
url_for("form_quick_watch_add"),
|
|
data={"url": 'file:///tasty/disk/drive', "tags": ''},
|
|
follow_redirects=True
|
|
)
|
|
wait_for_all_checks(client)
|
|
res = client.get(url_for("index"))
|
|
|
|
assert b'file:// type access is denied for security reasons.' in res.data
|
|
|
|
def test_xss(client, live_server):
|
|
#live_server_setup(live_server)
|
|
from changedetectionio.notification import (
|
|
default_notification_format
|
|
)
|
|
# the template helpers were named .jinja which meant they were not having jinja2 autoescape enabled.
|
|
res = client.post(
|
|
url_for("settings_page"),
|
|
data={"application-notification_urls": '"><img src=x onerror=alert(document.domain)>',
|
|
"application-notification_title": '"><img src=x onerror=alert(document.domain)>',
|
|
"application-notification_body": '"><img src=x onerror=alert(document.domain)>',
|
|
"application-notification_format": default_notification_format,
|
|
"requests-time_between_check-minutes": 180,
|
|
'application-fetch_backend': "html_requests"},
|
|
follow_redirects=True
|
|
)
|
|
|
|
assert b"<img src=x onerror=alert(" not in res.data
|
|
assert b"<img" in res.data
|
|
|