mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-23 17:16:33 +00:00
Fix password hack (#368)
This commit is contained in:
parent
65a2bf2d18
commit
d067dd643e
@ -1,6 +1,9 @@
|
||||
"""Util addons functions."""
|
||||
import hashlib
|
||||
import shutil
|
||||
import re
|
||||
|
||||
RE_DIGITS = re.compile(r"\d+")
|
||||
|
||||
|
||||
def password_to_key(password):
|
||||
@ -15,7 +18,10 @@ def password_for_validating(password):
|
||||
"""Generate a SHA256 hash from password."""
|
||||
for _ in range(100):
|
||||
password = hashlib.sha256(password.encode()).hexdigest()
|
||||
return password
|
||||
try:
|
||||
return sum(map(int, RE_DIGITS.findall(password)))
|
||||
except ValueError:
|
||||
return 0
|
||||
|
||||
|
||||
def key_to_iv(key):
|
||||
|
@ -29,8 +29,7 @@ SCHEMA_SNAPSHOT = vol.Schema({
|
||||
vol.Required(ATTR_TYPE): vol.In([SNAPSHOT_FULL, SNAPSHOT_PARTIAL]),
|
||||
vol.Required(ATTR_NAME): vol.Coerce(str),
|
||||
vol.Required(ATTR_DATE): vol.Coerce(str),
|
||||
vol.Inclusive(ATTR_PROTECTED, 'encrypted'):
|
||||
vol.All(vol.Coerce(str), vol.Length(64)),
|
||||
vol.Inclusive(ATTR_PROTECTED, 'encrypted'): vol.Coerce(int),
|
||||
vol.Inclusive(ATTR_CRYPTO, 'encrypted'): CRYPTO_AES128,
|
||||
vol.Optional(ATTR_HOMEASSISTANT, default=dict): vol.Schema({
|
||||
vol.Optional(ATTR_VERSION): vol.Coerce(str),
|
||||
|
Loading…
x
Reference in New Issue
Block a user