You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace non-CSPRNG random with secrets module in all cryptographic code:
- rabin_miller.py: secrets.randbits/randbelow, 40 witness rounds (was 5),
guard against num<5 to prevent secrets.randbelow(0) ValueError
- rsa_key_generator.py: secrets.randbits for public exponent e
- elgamal_key_generator.py: secrets.randbelow for private key d and
primitive root g; fix broken primitive_root() filter (pow(g,p,p)==1
is always False by Fermat's Little Theorem; replace with correct
Legendre symbol check pow(g,(p-1)//2,p)!=1)
- onepad_cipher.py: secrets.randbelow for key generation; update
seed-dependent doctests to property-based assertions
Replace pickle with json+numpy in CNN model persistence:
- convolution_neural_network.py: save_model writes config.json
(hyperparameters) and weights.npz (arrays); read_model loads both.
Pickle executes arbitrary code on load; neither json nor npz does.
Breaking change: existing .pkl model files must be re-saved.
Fix path traversal in image downloader:
- download_images_from_google_query.py: sanitise query string with
re.sub before use as directory name; add Path.resolve() boundary
check to reject destinations outside cwd
Fix hardcoded secret and plaintext HTTP:
- recaptcha_verification.py: read secret key from RECAPTCHA_SECRET_KEY
env var instead of hardcoded placeholder
- current_weather.py: WEATHERSTACK_URL_BASE was http://, now https://
Replace assert-based validation with proper exceptions:
- xor_cipher.py: assert isinstance -> raise TypeError (12 sites)
- base64_cipher.py: assert -> raise TypeError/ValueError (3 sites)
assert statements are silently removed with python -O/-OO
Co-authored-by: Ona <no-reply@ona.com>
0 commit comments