aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-06-30 04:14:52 +0200
committerDaniel Teichmann <daniel.teichmann@das-netzwerkteam.de>2021-06-30 04:14:52 +0200
commit05de5991fa0518c284aea267564128c64f193a7c (patch)
tree32811fc08073aa8c5797e52e286c09c2f87a86b2
parent09f0b0b89cfa7741df78e05586f615f37f5897c8 (diff)
downloadRWA.Support.SessionService-05de5991fa0518c284aea267564128c64f193a7c.tar.gz
RWA.Support.SessionService-05de5991fa0518c284aea267564128c64f193a7c.tar.bz2
RWA.Support.SessionService-05de5991fa0518c284aea267564128c64f193a7c.zip
Add url validator for incomming strings
-rw-r--r--poetry.lock35
-rw-r--r--pyproject.toml1
-rwxr-xr-xrwa/support/sessionservice/service.py11
3 files changed, 45 insertions, 2 deletions
diff --git a/poetry.lock b/poetry.lock
index 0111965..d2145f7 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -219,6 +219,14 @@ optional = false
python-versions = "*"
[[package]]
+name = "decorator"
+version = "5.0.9"
+description = "Decorators for Humans"
+category = "main"
+optional = false
+python-versions = ">=3.5"
+
+[[package]]
name = "dj-database-url"
version = "0.5.0"
description = "Use Database URLs in your Django Application."
@@ -944,7 +952,7 @@ urllib3 = "*"
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
-category = "dev"
+category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
@@ -1213,6 +1221,21 @@ python-versions = "*"
appdirs = ">=1.2"
[[package]]
+name = "validators"
+version = "0.18.2"
+description = "Python Data Validation for Humans™."
+category = "main"
+optional = false
+python-versions = ">=3.4"
+
+[package.dependencies]
+decorator = ">=3.4.0"
+six = ">=1.4.0"
+
+[package.extras]
+test = ["pytest (>=2.2.3)", "flake8 (>=2.4.0)", "isort (>=4.2.2)"]
+
+[[package]]
name = "websockify"
version = "0.9.0"
description = "Websockify."
@@ -1249,7 +1272,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=1.2.3)", "pytest-flake8", "pyt
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
-content-hash = "368a8ee38bb0c8659c6ef4c58e51052b6186ac516234b60488abee1aaa09f5c9"
+content-hash = "cfae68fa7ede37cc59acca52ede338921d94bc20378f977431593ea36c358a5c"
[metadata.files]
alabaster = [
@@ -1373,6 +1396,10 @@ curlylint = [
dbus-python = [
{file = "dbus-python-1.2.16.tar.gz", hash = "sha256:11238f1d86c995d8aed2e22f04a1e3779f0d70e587caffeab4857f3c662ed5a4"},
]
+decorator = [
+ {file = "decorator-5.0.9-py3-none-any.whl", hash = "sha256:6e5c199c16f7a9f0e3a61a4a54b3d27e7dad0dbdde92b944426cb20914376323"},
+ {file = "decorator-5.0.9.tar.gz", hash = "sha256:72ecfba4320a893c53f9706bebb2d55c270c1e51a28789361aa93e4a21319ed5"},
+]
dj-database-url = [
{file = "dj-database-url-0.5.0.tar.gz", hash = "sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163"},
{file = "dj_database_url-0.5.0-py2.py3-none-any.whl", hash = "sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9"},
@@ -1924,6 +1951,10 @@ usersettings = [
{file = "usersettings-1.1.5-py3-none-any.whl", hash = "sha256:503be61d30d0cfd98f16bb6c9be86c29e78dc476c794ffae6333ab26f38994bf"},
{file = "usersettings-1.1.5.tar.gz", hash = "sha256:9f84b282982622d8ebfd2d42b482317ae50fb2b3a7fba22e0b0c36cac61ad673"},
]
+validators = [
+ {file = "validators-0.18.2-py3-none-any.whl", hash = "sha256:0143dcca8a386498edaf5780cbd5960da1a4c85e0719f3ee5c9b41249c4fefbd"},
+ {file = "validators-0.18.2.tar.gz", hash = "sha256:37cd9a9213278538ad09b5b9f9134266e7c226ab1fede1d500e29e0a8fbb9ea6"},
+]
websockify = [
{file = "websockify-0.9.0.tar.gz", hash = "sha256:c35b5b79ebc517d3b784dacfb993be413a93cda5222c6f382443ce29c1a6cada"},
]
diff --git a/pyproject.toml b/pyproject.toml
index be6732c..0e99464 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -25,6 +25,7 @@ flask = "^1.1.2"
argparse = "^1.0.10"
usersettings = "^1.1.5"
click = "^8.0.1"
+validators="^0.18.2"
[tool.poetry.dev-dependencies]
aleksis-builddeps = "*"
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index eb588ae..bdd8fbe 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -36,6 +36,7 @@ import dbus
import dbus.mainloop.glib
import dbus.service
from gi.repository import GLib
+import validators
from .config import user_settings
from .lock import is_locked, lock, unlock
@@ -77,6 +78,16 @@ class RWASupportSessionService(dbus.service.Object):
logging.info("D-Bus service has been started.")
+ def _is_url(self, url: str) -> bool:
+ """Test if the given string contains an url.
+
+ :param url: The string which should be an URL.
+ :return: Bool (True=is url) or (False=no url)
+ """
+ valid = validators.url(url)
+ logging.debug('is url?: "%s": %s', url, valid)
+ return valid
+
def _get_web_app_hosts(self) -> str:
"""Get all registered RWA.Support.WebApp hosts.