diff options
author | John McCrae <john.mccrae@progress.com> | 2022-06-14 11:22:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 11:22:17 -0700 |
commit | 6f0a3cd9656f2c68ef6c8369d23538058394c11b (patch) | |
tree | f15af2cc2e28b06478f8422032732eddbc79ee3e /lib | |
parent | 5f4f69eb6f42313f0ca81e9ea58e11709c4d1c80 (diff) | |
parent | a09857ed3a35a02e026e2d4f9fe4a37820d40e7f (diff) | |
download | chef-6f0a3cd9656f2c68ef6c8369d23538058394c11b.tar.gz |
Merge pull request #12980 from chef/jfm/authenticator_password_gen
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/http/authenticator.rb | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/chef/http/authenticator.rb b/lib/chef/http/authenticator.rb index 6fbc2a74ba..c795297397 100644 --- a/lib/chef/http/authenticator.rb +++ b/lib/chef/http/authenticator.rb @@ -26,8 +26,6 @@ class Chef class HTTP class Authenticator DEFAULT_SERVER_API_VERSION = "2".freeze - # cspell:disable-next-line - SOME_CHARS = "~!@#%^&*_-+=`|\\(){}[<]:;'>,.?/0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".each_char.to_a extend Chef::Mixin::PowershellExec @@ -190,8 +188,9 @@ class Chef unless @win32registry.key_exists?(new_path) @win32registry.create_key(new_path, true) end + require "securerandom" unless defined?(SecureRandom) size = 14 - password = (0...size).map { SOME_CHARS[rand(SOME_CHARS.size)] }.join + password = SecureRandom.alphanumeric(size) encrypted_pass = encrypt_pfx_pass(password) values = { name: "PfxPass", type: :string, data: encrypted_pass } @win32registry.set_value(new_path, values) |