From ae4da946d65988caecf0ea8e5b20edb8874a8bbb Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sat, 19 Jan 2019 07:58:37 +0100 Subject: [PATCH] [enh] check domain validity --- requirements.txt | 1 + server.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/requirements.txt b/requirements.txt index 384cf27..e6795bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ sanic aiohttp +validators diff --git a/server.py b/server.py index 52254b2..8810864 100644 --- a/server.py +++ b/server.py @@ -1,4 +1,5 @@ import aiohttp +import validators from sanic import Sanic from sanic.log import logger @@ -27,6 +28,10 @@ async def check_http(request): domain = data["domain"] + if not validators.domain(domain): + logger.info(f"Invalid request, is not in the right format (domain is : {domain})") + return json_response({"status": "error", "content": "domain is not in the right format (do not include http:// or https://)"}) + # TODO DNS check async with aiohttp.ClientSession() as session: