ruff: Fix S311 Standard pseudo-random generators are not suitable for cryptographic purposes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6a7fe98eef
commit
7a6f00fdae
1 changed files with 2 additions and 4 deletions
|
@ -2,6 +2,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
|
import secrets
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Any, Dict, Iterable, List, Sequence, Tuple
|
from typing import Any, Dict, Iterable, List, Sequence, Tuple
|
||||||
|
|
||||||
|
@ -764,11 +765,8 @@ To move subjects, send your message again, otherwise join the game using the lin
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def generate_game_id(self) -> str:
|
def generate_game_id(self) -> str:
|
||||||
id = ""
|
|
||||||
valid_characters = "abcdefghijklmnopqrstuvwxyz0123456789"
|
valid_characters = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
for _i in range(6):
|
return "".join(secrets.choice(valid_characters) for _i in range(6))
|
||||||
id += valid_characters[random.randrange(0, len(valid_characters))]
|
|
||||||
return id
|
|
||||||
|
|
||||||
def broadcast(self, game_id: str, content: str, include_private: bool = True) -> bool:
|
def broadcast(self, game_id: str, content: str, include_private: bool = True) -> bool:
|
||||||
if include_private:
|
if include_private:
|
||||||
|
|
Loading…
Add table
Reference in a new issue