1
0

We need to check that the pasth is abs and we don't need to validate

This commit is contained in:
Jorik Schellekens
2019-08-27 14:33:28 +01:00
parent c36c0278b0
commit 2d56f81d05
2 changed files with 10 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
from os.path import abspath, dirname, join
from os.path import abspath, dirname, join, isabs
from canonicaljson import json
@@ -62,13 +62,13 @@ class Server:
self.model.set_config(body)
@app.route("/testcertpaths", methods=["POST"])
@log_body_if_fail
@validate_schema(CERT_PATHS_SCHEMA)
def test_cert_paths(self, request, body):
def test_cert_paths(self, request):
body = json.loads(request.content.read())
result = {}
config_path = self.model.get_config_dir()
config_path = self.model.config_dir
for name, path in body.items():
path = abspath(join(config_path, path))
if not isabs(path):
path = abspath(join(config_path, path))
try:
with open(path, "r"):
result[name] = {"invalid": False, "absolute_path": path}
@@ -92,7 +92,7 @@ class Server:
@app.route("/start", methods=["POST"])
def start_synapse(self, request):
print("Starting synapse")
subprocess.Popen(["synctl", "start", self.model.get_config_dir()])
subprocess.Popen(["synctl", "start", self.model.config_dir])
sys.exit()
@app.route("/favicon.ico")

View File

@@ -12,6 +12,7 @@ def validate_schema(schema):
@wraps(func)
def _do_validate(self, request):
body = json.loads(request.content.read())
print(body)
validate(instance=body, schema=schema)
return func(self, request, body)
@@ -36,9 +37,9 @@ def port_checker(port):
def log_body_if_fail(func):
@wraps(func)
def _log_wrapper(request):
def _log_wrapper(self, request):
try:
return func(request)
return func(self, request)
except Exception:
body = json.loads(request.content.read())
print(body)