aa17edf1d0
- Replace passlib.CryptContext with bcrypt 4.2.1 directly (passlib is unmaintained and only emitted warnings when paired with bcrypt 4+). hash_password / verify_password now call bcrypt.checkpw / .hashpw, and verify_password is hardened against empty inputs without raising. scripts/hash_password.py + tests/conftest.py updated to match. - status_checker.check_node() now rejects targets starting with '-' before any subprocess invocation, defending ping/tcp paths against arg-injection if an admin sets a check_target like '-O'. Tests added: - test_auth: expired JWT, malformed JWT, wrong-secret JWT, empty password vs empty server hash, verify_password edge cases. - test_scan: _background_scan failure path marks ScanRun failed, leaves non-running terminal status alone, success path invokes run_scan. - test_status_checker: ping/tcp invocations are bypassed when target or ip starts with '-'. Backend coverage 89% → 90%.
12 lines
307 B
Python
12 lines
307 B
Python
"""Generate a bcrypt password hash for the AUTH_PASSWORD_HASH env var."""
|
|
import sys
|
|
|
|
import bcrypt
|
|
|
|
if len(sys.argv) < 2:
|
|
print("Usage: python scripts/hash_password.py <password>")
|
|
sys.exit(1)
|
|
|
|
password = sys.argv[1]
|
|
print(bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt()).decode("utf-8"))
|