chef 18.1.29-x64-mingw-ucrt → 18.3.0-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/chef-universal-mingw-ucrt.gemspec +2 -2
  3. data/chef.gemspec +1 -2
  4. data/distro/powershell/chef/chef.psm1 +459 -0
  5. data/lib/chef/application/base.rb +2 -0
  6. data/lib/chef/client.rb +2 -2
  7. data/lib/chef/cookbook/synchronizer.rb +20 -2
  8. data/lib/chef/cookbook_version.rb +1 -1
  9. data/lib/chef/http/authenticator.rb +2 -2
  10. data/lib/chef/http/ssl_policies.rb +2 -2
  11. data/lib/chef/mixin/homebrew_user.rb +12 -5
  12. data/lib/chef/mixin/proxified_socket.rb +1 -1
  13. data/lib/chef/monkey_patches/net-http.rb +127 -0
  14. data/lib/chef/node/attribute_collections.rb +8 -0
  15. data/lib/chef/node/immutable_collections.rb +5 -2
  16. data/lib/chef/node/mixin/state_tracking.rb +1 -1
  17. data/lib/chef/platform/query_helpers.rb +4 -2
  18. data/lib/chef/provider/launchd.rb +1 -1
  19. data/lib/chef/provider/mount/linux.rb +1 -1
  20. data/lib/chef/provider/mount/mount.rb +5 -5
  21. data/lib/chef/provider/package/chocolatey.rb +18 -1
  22. data/lib/chef/provider/package/zypper.rb +1 -0
  23. data/lib/chef/provider/remote_file/http.rb +1 -1
  24. data/lib/chef/provider/yum_repository.rb +1 -1
  25. data/lib/chef/resource/apt_repository.rb +25 -6
  26. data/lib/chef/resource/homebrew_cask.rb +6 -7
  27. data/lib/chef/resource/homebrew_package.rb +1 -1
  28. data/lib/chef/resource/homebrew_tap.rb +5 -5
  29. data/lib/chef/resource/launchd.rb +5 -1
  30. data/lib/chef/resource/macos_userdefaults.rb +9 -5
  31. data/lib/chef/resource/selinux_login.rb +129 -0
  32. data/lib/chef/resource/selinux_user.rb +137 -0
  33. data/lib/chef/resource/windows_certificate.rb +1 -1
  34. data/lib/chef/resource/windows_security_policy.rb +2 -2
  35. data/lib/chef/resource.rb +11 -1
  36. data/lib/chef/resources.rb +2 -0
  37. data/lib/chef/version.rb +1 -1
  38. data/lib/chef/win32/security.rb +7 -1
  39. data/spec/data/trusted_certs/intermediate.pem +38 -27
  40. data/spec/data/trusted_certs/opscode.pem +33 -54
  41. data/spec/functional/resource/chocolatey_package_spec.rb +32 -20
  42. data/spec/functional/resource/execute_spec.rb +1 -1
  43. data/spec/functional/resource/macos_userdefaults_spec.rb +4 -4
  44. data/spec/functional/resource/windows_certificate_spec.rb +25 -0
  45. data/spec/unit/client_spec.rb +2 -2
  46. data/spec/unit/mixin/homebrew_user_spec.rb +30 -7
  47. data/spec/unit/node/vivid_mash_spec.rb +42 -0
  48. data/spec/unit/provider/apt_repository_spec.rb +17 -7
  49. data/spec/unit/provider/launchd_spec.rb +2 -2
  50. data/spec/unit/provider/mount/aix_spec.rb +2 -2
  51. data/spec/unit/provider/mount/linux_spec.rb +6 -5
  52. data/spec/unit/provider/mount/mount_spec.rb +8 -8
  53. data/spec/unit/provider/package/chocolatey_spec.rb +19 -3
  54. data/spec/unit/provider/package/rpm_spec.rb +2 -2
  55. data/spec/unit/provider/package/zypper_spec.rb +10 -0
  56. data/spec/unit/provider/remote_file/http_spec.rb +4 -4
  57. data/spec/unit/resource/apt_repository_spec.rb +5 -0
  58. data/spec/unit/resource/macos_user_defaults_spec.rb +4 -4
  59. data/spec/unit/resource/selinux_login_spec.rb +73 -0
  60. data/spec/unit/resource/selinux_user_spec.rb +92 -0
  61. data/spec/unit/resource_spec.rb +86 -0
  62. metadata +22 -17
  63. data/lib/chef/powershell.rb +0 -81
  64. /data/spec/functional/assets/chocolatey_feed/{test-A.1.0.nupkg → test-A.1.0.0.nupkg} +0 -0
  65. /data/spec/functional/assets/chocolatey_feed/{test-A.1.5.nupkg → test-A.1.5.0.nupkg} +0 -0
  66. /data/spec/functional/assets/chocolatey_feed/{test-A.2.0.nupkg → test-A.2.0.0.nupkg} +0 -0
  67. /data/spec/functional/assets/chocolatey_feed/{test-B.1.0.nupkg → test-B.1.0.0.nupkg} +0 -0
@@ -0,0 +1,92 @@
1
+ #
2
+ # Copyright:: Copyright (c) Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+
20
+ describe Chef::Resource::SelinuxUser do
21
+ let(:node) { Chef::Node.new }
22
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
23
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
24
+ let(:resource) { Chef::Resource::SelinuxUser.new("fakey_fakerton", run_context) }
25
+ let(:provider) { resource.provider_for_action(:manage) }
26
+ let(:semanage_list) { double("shellout", stdout: "") }
27
+
28
+ it "sets user property as name_property" do
29
+ expect(resource.user).to eql("fakey_fakerton")
30
+ end
31
+
32
+ it "sets the default action as :manage" do
33
+ expect(resource.action).to eql([:manage])
34
+ end
35
+
36
+ it "supports :manage, :add, :modify, :delete actions" do
37
+ expect { resource.action :manage }.not_to raise_error
38
+ expect { resource.action :add }.not_to raise_error
39
+ expect { resource.action :modify }.not_to raise_error
40
+ expect { resource.action :delete }.not_to raise_error
41
+ end
42
+
43
+ it "sorts roles property values" do
44
+ expect { resource.roles %w{c a b} }.not_to raise_error
45
+ expect(resource.roles).to eq(%w{a b c})
46
+ end
47
+
48
+ describe "#semanage_user_args" do
49
+ let(:provider) { resource.provider_for_action(:modify) }
50
+
51
+ context "when no parameters are provided" do
52
+ it "returns an empty string" do
53
+ expect(provider.semanage_user_args).to eq("")
54
+ end
55
+ end
56
+
57
+ context "when all parameters are provided" do
58
+ it "returns all params" do
59
+ resource.level "s0"
60
+ resource.range "s0"
61
+ resource.roles %w{sysadm_r staff_r}
62
+ expect(provider.semanage_user_args).to eq(" -L s0 -r s0 -R 'staff_r sysadm_r'")
63
+ end
64
+ end
65
+
66
+ context "when no roles are provided" do
67
+ it "returns level and range params" do
68
+ resource.level "s0"
69
+ resource.range "s0"
70
+ resource.roles []
71
+
72
+ expect(provider.semanage_user_args).to eq(" -L s0 -r s0")
73
+ end
74
+ end
75
+
76
+ context "when no range is provided" do
77
+ it "returns level and roles params" do
78
+ resource.level "s0"
79
+ resource.roles %w{sysadm_r staff_r}
80
+ expect(provider.semanage_user_args).to eq(" -L s0 -R 'staff_r sysadm_r'")
81
+ end
82
+ end
83
+
84
+ context "when no level is provided" do
85
+ it "returns range and roles params" do
86
+ resource.range "s0"
87
+ resource.roles %w{sysadm_r staff_r}
88
+ expect(provider.semanage_user_args).to eq(" -r s0 -R 'staff_r sysadm_r'")
89
+ end
90
+ end
91
+ end
92
+ end
@@ -803,6 +803,92 @@ describe Chef::Resource do
803
803
  end
804
804
  end
805
805
 
806
+ describe "when using resource partials" do
807
+ let(:resource_using_core_partial) do
808
+ Class.new(Chef::Resource) do
809
+ use "core::core_partial"
810
+ end
811
+ end
812
+
813
+ let(:resource_using_cookbook_partial) do
814
+ Class.new(Chef::Resource) do
815
+ use "my_local_partial"
816
+ end
817
+ end
818
+
819
+ let(:resource_using_nested_partials) do
820
+ FakeCaller = Struct.new(:label, :path, keyword_init: true)
821
+ NonDynamicResource = Chef::Resource.dup
822
+
823
+ # Fake a caller_locations array, as RSpec uses a different execution path
824
+ NonDynamicResource.define_singleton_method(:caller_locations) do
825
+ [
826
+ FakeCaller.new(label: "use", path: File.join(__dir__, "resource.rb")),
827
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
828
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level3_partial.rb")),
829
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
830
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level2_partial.rb")),
831
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
832
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level1_partial.rb")),
833
+ FakeCaller.new(label: "noise", path: File.join(__dir__, "no_file")),
834
+ FakeCaller.new(label: "class_from_file", path: File.join(__dir__, "_level0_partial.rb")),
835
+ ]
836
+ end
837
+
838
+ Class.new(NonDynamicResource) do
839
+ use "level3_partial"
840
+ end
841
+ end
842
+
843
+ it "correcly includes a core partial" do
844
+ expected_path = File.expand_path(File.join(__dir__, "../..", "lib/chef", "resource/_core_partial.rb"))
845
+ partial = "property :addon_property, default: true"
846
+
847
+ expect(IO).to receive(:read).with(expected_path).and_return(partial)
848
+ expect(resource_using_core_partial.properties.keys).to include(:addon_property)
849
+ end
850
+
851
+ it "correctly includes a cookbook partial" do
852
+ expected_path = File.expand_path(File.join(__dir__, "_my_local_partial.rb"))
853
+ partial = "property :addon_property, default: true"
854
+
855
+ expect(IO).to receive(:read).with(expected_path).and_return(partial)
856
+ expect(resource_using_cookbook_partial.properties.keys).to include(:addon_property)
857
+ end
858
+
859
+ it "correctly includes nested partials" do
860
+ level0_path = File.expand_path(File.join(__dir__, "_level0_partial.rb"))
861
+ level0_partial = "property :level0_property, default: true"
862
+ expect(IO).to receive(:read).with(level0_path).and_return(level0_partial)
863
+
864
+ level1_path = File.expand_path(File.join(__dir__, "_level1_partial.rb"))
865
+ level1_partial = <<-EOF
866
+ use 'level0_partial'
867
+ property :level1_property, default: true
868
+ EOF
869
+ expect(IO).to receive(:read).with(level1_path).and_return(level1_partial)
870
+
871
+ level2_path = File.expand_path(File.join(__dir__, "_level2_partial.rb"))
872
+ level2_partial = <<-EOF
873
+ use 'level1_partial'
874
+ property :level2_property, default: true
875
+ EOF
876
+ expect(IO).to receive(:read).with(level2_path).and_return(level2_partial)
877
+
878
+ level3_path = File.expand_path(File.join(__dir__, "_level3_partial.rb"))
879
+ level3_partial = <<-EOF
880
+ use 'level2_partial'
881
+ property :level3_property, default: true
882
+ EOF
883
+ expect(IO).to receive(:read).with(level3_path).and_return(level3_partial)
884
+
885
+ expect(resource_using_nested_partials.properties.keys).to include(:level0_property)
886
+ expect(resource_using_nested_partials.properties.keys).to include(:level1_property)
887
+ expect(resource_using_nested_partials.properties.keys).to include(:level2_property)
888
+ expect(resource_using_nested_partials.properties.keys).to include(:level3_property)
889
+ end
890
+ end
891
+
806
892
  describe "should_skip?" do
807
893
  before do
808
894
  resource = Chef::Resource::Cat.new("sugar", run_context)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.1.29
4
+ version: 18.3.0
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 18.1.29
19
+ version: 18.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 18.1.29
26
+ version: 18.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef-utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 18.1.29
33
+ version: 18.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 18.1.29
40
+ version: 18.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: train-core
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -336,20 +336,20 @@ dependencies:
336
336
  requirements:
337
337
  - - "~>"
338
338
  - !ruby/object:Gem::Version
339
- version: '1.1'
339
+ version: '1.0'
340
340
  - - ">="
341
341
  - !ruby/object:Gem::Version
342
- version: 1.1.3
342
+ version: 1.0.3
343
343
  type: :runtime
344
344
  prerelease: false
345
345
  version_requirements: !ruby/object:Gem::Requirement
346
346
  requirements:
347
347
  - - "~>"
348
348
  - !ruby/object:Gem::Version
349
- version: '1.1'
349
+ version: '1.0'
350
350
  - - ">="
351
351
  - !ruby/object:Gem::Version
352
- version: 1.1.3
352
+ version: 1.0.3
353
353
  - !ruby/object:Gem::Dependency
354
354
  name: chef-zero
355
355
  requirement: !ruby/object:Gem::Requirement
@@ -710,14 +710,14 @@ dependencies:
710
710
  requirements:
711
711
  - - "~>"
712
712
  - !ruby/object:Gem::Version
713
- version: 1.0.12
713
+ version: 18.1.0
714
714
  type: :runtime
715
715
  prerelease: false
716
716
  version_requirements: !ruby/object:Gem::Requirement
717
717
  requirements:
718
718
  - - "~>"
719
719
  - !ruby/object:Gem::Version
720
- version: 1.0.12
720
+ version: 18.1.0
721
721
  description: A systems integration framework, built to bring the benefits of configuration
722
722
  management to your entire infrastructure.
723
723
  email: adam@chef.io
@@ -734,6 +734,7 @@ files:
734
734
  - Rakefile
735
735
  - chef-universal-mingw-ucrt.gemspec
736
736
  - chef.gemspec
737
+ - distro/powershell/chef/chef.psm1
737
738
  - distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll
738
739
  - distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll
739
740
  - distro/ruby_bin_folder/AMD64/Ijwhost.dll
@@ -1649,6 +1650,7 @@ files:
1649
1650
  - lib/chef/mixin/windows_env_helper.rb
1650
1651
  - lib/chef/mixin/xml_escape.rb
1651
1652
  - lib/chef/mixins.rb
1653
+ - lib/chef/monkey_patches/net-http.rb
1652
1654
  - lib/chef/monkey_patches/webrick-utils.rb
1653
1655
  - lib/chef/monkey_patches/win32/registry.rb
1654
1656
  - lib/chef/monologger.rb
@@ -1679,7 +1681,6 @@ files:
1679
1681
  - lib/chef/policy_builder/dynamic.rb
1680
1682
  - lib/chef/policy_builder/expand_node_object.rb
1681
1683
  - lib/chef/policy_builder/policyfile.rb
1682
- - lib/chef/powershell.rb
1683
1684
  - lib/chef/property.rb
1684
1685
  - lib/chef/provider.rb
1685
1686
  - lib/chef/provider/batch.rb
@@ -1954,10 +1955,12 @@ files:
1954
1955
  - lib/chef/resource/selinux_boolean.rb
1955
1956
  - lib/chef/resource/selinux_fcontext.rb
1956
1957
  - lib/chef/resource/selinux_install.rb
1958
+ - lib/chef/resource/selinux_login.rb
1957
1959
  - lib/chef/resource/selinux_module.rb
1958
1960
  - lib/chef/resource/selinux_permissive.rb
1959
1961
  - lib/chef/resource/selinux_port.rb
1960
1962
  - lib/chef/resource/selinux_state.rb
1963
+ - lib/chef/resource/selinux_user.rb
1961
1964
  - lib/chef/resource/service.rb
1962
1965
  - lib/chef/resource/smartos_package.rb
1963
1966
  - lib/chef/resource/snap_package.rb
@@ -2504,10 +2507,10 @@ files:
2504
2507
  - spec/functional/assets/PkgA.1.0.0.0.bff
2505
2508
  - spec/functional/assets/PkgA.2.0.0.0.bff
2506
2509
  - spec/functional/assets/chefinittest
2507
- - spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg
2508
- - spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg
2509
- - spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg
2510
- - spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg
2510
+ - spec/functional/assets/chocolatey_feed/test-A.1.0.0.nupkg
2511
+ - spec/functional/assets/chocolatey_feed/test-A.1.5.0.nupkg
2512
+ - spec/functional/assets/chocolatey_feed/test-A.2.0.0.nupkg
2513
+ - spec/functional/assets/chocolatey_feed/test-B.1.0.0.nupkg
2511
2514
  - spec/functional/assets/dummy-1-0.aix6.1.noarch.rpm
2512
2515
  - spec/functional/assets/dummy-2-0.aix6.1.noarch.rpm
2513
2516
  - spec/functional/assets/inittest
@@ -3116,10 +3119,12 @@ files:
3116
3119
  - spec/unit/resource/selinux_boolean_spec.rb
3117
3120
  - spec/unit/resource/selinux_fcontext_spec.rb
3118
3121
  - spec/unit/resource/selinux_install_spec.rb
3122
+ - spec/unit/resource/selinux_login_spec.rb
3119
3123
  - spec/unit/resource/selinux_module_spec.rb
3120
3124
  - spec/unit/resource/selinux_permissive_spec.rb
3121
3125
  - spec/unit/resource/selinux_port_spec.rb
3122
3126
  - spec/unit/resource/selinux_state_spec.rb
3127
+ - spec/unit/resource/selinux_user_spec.rb
3123
3128
  - spec/unit/resource/service_spec.rb
3124
3129
  - spec/unit/resource/smartos_package_spec.rb
3125
3130
  - spec/unit/resource/snap_package_spec.rb
@@ -1,81 +0,0 @@
1
- #
2
- # Author:: Stuart Preston (<stuart@chef.io>)
3
- # Copyright:: Copyright (c) Chef Software Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- require "ffi" unless defined?(FFI)
19
- require_relative "json_compat"
20
-
21
- class Chef
22
- class PowerShell
23
- extend FFI::Library
24
-
25
- attr_reader :result
26
- attr_reader :errors
27
- attr_reader :verbose
28
-
29
- # Run a command under PowerShell via FFI
30
- # This implementation requires the managed dll and native wrapper to be in the library search
31
- # path on Windows (i.e. c:\windows\system32 or in the same location as ruby.exe).
32
- #
33
- # Requires: .NET Framework 4.0 or higher on the target machine.
34
- #
35
- # @param script [String] script to run
36
- # @param timeout [Integer, nil] timeout in seconds.
37
- # @return [Object] output
38
- def initialize(script, timeout: -1)
39
- # This Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
40
- # Every merge into that repo triggers a Habitat build and promotion. Running
41
- # the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down
42
- # the built packages and copy the binaries to distro/ruby_bin_folder. Bundle install
43
- # ensures that the correct architecture binaries are installed into the path.
44
- @dll ||= "Chef.PowerShell.Wrapper.dll"
45
- exec(script, timeout: timeout)
46
- end
47
-
48
- #
49
- # Was there an error running the command
50
- #
51
- # @return [Boolean]
52
- #
53
- def error?
54
- return true if errors.count > 0
55
-
56
- false
57
- end
58
-
59
- class CommandFailed < RuntimeError; end
60
-
61
- #
62
- # @raise [Chef::PowerShell::CommandFailed] raise if the command failed
63
- #
64
- def error!
65
- raise Chef::PowerShell::CommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
66
- end
67
-
68
- private
69
-
70
- def exec(script, timeout: -1)
71
- FFI.ffi_lib @dll
72
- FFI.attach_function :execute_powershell, :ExecuteScript, %i{string int}, :pointer
73
- timeout = -1 if timeout == 0 || timeout.nil?
74
- execution = FFI.execute_powershell(script, timeout).read_utf16string
75
- hashed_outcome = Chef::JSONCompat.parse(execution)
76
- @result = Chef::JSONCompat.parse(hashed_outcome["result"])
77
- @errors = hashed_outcome["errors"]
78
- @verbose = hashed_outcome["verbose"]
79
- end
80
- end
81
- end