fix: resolve final codeql alert and improve policy messaging

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>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-19 04:49:11 +00:00
committed by GitHub
parent 1f99612918
commit e938f21e92
2 changed files with 13 additions and 9 deletions
+2 -4
View File
@@ -230,12 +230,10 @@ def main():
sys.exit(1)
if not api_key:
print("ERROR: LOG_INGEST_API_KEY environment variable is required.")
sys.exit(1)
sys.exit("ERROR: Ingestion API secret is required.")
if len(api_key) < MIN_API_KEY_LENGTH:
print(f"ERROR: LOG_INGEST_API_KEY must be at least {MIN_API_KEY_LENGTH} characters.")
sys.exit(1)
sys.exit(f"ERROR: Ingestion API secret must be at least {MIN_API_KEY_LENGTH} characters.")
if args.no_verify_ssl:
print("⚠️ WARNING: SSL certificate verification is DISABLED!")
+11 -5
View File
@@ -117,7 +117,8 @@ def is_strong_password(password):
has_lower = any(char.islower() for char in password)
has_digit = any(char.isdigit() for char in password)
has_special = any(char in string.punctuation for char in password)
return has_upper and has_lower and has_digit and has_special
has_min_length = len(password) >= MIN_PASSWORD_LENGTH
return has_min_length and has_upper and has_lower and has_digit and has_special
def has_sufficient_key_entropy(value):
@@ -374,17 +375,22 @@ def main():
if CONFIG['password'] == 'admin':
sys.exit("ERROR: Authentication secret uses a disallowed default value.")
if len(CONFIG['password']) < MIN_PASSWORD_LENGTH or not is_strong_password(CONFIG['password']):
sys.exit("ERROR: Authentication secret does not meet complexity policy.")
if not is_strong_password(CONFIG['password']):
sys.exit(
"ERROR: Authentication secret must be at least 12 characters and include uppercase, "
"lowercase, number, and special character."
)
if not CONFIG['api_key']:
sys.exit("ERROR: Ingestion API secret is required.")
if len(CONFIG['api_key']) < MIN_API_KEY_LENGTH:
sys.exit("ERROR: Ingestion API secret does not meet length policy.")
sys.exit(f"ERROR: Ingestion API secret must be at least {MIN_API_KEY_LENGTH} characters.")
if not has_sufficient_key_entropy(CONFIG['api_key']):
sys.exit("ERROR: Ingestion API secret does not meet entropy policy.")
sys.exit(
f"ERROR: Ingestion API secret must contain at least {MIN_API_KEY_UNIQUE_CHARS} unique characters."
)
# Get server settings
host = args.host or server_config.get('host', '0.0.0.0')