Secure Source of Randomness (#1695)

* Secure Source of Randomness

* lint

---------

Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
pixeebot[bot] 2024-06-08 18:31:11 -07:00 committed by GitHub
parent 586a088e21
commit 62124525d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 4 deletions

View File

@ -2,6 +2,7 @@ from __future__ import annotations
import math
import random
import secrets
import string
import time
from dataclasses import dataclass
@ -133,7 +134,7 @@ class UserModel(SpiffworkflowBaseDBModel):
]
fuzz = "".join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(7))
# this is not for cryptographic purposes
adjective = random.choice(adjectives) # noqa: S311
animal = random.choice(animals) # noqa: S311
adjective = secrets.choice(adjectives) # noqa: S311
animal = secrets.choice(animals) # noqa: S311
username = f"{prefix}{adjective}{animal}{fuzz}"
return username

View File

@ -1,7 +1,7 @@
"""APIs for dealing with process groups, process models, and process instances."""
import json
import random
import secrets
import string
import flask.wrappers
@ -77,7 +77,7 @@ def script_unit_test_create(modified_process_model_identifier: str, body: dict[s
else:
unit_test_elements = unit_test_elements_array[0]
fuzz = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(7)) # noqa: S311
fuzz = "".join(secrets.choice(string.ascii_uppercase + string.digits) for _ in range(7)) # noqa: S311
unit_test_id = f"unit_test_{fuzz}"
input_json_element = spiff_element_maker("inputJson", json.dumps(input_json))