Skip to content

Commit 7a6f00f

Browse files
committed
ruff: Fix S311 Standard pseudo-random generators are not suitable for cryptographic purposes.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 6a7fe98 commit 7a6f00f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

zulip_bots/zulip_bots/game_handler.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import random
44
import re
5+
import secrets
56
from copy import deepcopy
67
from typing import Any, Dict, Iterable, List, Sequence, Tuple
78

@@ -764,11 +765,8 @@ def is_user_not_player(self, user_email: str, message: Dict[str, Any]) -> bool:
764765
return True
765766

766767
def generate_game_id(self) -> str:
767-
id = ""
768768
valid_characters = "abcdefghijklmnopqrstuvwxyz0123456789"
769-
for _i in range(6):
770-
id += valid_characters[random.randrange(0, len(valid_characters))]
771-
return id
769+
return "".join(secrets.choice(valid_characters) for _i in range(6))
772770

773771
def broadcast(self, game_id: str, content: str, include_private: bool = True) -> bool:
774772
if include_private:

0 commit comments

Comments
 (0)