From 37ab7a3c67f9711c000762d48acd598106f2801a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 19 Apr 2026 04:46:25 +0000 Subject: [PATCH] chore: clarify credential validation errors and constants Agent-Logs-Url: https://github.com/Stalin-143/Keylogger/sessions/cef34b0e-605b-4ab9-8da6-2559d1dd4529 Co-authored-by: Stalin-143 <161853795+Stalin-143@users.noreply.github.com> --- src/server.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/server.py b/src/server.py index 6a346ad..07739d5 100644 --- a/src/server.py +++ b/src/server.py @@ -38,6 +38,7 @@ CONFIG = { 'api_key': None } MAX_LOG_PAYLOAD_BYTES = 64 * 1024 +MIN_API_KEY_UNIQUE_CHARS = 8 def check_auth(username, password): @@ -127,7 +128,7 @@ def has_sufficient_key_entropy(value): Returns: bool: True when key has enough character variety """ - if len(set(value)) < 8: + if len(set(value)) < MIN_API_KEY_UNIQUE_CHARS: return False if value.count(value[0]) == len(value): return False @@ -368,13 +369,25 @@ def main(): print(" source config/.env") sys.exit(1) - if CONFIG['password'] == 'admin' or len(CONFIG['password']) < 12 or not is_strong_password(CONFIG['password']): + if CONFIG['password'] == 'admin': + print("ERROR: Default password 'admin' is not allowed.") + sys.exit(1) + + if len(CONFIG['password']) < 12 or not is_strong_password(CONFIG['password']): print("ERROR: Weak password detected.") print("Please use at least 12 characters with uppercase, lowercase, number, and special character.") sys.exit(1) - if not CONFIG['api_key'] or len(CONFIG['api_key']) < 24 or not has_sufficient_key_entropy(CONFIG['api_key']): - print("ERROR: LOG_INGEST_API_KEY is required, must be at least 24 characters, and must have sufficient entropy.") + if not CONFIG['api_key']: + print("ERROR: LOG_INGEST_API_KEY is required.") + sys.exit(1) + + if len(CONFIG['api_key']) < 24: + print("ERROR: LOG_INGEST_API_KEY must be at least 24 characters.") + sys.exit(1) + + if not has_sufficient_key_entropy(CONFIG['api_key']): + print(f"ERROR: LOG_INGEST_API_KEY must include at least {MIN_API_KEY_UNIQUE_CHARS} unique characters.") sys.exit(1) # Get server settings