Skip to content

Commit

Permalink
chore: Reduces the form_data_key length (#31905)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Jan 21, 2025
1 parent dca3efb commit a02a2f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion superset/key_value/shared_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def set_shared_value(key: SharedKey, value: Any) -> None:
def get_permalink_salt(key: SharedKey) -> str:
salt = get_shared_value(key)
if salt is None:
salt = random_key()
# Use a 48 bytes salt
salt = random_key(48)
set_shared_value(key, value=salt)
return salt
10 changes: 8 additions & 2 deletions superset/key_value/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@
HASHIDS_MIN_LENGTH = 11


def random_key() -> str:
return token_urlsafe(48)
def random_key(nbytes: int = 8) -> str:
"""
Generate a random URL-safe string.
Args:
nbytes (int): Number of bytes to use for generating the key. Default is 8.
"""
return token_urlsafe(nbytes)


def get_filter(resource: KeyValueResource, key: Key) -> KeyValueFilter:
Expand Down

0 comments on commit a02a2f5

Please sign in to comment.