S311: fix random usage
This commit is contained in:
@@ -235,7 +235,7 @@ def test_multiple_user_keys(
|
||||
# let's do some setting and getting of secrets
|
||||
|
||||
def random_str() -> str:
|
||||
return "".join(random.choices(string.ascii_letters, k=10))
|
||||
return "".join(random.choices(string.ascii_letters, k=10)) # noqa: S311 - Test data generation, not cryptographic
|
||||
|
||||
for user_key in user_keys:
|
||||
# set a secret using each of the user's private keys
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import platform
|
||||
import random
|
||||
import secrets
|
||||
from collections.abc import Generator
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass
|
||||
@@ -27,7 +27,7 @@ def graphics_options(vm: VmConfig) -> GraphicOptions:
|
||||
|
||||
if vm.waypipe.enable:
|
||||
# FIXME: check for collisions
|
||||
cid = random.randint(1, 2**32)
|
||||
cid = secrets.randbelow(2**32 - 1) + 1 # Generate random CID between 1 and 2^32
|
||||
# fmt: off
|
||||
return GraphicOptions([
|
||||
*common,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
@@ -34,8 +34,8 @@ def is_local_input(node: dict[str, dict[str, str]]) -> bool:
|
||||
def random_hostname() -> str:
|
||||
adjectives = ["wacky", "happy", "fluffy", "silly", "quirky", "zany", "bouncy"]
|
||||
nouns = ["unicorn", "penguin", "goose", "ninja", "octopus", "hamster", "robot"]
|
||||
adjective = random.choice(adjectives)
|
||||
noun = random.choice(nouns)
|
||||
adjective = secrets.choice(adjectives)
|
||||
noun = secrets.choice(nouns)
|
||||
return f"{adjective}-{noun}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user