1
0
Fork 0

webhooks: was not checking signatures...
Some checks failed
Auto updates messages.pot for readme_generator / Auto updates messages.pot for readme_generator (push) Has been cancelled
Check / auto apply Black / Check / auto apply black (push) Has been cancelled
Run tests for make_readme.py / Run tests for make_readme.py (push) Has been cancelled

This commit is contained in:
Félix Piédallu 2024-09-30 16:09:07 +02:00
parent 47a977a069
commit 8cf292fd77

View file

@ -61,7 +61,9 @@ async def github_get(request: Request) -> HTTPResponse:
@APP.route("/github", methods=["POST"]) @APP.route("/github", methods=["POST"])
async def github_post(request: Request) -> HTTPResponse: async def github_post(request: Request) -> HTTPResponse:
if UNSAFE and (signatures_reply := check_webhook_signatures(request)): if UNSAFE:
logging.warning("Unsafe webhook!")
elif signatures_reply := check_webhook_signatures(request):
return signatures_reply return signatures_reply
event = request.headers.get("X-Github-Event") event = request.headers.get("X-Github-Event")
@ -94,7 +96,6 @@ async def get_pr_infos(request: Request) -> dict:
def check_webhook_signatures(request: Request) -> Optional[HTTPResponse]: def check_webhook_signatures(request: Request) -> Optional[HTTPResponse]:
logging.warning("Unsafe webhook!")
header_signature = request.headers.get("X-Hub-Signature") header_signature = request.headers.get("X-Hub-Signature")
if header_signature is None: if header_signature is None:
logging.error("no header X-Hub-Signature") logging.error("no header X-Hub-Signature")