Skip to content

Commit 619b7c0

Browse files
apply some logic for entropy in sus user check
1 parent ec77e9a commit 619b7c0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code/logic/input.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ int fossil_io_validate_is_suspicious_user(const char *input) {
421421
// 3. Check for long digit/symbol runs or too few letters
422422
if (max_digit_run >= 5) return 1; // suspicious long digit tail
423423
if (max_symbol_run >= 4) return 1; // suspicious long symbol run
424-
if ((float)digit_count / len > 0.5) return 1; // mostly digits
424+
if (digit_count >= 8) return 1; // many digits (new: covers user1234567890)
425+
if ((float)digit_count / len > 0.45) return 1; // high digit ratio (new: covers a1b2c3d4e5f6g7h8i9j0)
425426
if ((float)alpha_count / len < 0.3) return 1; // too few letters
426427
if ((float)symbol_count / len > 0.3) return 1; // too many symbols
427428

@@ -472,7 +473,7 @@ int fossil_io_validate_is_suspicious_user(const char *input) {
472473
entropy -= p * log2(p);
473474
}
474475
}
475-
if (entropy > 4.5) return 1; // suspiciously random-like
476+
if (entropy > 4.2) return 1; // slightly lower threshold for suspicious randomness
476477

477478
// 8. Looks like an email or URL
478479
if (strchr(input, '@') || fossil_io_cstring_case_search(input, "http") != NULL) return 1;

0 commit comments

Comments
 (0)