Skip to content

Fix entropy calc, crack-time overflow, and CLI bugs#2

Open
Marchy02 wants to merge 1 commit into
mainfrom
fix/audit-quickwins
Open

Fix entropy calc, crack-time overflow, and CLI bugs#2
Marchy02 wants to merge 1 commit into
mainfrom
fix/audit-quickwins

Conversation

@Marchy02

@Marchy02 Marchy02 commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Fix da audit del codice.

Bug corretti

  • Calcolo entropia (charset) errato: la cascata elif faceva sì che, es., minuscole+cifre usassero base 10 invece di 36 e che i caratteri speciali fossero ignorati se non presenti tutte e 4 le classi. Ora additivo (+26/+26/+10/+N), in parità tra password_tester.py e js/script.js (costante SPECIAL_CHARS condivisa).
  • OverflowError su password lunghe in time_to_crack: ora il calcolo è in spazio logaritmico, niente interi giganti materializzati.
  • FileNotFoundError sul file delle password comuni: path costruito da Path(__file__).parent/'assets'/..., caricato una sola volta in un set, con fallback se mancante.
  • Loop CLI sì/no: era in "Yy" (matchava qualsiasi stringa con 'y') → ora answer.strip().lower() == 'y'.
  • Check minuscole mancante nella CLI: aggiunto per allinearla al tool web.
  • Guard base==0 (charset vuoto) per evitare pow(0,n).

Extra

  • Scoperto un bug latente: nel set caratteri speciali Python il " veniva perso per concatenazione di literal adiacenti → ora unificato con JS (24 caratteri).
  • Aggiunto requirements.txt (rich).

Verifica

python3 (AST + esecuzione CLI) e node --check ok; parità byte-per-byte JS/Python sui casi di test.

⚠️ Da decidere: se il " debba restare nel set speciale (ora incluso).

🤖 Generated with Claude Code

Make charset entropy additive (lower+digit now base 36, special class always counted) in password_tester.py and script.js, kept in parity via a shared SPECIAL_CHARS set. Load common-passwords from a path built off __file__ under assets/ once into a set, degrading gracefully if missing. Compute time_to_crack in log space to avoid OverflowError on long inputs and guard base==0. Fix CLI yes/no loop to use equality and add the missing lowercase check to match the web verdict. Pin rich in requirements.txt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant