chef 18.0.185-x64-mingw-ucrt → 18.1.29-x64-mingw-ucrt
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/chef.gemspec +3 -2
- data/lib/chef/application/base.rb +18 -2
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/client.rb +23 -6
- data/lib/chef/http/authenticator.rb +117 -34
- data/lib/chef/mixin/proxified_socket.rb +1 -1
- data/lib/chef/property.rb +8 -3
- data/lib/chef/provider/launchd.rb +1 -0
- data/lib/chef/provider/package/yum/yum_helper.py +5 -17
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/resource/apt_repository.rb +20 -2
- data/lib/chef/resource/bash.rb +13 -0
- data/lib/chef/resource/dsc_script.rb +1 -1
- data/lib/chef/resource/launchd.rb +4 -1
- data/lib/chef/resource/macos_userdefaults.rb +3 -3
- data/lib/chef/resource/rhsm_register.rb +2 -1
- data/lib/chef/resource/selinux_fcontext.rb +1 -1
- data/lib/chef/resource/selinux_permissive.rb +1 -1
- data/lib/chef/resource/selinux_port.rb +1 -1
- data/lib/chef/resource/selinux_state.rb +1 -1
- data/lib/chef/resource/service.rb +1 -1
- data/lib/chef/resource/user.rb +2 -2
- data/lib/chef/resource/windows_user_privilege.rb +14 -10
- data/lib/chef/resource/yum_repository.rb +4 -0
- data/lib/chef/version.rb +1 -1
- data/spec/functional/assets/yumrepo-empty/repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo-empty/repodata/repomd.xml +55 -0
- data/spec/functional/resource/yum_package_spec.rb +16 -0
- data/spec/integration/client/client_spec.rb +22 -16
- data/spec/integration/client/fips_spec.rb +20 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/platform_helpers.rb +4 -0
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +26 -2
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/http/authenticator_spec.rb +64 -11
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +26 -5
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- metadata +21 -14
- data/distro/powershell/chef/chef.psm1 +0 -459
data/lib/chef/resource/bash.rb
CHANGED
@@ -43,6 +43,19 @@ class Chef
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
+
**Using escape characters in a string of code**
|
47
|
+
|
48
|
+
In the following example, the `find` command uses an escape character (`\`). Use a second escape character (`\\`) to preserve the escape character in the code string:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
bash 'delete some archives ' do
|
52
|
+
code <<-EOH
|
53
|
+
find ./ -name "*.tar.Z" -mtime +180 -exec rm -f {} \\;
|
54
|
+
EOH
|
55
|
+
ignore_failure true
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
46
59
|
**Install a file from a remote location**
|
47
60
|
|
48
61
|
The following is an example of how to install the foo123 module for Nginx. This module adds shell-style functionality to an Nginx configuration file and does the following:
|
@@ -34,7 +34,7 @@ class Chef
|
|
34
34
|
resource in #{ChefUtils::Dist::Infra::PRODUCT}, such as the Archive resource, a custom DSC resource, an existing DSC script that performs an important
|
35
35
|
task, and so on. Use the dsc_script resource to embed the code that defines a DSC configuration directly within a #{ChefUtils::Dist::Infra::PRODUCT} recipe.
|
36
36
|
|
37
|
-
Warning: The **dsc_script** resource
|
37
|
+
Warning: The **dsc_script** resource is only available on 64-bit Chef Infra Client.
|
38
38
|
DESC
|
39
39
|
|
40
40
|
default_action :run
|
@@ -21,7 +21,7 @@ require_relative "../resource"
|
|
21
21
|
class Chef
|
22
22
|
class Resource
|
23
23
|
class Launchd < Chef::Resource
|
24
|
-
provides :launchd
|
24
|
+
provides :launchd, os: "darwin"
|
25
25
|
|
26
26
|
description "Use the **launchd** resource to manage system-wide services (daemons) and per-user services (agents) on the macOS platform."
|
27
27
|
introduced "12.8"
|
@@ -129,6 +129,9 @@ class Chef
|
|
129
129
|
property :abandon_process_group, [ TrueClass, FalseClass ],
|
130
130
|
description: "If a job dies, all remaining processes with the same process ID may be kept running. Set to true to kill all remaining processes."
|
131
131
|
|
132
|
+
property :associated_bundle_identifiers, Array,
|
133
|
+
description: "This optional key indicates which bundles the Login Items Added by Apps panel associates with the helper executable."
|
134
|
+
|
132
135
|
property :debug, [ TrueClass, FalseClass ],
|
133
136
|
description: "Sets the log mask to `LOG_DEBUG` for this job."
|
134
137
|
|
@@ -69,7 +69,7 @@ class Chef
|
|
69
69
|
|
70
70
|
property :global, [TrueClass, FalseClass],
|
71
71
|
description: "Determines whether or not the domain is global.",
|
72
|
-
deprecated:
|
72
|
+
deprecated: "As of Chef Infra Client 17.8 the `global` property is no longer necessary.",
|
73
73
|
default: false,
|
74
74
|
desired_state: false
|
75
75
|
|
@@ -90,7 +90,7 @@ class Chef
|
|
90
90
|
description: "The value type of the preference key.",
|
91
91
|
equal_to: %w{bool string int float array dict},
|
92
92
|
desired_state: false,
|
93
|
-
deprecated:
|
93
|
+
deprecated: "As of Chef Infra Client 17.8 the `type` property is no longer necessary."
|
94
94
|
|
95
95
|
property :user, [String, Symbol],
|
96
96
|
description: "The system user that the default will be applied to. Set :current for current user, :all for all users or pass a valid username",
|
@@ -100,7 +100,7 @@ class Chef
|
|
100
100
|
description: "Set to true if the setting you wish to modify requires privileged access. This requires passwordless sudo for the `/usr/bin/defaults` command to be setup for the user running #{ChefUtils::Dist::Infra::PRODUCT}.",
|
101
101
|
default: false,
|
102
102
|
desired_state: false,
|
103
|
-
deprecated:
|
103
|
+
deprecated: "As of Chef Infra Client 17.8 the `sudo` property is no longer necessary."
|
104
104
|
|
105
105
|
load_current_value do |new_resource|
|
106
106
|
Chef::Log.debug "#load_current_value: attempting to read \"#{new_resource.domain}\" value from preferences to determine state"
|
@@ -92,7 +92,7 @@ class Chef
|
|
92
92
|
|
93
93
|
property :release,
|
94
94
|
[Float, String],
|
95
|
-
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used
|
95
|
+
description: "Sets the operating system minor release to use for subscriptions for the system. Products and updates are limited to the specified minor release version. This is used with the `auto_attach` or `activation_key` options. For example, `release '6.4'` will append `--release=6.4` to the register command.",
|
96
96
|
introduced: "17.8"
|
97
97
|
|
98
98
|
action :register, description: "Register the node with RHSM." do
|
@@ -205,6 +205,7 @@ class Chef
|
|
205
205
|
command << "--name=#{Shellwords.shellescape(new_resource.system_name)}" if new_resource.system_name
|
206
206
|
command << "--serverurl=#{Shellwords.shellescape(new_resource.server_url)}" if new_resource.server_url
|
207
207
|
command << "--baseurl=#{Shellwords.shellescape(new_resource.base_url)}" if new_resource.base_url
|
208
|
+
command << "--release=#{Shellwords.shellescape(new_resource.release)}" if new_resource.release
|
208
209
|
command << "--force" if new_resource.force
|
209
210
|
|
210
211
|
return command.join(" ")
|
@@ -22,7 +22,7 @@ class Chef
|
|
22
22
|
|
23
23
|
provides :selinux_fcontext
|
24
24
|
|
25
|
-
description "Use **selinux_fcontext** resource to set the SELinux context of files
|
25
|
+
description "Use the **selinux_fcontext** resource to set the SELinux context of files using the `semanage fcontext` command."
|
26
26
|
introduced "18.0"
|
27
27
|
examples <<~DOC
|
28
28
|
**Allow http servers (e.g. nginx/apache) to modify moodle files**:
|
@@ -20,7 +20,7 @@ class Chef
|
|
20
20
|
|
21
21
|
provides :selinux_permissive
|
22
22
|
|
23
|
-
description "Use **selinux_permissive** resource to
|
23
|
+
description "Use the **selinux_permissive** resource to allow some domains to misbehave without stopping them. This is not as good as setting specific policies, but better than disabling SELinux entirely."
|
24
24
|
introduced "18.0"
|
25
25
|
examples <<~DOC
|
26
26
|
**Disable enforcement on Apache**:
|
@@ -21,7 +21,7 @@ class Chef
|
|
21
21
|
|
22
22
|
provides :selinux_port
|
23
23
|
|
24
|
-
description "Use **selinux_port** resource to
|
24
|
+
description "Use the **selinux_port** resource to assign a network port to a specific SELinux context. For example, running a web server on a non-standard port."
|
25
25
|
introduced "18.0"
|
26
26
|
examples <<~DOC
|
27
27
|
**Allow nginx/apache to bind to port 5678 by giving it the http_port_t context**:
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
|
57
57
|
property :persistent, [true, false],
|
58
58
|
default: true,
|
59
|
-
description: "
|
59
|
+
description: "Set the status update in the SELinux configuration file."
|
60
60
|
|
61
61
|
property :policy, String,
|
62
62
|
default: lazy { default_policy_platform },
|
@@ -81,7 +81,7 @@ class Chef
|
|
81
81
|
# specify overrides for the start_command, stop_command and
|
82
82
|
# restart_command properties.
|
83
83
|
property :init_command, String,
|
84
|
-
description: "The path to the init script that is associated with the service. Use init_command to prevent the need to specify overrides for the start_command
|
84
|
+
description: "The path to the init script that is associated with the service. Use `init_command` to prevent the need to specify overrides for the `start_command`, `stop_command`, and `restart_command` properties. When this property is not specified, the #{ChefUtils::Dist::Infra::PRODUCT} will use the default init command for the service provider being used.",
|
85
85
|
desired_state: false
|
86
86
|
|
87
87
|
# if the service is enabled or not
|
data/lib/chef/resource/user.rb
CHANGED
@@ -74,12 +74,12 @@ class Chef
|
|
74
74
|
alias_method :group, :gid
|
75
75
|
|
76
76
|
property :expire_date, [ String, NilClass ],
|
77
|
-
description: "(Linux) The date on which the user account will be disabled. The date is specified in
|
77
|
+
description: "(Linux) The date on which the user account will be disabled. The date is specified in YYYY-MM-DD format.",
|
78
78
|
introduced: "18.0",
|
79
79
|
desired_state: false
|
80
80
|
|
81
81
|
property :inactive, [ String, Integer, NilClass ],
|
82
|
-
description: "(Linux) The number of days after a password expires until the account is permanently disabled. A value of 0 disables the account as soon as the password has expired, and a value of
|
82
|
+
description: "(Linux) The number of days after a password expires until the account is permanently disabled. A value of `0` disables the account as soon as the password has expired, and a value of `-1` disables the feature.",
|
83
83
|
introduced: "18.0",
|
84
84
|
desired_state: false
|
85
85
|
end
|
@@ -23,12 +23,14 @@ class Chef
|
|
23
23
|
class WindowsUserPrivilege < Chef::Resource
|
24
24
|
|
25
25
|
provides :windows_user_privilege
|
26
|
-
description "
|
26
|
+
description "Use the **windows_user_privilege** resource to set privileges for a principal, user, or group.\n See [Microsoft's user rights assignment documentation](https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment) for more information."
|
27
27
|
|
28
28
|
introduced "16.0"
|
29
29
|
|
30
30
|
examples <<~DOC
|
31
|
-
**Set the SeNetworkLogonRight
|
31
|
+
**Set the SeNetworkLogonRight privilege for the Builtin Administrators and Authenticated Users groups**:
|
32
|
+
|
33
|
+
The `:set` action will add this privilege for these two groups and remove this privilege from all other groups or users.
|
32
34
|
|
33
35
|
```ruby
|
34
36
|
windows_user_privilege 'Network Logon Rights' do
|
@@ -38,7 +40,9 @@ class Chef
|
|
38
40
|
end
|
39
41
|
```
|
40
42
|
|
41
|
-
**
|
43
|
+
**Set the SeCreatePagefilePrivilege privilege for the Builtin Guests and Administrator groups**:
|
44
|
+
|
45
|
+
The `:set` action will add this privilege for these two groups and remove this privilege from all other groups or users.
|
42
46
|
|
43
47
|
```ruby
|
44
48
|
windows_user_privilege 'Create Pagefile' do
|
@@ -48,7 +52,7 @@ class Chef
|
|
48
52
|
end
|
49
53
|
```
|
50
54
|
|
51
|
-
**Add the SeDenyRemoteInteractiveLogonRight
|
55
|
+
**Add the SeDenyRemoteInteractiveLogonRight privilege to the 'Remote interactive logon' principal**:
|
52
56
|
|
53
57
|
```ruby
|
54
58
|
windows_user_privilege 'Remote interactive logon' do
|
@@ -57,7 +61,7 @@ class Chef
|
|
57
61
|
end
|
58
62
|
```
|
59
63
|
|
60
|
-
**Add to the Builtin Guests
|
64
|
+
**Add the SeCreatePageFilePrivilege privilege to the Builtin Guests group**:
|
61
65
|
|
62
66
|
```ruby
|
63
67
|
windows_user_privilege 'Guests add Create Pagefile' do
|
@@ -67,7 +71,7 @@ class Chef
|
|
67
71
|
end
|
68
72
|
```
|
69
73
|
|
70
|
-
**Remove the
|
74
|
+
**Remove the SeCreatePageFilePrivilege privilege from the Builtin Guests group**:
|
71
75
|
|
72
76
|
```ruby
|
73
77
|
windows_user_privilege 'Create Pagefile' do
|
@@ -77,7 +81,7 @@ class Chef
|
|
77
81
|
end
|
78
82
|
```
|
79
83
|
|
80
|
-
**Clear
|
84
|
+
**Clear the SeDenyNetworkLogonRight privilege from all users**:
|
81
85
|
|
82
86
|
```ruby
|
83
87
|
windows_user_privilege 'Allow any user the Network Logon right' do
|
@@ -135,15 +139,15 @@ class Chef
|
|
135
139
|
}.freeze
|
136
140
|
|
137
141
|
property :principal, String,
|
138
|
-
description: "An optional property to add the privilege for given principal. Use only with add and remove action. Principal can either be a
|
142
|
+
description: "An optional property to add the privilege for given principal. Use only with add and remove action. Principal can either be a user, group, or [special identity](https://docs.microsoft.com/en-us/windows/security/identity-protection/access-control/special-identities).",
|
139
143
|
name_property: true
|
140
144
|
|
141
145
|
property :users, [Array, String],
|
142
|
-
description: "An optional property to set the privilege for
|
146
|
+
description: "An optional property to set the privilege for the specified users. Use only with `:set` action",
|
143
147
|
coerce: proc { |v| Array(v) }
|
144
148
|
|
145
149
|
property :privilege, [Array, String],
|
146
|
-
description: "One or more privileges to set for principal or users/groups. For more information on what each privilege does
|
150
|
+
description: "One or more privileges to set for principal or users/groups. For more information, see [Microsoft's documentation on what each privilege does](https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-rights-assignment).",
|
147
151
|
required: true,
|
148
152
|
coerce: proc { |v| Array(v) },
|
149
153
|
callbacks: {
|
@@ -114,6 +114,10 @@ class Chef
|
|
114
114
|
description: "Determines whether package files downloaded by Yum stay in cache directories. By using cached data, you can carry out certain operations without a network connection.",
|
115
115
|
default: true
|
116
116
|
|
117
|
+
property :makecache_fast, [TrueClass, FalseClass],
|
118
|
+
description: "if make_cache is true, uses `yum makecache fast`, which downloads only the minimum amount of data required. Useful over slower connections and when disk space is at a premium.",
|
119
|
+
default: false
|
120
|
+
|
117
121
|
property :max_retries, [String, Integer],
|
118
122
|
description: "Number of times any attempt to retrieve a file should retry before returning an error. Setting this to `0` makes Yum try forever."
|
119
123
|
|
data/lib/chef/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
|
3
|
+
<revision>1667508211</revision>
|
4
|
+
<data type="filelists">
|
5
|
+
<checksum type="sha256">401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93</checksum>
|
6
|
+
<open-checksum type="sha256">bf9808b81cb2dbc54b4b8e35adc584ddcaa73bd81f7088d73bf7dbbada961310</open-checksum>
|
7
|
+
<location href="repodata/401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz"/>
|
8
|
+
<timestamp>1667508211</timestamp>
|
9
|
+
<size>123</size>
|
10
|
+
<open-size>125</open-size>
|
11
|
+
</data>
|
12
|
+
<data type="primary">
|
13
|
+
<checksum type="sha256">dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9</checksum>
|
14
|
+
<open-checksum type="sha256">e1e2ffd2fb1ee76f87b70750d00ca5677a252b397ab6c2389137a0c33e7b359f</open-checksum>
|
15
|
+
<location href="repodata/dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz"/>
|
16
|
+
<timestamp>1667508211</timestamp>
|
17
|
+
<size>134</size>
|
18
|
+
<open-size>167</open-size>
|
19
|
+
</data>
|
20
|
+
<data type="primary_db">
|
21
|
+
<checksum type="sha256">5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945</checksum>
|
22
|
+
<open-checksum type="sha256">f0d550414e8f2e960e82e704549364299ca9e3e8664ad4faffd208262c3b6d12</open-checksum>
|
23
|
+
<location href="repodata/5dc1e6e73c84803f059bb3065e684e56adfc289a7e398946574d79dac6643945-primary.sqlite.bz2"/>
|
24
|
+
<timestamp>1667508211</timestamp>
|
25
|
+
<database_version>10</database_version>
|
26
|
+
<size>1131</size>
|
27
|
+
<open-size>21504</open-size>
|
28
|
+
</data>
|
29
|
+
<data type="other_db">
|
30
|
+
<checksum type="sha256">7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4</checksum>
|
31
|
+
<open-checksum type="sha256">4de0fe7c5dd2674849a7c63c326e42f33af0a0f46219bc6dd59f51dfa2ac8c68</open-checksum>
|
32
|
+
<location href="repodata/7c36572015e075add2b38b900837bcdbb8a504130ddff49b2351a7fc0affa3d4-other.sqlite.bz2"/>
|
33
|
+
<timestamp>1667508211</timestamp>
|
34
|
+
<database_version>10</database_version>
|
35
|
+
<size>575</size>
|
36
|
+
<open-size>6144</open-size>
|
37
|
+
</data>
|
38
|
+
<data type="other">
|
39
|
+
<checksum type="sha256">6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670</checksum>
|
40
|
+
<open-checksum type="sha256">e0ed5e0054194df036cf09c1a911e15bf2a4e7f26f2a788b6f47d53e80717ccc</open-checksum>
|
41
|
+
<location href="repodata/6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz"/>
|
42
|
+
<timestamp>1667508211</timestamp>
|
43
|
+
<size>123</size>
|
44
|
+
<open-size>121</open-size>
|
45
|
+
</data>
|
46
|
+
<data type="filelists_db">
|
47
|
+
<checksum type="sha256">01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523</checksum>
|
48
|
+
<open-checksum type="sha256">c4211f57bdcbb142c9f93a6d32401539f775eb6a670ab7a423e13f435ce94689</open-checksum>
|
49
|
+
<location href="repodata/01a3b489a465bcac22a43492163df43451dc6ce47d27f66de289756b91635523-filelists.sqlite.bz2"/>
|
50
|
+
<timestamp>1667508211</timestamp>
|
51
|
+
<database_version>10</database_version>
|
52
|
+
<size>586</size>
|
53
|
+
<open-size>7168</open-size>
|
54
|
+
</data>
|
55
|
+
</repomd>
|
@@ -57,6 +57,12 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
|
|
57
57
|
baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo
|
58
58
|
enable=1
|
59
59
|
gpgcheck=0
|
60
|
+
[chef-yum-empty]
|
61
|
+
name=Chef DNF spec empty repo
|
62
|
+
baseurl=file://#{CHEF_SPEC_ASSETS}/yumrepo-empty
|
63
|
+
enable=1
|
64
|
+
gpgcheck=0
|
65
|
+
|
60
66
|
EOF
|
61
67
|
end
|
62
68
|
# ensure we don't have any stray chef_rpms installed
|
@@ -1095,6 +1101,16 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
|
|
1095
1101
|
end.should_not_be_updated
|
1096
1102
|
end
|
1097
1103
|
|
1104
|
+
it "should work to disable a repo" do
|
1105
|
+
flush_cache
|
1106
|
+
expect {
|
1107
|
+
yum_package "chef_rpm" do
|
1108
|
+
options "--disablerepo=chef-yum-localtesting --enablerepo=chef-yum-empty"
|
1109
|
+
action :install
|
1110
|
+
end
|
1111
|
+
}.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
|
1112
|
+
end
|
1113
|
+
|
1098
1114
|
it "when an idempotent install action is run, does not leave repos disabled" do
|
1099
1115
|
flush_cache
|
1100
1116
|
# this is a bit tricky -- we need this action to be idempotent, so that it doesn't recycle any
|
@@ -35,14 +35,14 @@ describe "chef-client" do
|
|
35
35
|
@server = @api = nil
|
36
36
|
end
|
37
37
|
|
38
|
-
def install_certificate_in_store(client_name)
|
38
|
+
def install_certificate_in_store(client_name, store_location)
|
39
39
|
if ChefUtils.windows?
|
40
40
|
powershell_exec! <<~EOH
|
41
41
|
if (-not (($PSVersionTable.PSVersion.Major -ge 5) -and ($PSVersionTable.PSVersion.Build -ge 22000)) ) {
|
42
|
-
New-SelfSignedCertificate -CertStoreLocation Cert
|
42
|
+
New-SelfSignedCertificate -CertStoreLocation Cert:\\#{store_location}\\My -DnsName "#{client_name}"
|
43
43
|
}
|
44
44
|
else {
|
45
|
-
New-SelfSignedCertificate -CertStoreLocation Cert
|
45
|
+
New-SelfSignedCertificate -CertStoreLocation Cert:\\#{store_location}\\My -Subject "#{client_name}" -FriendlyName "#{client_name}" -KeyExportPolicy Exportable
|
46
46
|
}
|
47
47
|
EOH
|
48
48
|
end
|
@@ -50,14 +50,6 @@ describe "chef-client" do
|
|
50
50
|
|
51
51
|
def create_registry_key
|
52
52
|
::Chef::HTTP::Authenticator.get_cert_password
|
53
|
-
# @win32registry = Chef::Win32::Registry.new
|
54
|
-
# path = "HKEY_LOCAL_MACHINE\\Software\\Progress\\Authentication"
|
55
|
-
# unless @win32registry.key_exists?(path)
|
56
|
-
# @win32registry.create_key(path, true)
|
57
|
-
# end
|
58
|
-
# password = SOME_CHARS.sample(1 + rand(SOME_CHARS.count)).join[0...14]
|
59
|
-
# values = { name: "PfxPass", type: :string, data: password }
|
60
|
-
# @win32registry.set_value(path, values)
|
61
53
|
end
|
62
54
|
|
63
55
|
def remove_certificate_from_store
|
@@ -111,6 +103,9 @@ describe "chef-client" do
|
|
111
103
|
tempfile.close
|
112
104
|
@path = tempfile.path
|
113
105
|
Chef::Config.validation_key = @path
|
106
|
+
if ChefUtils.windows?
|
107
|
+
create_registry_key
|
108
|
+
end
|
114
109
|
|
115
110
|
file "config/client.rb", <<~EOM
|
116
111
|
local_mode true
|
@@ -201,17 +196,27 @@ describe "chef-client" do
|
|
201
196
|
|
202
197
|
if ChefUtils.windows?
|
203
198
|
context "and the private key is in the Windows CertStore" do
|
204
|
-
|
205
|
-
|
199
|
+
|
200
|
+
it "should verify that the cert is loaded in the \\LocalMachine\\My store" do
|
201
|
+
Chef::Config[:auth_key_registry_type] = "machine"
|
202
|
+
install_certificate_in_store(client_name, "LocalMachine")
|
206
203
|
create_registry_key
|
204
|
+
expect(Chef::HTTP::Authenticator.check_certstore_for_key(hostname)).to eq(true)
|
207
205
|
end
|
208
206
|
|
209
|
-
|
207
|
+
it "should verify that the export password for the pfx is loaded in the Registry" do
|
208
|
+
expect(verify_export_password_exists.result).to eq(true)
|
209
|
+
end
|
210
|
+
|
211
|
+
it "should verify that a private key is returned to me" do
|
212
|
+
expect(Chef::HTTP::Authenticator.retrieve_certificate_key(client_name)).not_to be nil
|
210
213
|
remove_certificate_from_store
|
211
|
-
remove_registry_key
|
212
214
|
end
|
213
215
|
|
214
|
-
it "should verify that the cert is loaded in the
|
216
|
+
it "should verify that the cert is loaded in the \\CurrentUser\\My store" do
|
217
|
+
Chef::Config[:auth_key_registry_type] = "user"
|
218
|
+
install_certificate_in_store(client_name, "CurrentUser")
|
219
|
+
create_registry_key
|
215
220
|
expect(Chef::HTTP::Authenticator.check_certstore_for_key(hostname)).to eq(true)
|
216
221
|
end
|
217
222
|
|
@@ -221,6 +226,7 @@ describe "chef-client" do
|
|
221
226
|
|
222
227
|
it "should verify that a private key is returned to me" do
|
223
228
|
expect(Chef::HTTP::Authenticator.retrieve_certificate_key(client_name)).not_to be nil
|
229
|
+
remove_certificate_from_store
|
224
230
|
end
|
225
231
|
end
|
226
232
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "chef-client fips" do
|
4
|
+
def enable_fips
|
5
|
+
OpenSSL.fips_mode = true
|
6
|
+
end
|
7
|
+
|
8
|
+
# All tests assume fips mode is off at present
|
9
|
+
after { OpenSSL.fips_mode = false }
|
10
|
+
|
11
|
+
# For non-FIPS OSes/builds of Ruby, enabling FIPS should error
|
12
|
+
example "Error enabling fips_mode if FIPS not linked", fips_mode: false do
|
13
|
+
expect { enable_fips }.to raise_error(OpenSSL::OpenSSLError)
|
14
|
+
end
|
15
|
+
|
16
|
+
# For FIPS OSes/builds of Ruby, enabling FIPS should not error
|
17
|
+
example "Do not error enabling fips_mode if FIPS linked", fips_mode: true do
|
18
|
+
expect { enable_fips }.not_to raise_error
|
19
|
+
end
|
20
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -138,6 +138,10 @@ RSpec.configure do |config|
|
|
138
138
|
|
139
139
|
config.filter_run_excluding skip_buildkite: true if ENV["BUILDKITE"]
|
140
140
|
|
141
|
+
config.filter_run_excluding fips_mode: !fips_mode_build?
|
142
|
+
# Skip fips on windows
|
143
|
+
# config.filter_run_excluding :fips_mode if windows?
|
144
|
+
|
141
145
|
config.filter_run_excluding windows_only: true unless windows?
|
142
146
|
config.filter_run_excluding not_supported_on_windows: true if windows?
|
143
147
|
config.filter_run_excluding not_supported_on_macos: true if macos?
|
data/spec/unit/client_spec.rb
CHANGED
@@ -310,25 +310,49 @@ describe Chef::Client, :windows_only do
|
|
310
310
|
end
|
311
311
|
|
312
312
|
context "when the client intially boots the first time" do
|
313
|
-
it "verfies that a certificate was correctly created and exists in the Cert Store" do
|
313
|
+
it "verfies that a certificate was correctly created and exists in the LocalMachine Cert Store" do
|
314
|
+
Chef::Config[:node_name] = "test"
|
314
315
|
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
315
316
|
my_client.import_pfx_to_store(new_pfx)
|
316
317
|
expect(my_client.check_certstore_for_key(cert_name)).not_to be false
|
318
|
+
delete_certificate(cert_name)
|
317
319
|
end
|
318
320
|
|
319
321
|
it "correctly returns a new Publc Key" do
|
320
322
|
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
321
323
|
cert_object = new_pfx.certificate.public_key.to_pem
|
322
324
|
expect(cert_object.to_s).to match(/PUBLIC KEY/)
|
325
|
+
delete_certificate(cert_name)
|
326
|
+
end
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
context "when the client intially boots the first time and auth_key_registry_type is set to 'user' " do
|
331
|
+
it "verfies that a certificate was correctly created and exists in the CurrentUser Cert Store" do
|
332
|
+
Chef::Config[:node_name] = "test"
|
333
|
+
Chef::Config[:auth_key_registry_type] = "user"
|
334
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
335
|
+
my_client.import_pfx_to_store(new_pfx)
|
336
|
+
expect(my_client.check_certstore_for_key(cert_name)).not_to be false
|
337
|
+
delete_certificate(cert_name)
|
338
|
+
end
|
339
|
+
|
340
|
+
it "correctly returns a new Publc Key" do
|
341
|
+
Chef::Config[:auth_key_registry_type] = "user"
|
342
|
+
new_pfx = my_client.generate_pfx_package(cert_name, end_date)
|
343
|
+
cert_object = new_pfx.certificate.public_key.to_pem
|
344
|
+
expect(cert_object.to_s).to match(/PUBLIC KEY/)
|
345
|
+
delete_certificate(cert_name)
|
323
346
|
end
|
324
347
|
|
325
348
|
end
|
326
349
|
|
327
350
|
def delete_certificate(cert_name)
|
351
|
+
Chef::Config[:auth_key_registry_type] == "user" ? store = "CurrentUser" : store = "LocalMachine"
|
328
352
|
require "chef/mixin/powershell_exec"
|
329
353
|
extend Chef::Mixin::PowershellExec
|
330
354
|
powershell_code = <<~CODE
|
331
|
-
Get-ChildItem -path cert
|
355
|
+
Get-ChildItem -path cert:\\#{store}\\My -Recurse -Force | Where-Object { $_.Subject -Match "#{cert_name}" } | Remove-item
|
332
356
|
CODE
|
333
357
|
powershell_exec!(powershell_code)
|
334
358
|
end
|
@@ -49,6 +49,14 @@ describe Chef::Compliance::Runner do
|
|
49
49
|
expect(runner).not_to be_enabled
|
50
50
|
end
|
51
51
|
|
52
|
+
it "is false if the node attributes have audit profiles and the audit cookbook is present, and the complince mode attribute is false" do
|
53
|
+
stub_const("::Reporter::ChefAutomate", true)
|
54
|
+
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
|
55
|
+
node.normal["audit"]["compliance_phase"] = false
|
56
|
+
|
57
|
+
expect(runner).not_to be_enabled
|
58
|
+
end
|
59
|
+
|
52
60
|
it "is true if the node attributes have audit profiles and the audit cookbook is present, and the complince mode attribute is true" do
|
53
61
|
stub_const("::Reporter::ChefAutomate", true)
|
54
62
|
node.normal["audit"]["profiles"]["ssh"] = { 'compliance': "base/ssh" }
|