From 69e911b1b807448b20bea6ac1cf79b0c21be3a1a Mon Sep 17 00:00:00 2001 From: sherl Date: Tue, 27 May 2025 01:33:04 +0200 Subject: [PATCH] fix: increment bad requests when trying to access authed endpoint without a token --- FlaskWebProject/FlaskWebProject/lewy_api_v1.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FlaskWebProject/FlaskWebProject/lewy_api_v1.py b/FlaskWebProject/FlaskWebProject/lewy_api_v1.py index 16c6985..b9ff90c 100644 --- a/FlaskWebProject/FlaskWebProject/lewy_api_v1.py +++ b/FlaskWebProject/FlaskWebProject/lewy_api_v1.py @@ -20,6 +20,7 @@ def require_authentication(func): except: raise AssertionError(f"Function \"{func.__name__}\" does not return status, code, and data as it should!") else: + increment_bad_requests() return 401, "error", {'error_msg': "Unauthorized"} return wrapper @@ -33,7 +34,7 @@ def not_implemented(data): def stub_hello(): return 200, 'hello from v1! stats are at /api/v1/stats', [] -def epochToDate(epoch): +def epoch_to_date(epoch): return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(epoch)) def stats(): @@ -53,7 +54,7 @@ def get_matches(): @require_authentication def debugger_halt(r): - print(f"{c.WARNING}[{epochToDate(time.time())}]{c.ENDC} {r.remote_addr} triggered a debugger halt!") + print(f"{c.WARNING}[{epoch_to_date(time.time())}]{c.ENDC} {r.remote_addr} triggered a debugger halt!") breakpoint() return 200, "ok", []