Compare commits

..

No commits in common. "11e5507ec9f7dd467e9c272f66e450315bf4a402" and "223108004f6b83c02d96af8aa07d88ae1e3b2b9b" have entirely different histories.

View file

@ -3,7 +3,7 @@ import hmac
import hashlib
import json
from collections import defaultdict
from flask import Flask, request
from flask import Flask, request, abort
from .conf import Configuration
config = Configuration()
@ -19,12 +19,12 @@ def webhook_receiver(hook_type):
def inner(func):
def wrapped(hook_name: str):
if request.content_length is None or request.content_length > 32000:
return "Too much content", 400
abort(400)
if request.content_type != "application/json":
return "Expected json", 415
if hook_name not in relevant_hooks:
return "No such hook", 404
abort(404)
hook_conf = relevant_hooks[hook_name]
raw_payload: bytes = request.get_data(cache=False)
@ -33,7 +33,7 @@ def webhook_receiver(hook_type):
hook_conf["secret"].encode("utf-8"), raw_payload, hashlib.sha256
).hexdigest()
if not hmac.compare_digest(provided_sig, computed_sig):
return "Bad credentials", 403
abort(403)
try:
payload = json.loads(raw_payload)
@ -59,7 +59,7 @@ def fifo_hooks(payload, hook_name, hook_conf):
"""Fifo web handler -- write 1 to a unix fifo"""
try:
with open(hook_conf["fifo_path"], "w") as fifo:
fifo.write("1\n")
fifo.write("1")
except FileNotFoundError:
return "No such fifo", 500
except PermissionError: