mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
[stable-10] random_string: replace random.SystemRandom() with secrets.SystemRandom() (#10896)
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
nox / Run extra sanity tests (push) Has been cancelled
random_string: replace random.SystemRandom() with secrets.SystemRandom() (#10893)
* random_string: replace random.SystemRandom() with secrets.SystemRandom()
* add the forgotten blank line
* Update changelogs/fragments/replace-random-with-secrets.yml
* readd the description
* Update changelogs/fragments/replace-random-with-secrets.yml
---------
(cherry picked from commit 14a858fd9c
)
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Co-authored-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
This commit is contained in:
parent
67562860e2
commit
ea40a39a09
2 changed files with 7 additions and 2 deletions
4
changelogs/fragments/replace-random-with-secrets.yml
Normal file
4
changelogs/fragments/replace-random-with-secrets.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
bugfixes:
|
||||
- random_string lookup plugin - replace ``random.SystemRandom()`` with ``secrets.SystemRandom()`` when
|
||||
generating strings. This has no practical effect, as both are the same
|
||||
(https://github.com/ansible-collections/community.general/pull/10893).
|
|
@ -16,7 +16,7 @@ short_description: Generates random string
|
|||
version_added: '3.2.0'
|
||||
description:
|
||||
- Generates random string based upon the given constraints.
|
||||
- Uses L(random.SystemRandom,https://docs.python.org/3/library/random.html#random.SystemRandom), so should be strong enough
|
||||
- Uses L(secrets.SystemRandom,https://docs.python.org/3/library/secrets.html#secrets.SystemRandom), so should be strong enough
|
||||
for cryptographic purposes.
|
||||
options:
|
||||
length:
|
||||
|
@ -149,6 +149,7 @@ _raw:
|
|||
|
||||
import base64
|
||||
import random
|
||||
import secrets
|
||||
import string
|
||||
|
||||
from ansible.errors import AnsibleLookupError
|
||||
|
@ -178,7 +179,7 @@ class LookupModule(LookupBase):
|
|||
lower_chars = string.ascii_lowercase
|
||||
upper_chars = string.ascii_uppercase
|
||||
special_chars = string.punctuation
|
||||
random_generator = random.SystemRandom()
|
||||
random_generator = secrets.SystemRandom()
|
||||
|
||||
self.set_options(var_options=variables, direct=kwargs)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue