chef 16.7.61-universal-mingw32 → 16.8.9-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/README.md +1 -1
  4. data/chef.gemspec +2 -1
  5. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.Wrapper.dll +0 -0
  6. data/distro/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
  7. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  8. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  9. data/distro/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  10. data/distro/ruby_bin_folder/x86/Chef.PowerShell.dll +0 -0
  11. data/distro/ruby_bin_folder/x86/Chef.Powershell.Wrapper.dll +0 -0
  12. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
  13. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.dll +0 -0
  14. data/distro/ruby_bin_folder/x86/shared/Microsoft.NETCore.App/5.0.0/Chef.Powershell.Core.pdb +0 -0
  15. data/lib/chef/application/base.rb +1 -1
  16. data/lib/chef/client.rb +3 -0
  17. data/lib/chef/compliance/default_attributes.rb +89 -0
  18. data/lib/chef/compliance/fetcher/automate.rb +69 -0
  19. data/lib/chef/compliance/fetcher/chef_server.rb +134 -0
  20. data/lib/chef/compliance/reporter/automate.rb +202 -0
  21. data/lib/chef/compliance/reporter/chef_server_automate.rb +92 -0
  22. data/lib/chef/compliance/reporter/compliance_enforcer.rb +20 -0
  23. data/lib/chef/compliance/reporter/json_file.rb +19 -0
  24. data/lib/chef/compliance/runner.rb +250 -0
  25. data/lib/chef/cookbook_manifest.rb +1 -0
  26. data/lib/chef/encrypted_data_bag_item/assertions.rb +1 -1
  27. data/lib/chef/exceptions.rb +4 -0
  28. data/lib/chef/http/ssl_policies.rb +6 -0
  29. data/lib/chef/knife/bootstrap/train_connector.rb +1 -1
  30. data/lib/chef/knife/core/ui.rb +4 -1
  31. data/lib/chef/knife/ssh.rb +1 -1
  32. data/lib/chef/mixin/powershell_exec.rb +3 -1
  33. data/lib/chef/platform/query_helpers.rb +4 -4
  34. data/lib/chef/powershell.rb +2 -0
  35. data/lib/chef/provider/dsc_resource.rb +12 -24
  36. data/lib/chef/provider/dsc_script.rb +16 -20
  37. data/lib/chef/provider/git.rb +5 -5
  38. data/lib/chef/resource/chef_client_config.rb +1 -1
  39. data/lib/chef/resource/dsc_script.rb +8 -1
  40. data/lib/chef/resource/hostname.rb +3 -3
  41. data/lib/chef/resource/template.rb +2 -2
  42. data/lib/chef/resource/windows_certificate.rb +7 -1
  43. data/lib/chef/resource_collection/resource_set.rb +1 -1
  44. data/lib/chef/util/dsc/configuration_generator.rb +52 -11
  45. data/lib/chef/util/dsc/lcm_output_parser.rb +3 -4
  46. data/lib/chef/util/dsc/local_configuration_manager.rb +17 -14
  47. data/lib/chef/util/dsc/resource_store.rb +5 -11
  48. data/lib/chef/version.rb +1 -1
  49. data/lib/chef/win32/api/file.rb +4 -0
  50. data/spec/functional/resource/dsc_script_spec.rb +3 -6
  51. data/spec/integration/client/client_spec.rb +2 -1
  52. data/spec/integration/compliance/compliance_spec.rb +81 -0
  53. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -0
  54. data/spec/spec_helper.rb +1 -1
  55. data/spec/unit/client_spec.rb +1 -0
  56. data/spec/unit/compliance/fetcher/automate_spec.rb +134 -0
  57. data/spec/unit/compliance/fetcher/chef_server_spec.rb +93 -0
  58. data/spec/unit/compliance/reporter/automate_spec.rb +427 -0
  59. data/spec/unit/compliance/reporter/chef_server_automate_spec.rb +177 -0
  60. data/spec/unit/compliance/reporter/compliance_enforcer_spec.rb +48 -0
  61. data/spec/unit/compliance/runner_spec.rb +113 -0
  62. data/spec/unit/http/ssl_policies_spec.rb +11 -0
  63. data/spec/unit/knife/core/node_editor_spec.rb +1 -1
  64. data/spec/unit/mixin/powershell_exec_spec.rb +1 -1
  65. data/spec/unit/platform/query_helpers_spec.rb +11 -12
  66. data/spec/unit/provider/dsc_resource_spec.rb +10 -27
  67. data/spec/unit/provider/dsc_script_spec.rb +1 -1
  68. data/spec/unit/provider/mount/windows_spec.rb +1 -0
  69. data/spec/unit/provider/systemd_unit_spec.rb +1 -1
  70. data/spec/unit/resource/windows_certificate_spec.rb +12 -0
  71. data/spec/unit/util/dsc/configuration_generator_spec.rb +79 -0
  72. data/spec/unit/util/dsc/local_configuration_manager_spec.rb +27 -35
  73. metadata +37 -12
  74. data/lib/chef/util/powershell/cmdlet.rb +0 -169
  75. data/lib/chef/util/powershell/cmdlet_result.rb +0 -61
  76. data/spec/functional/util/powershell/cmdlet_spec.rb +0 -111
  77. data/spec/unit/util/powershell/cmdlet_spec.rb +0 -106
@@ -1,61 +0,0 @@
1
- #
2
- # Author:: Adam Edwards (<adamed@chef.io>)
3
- #
4
- # Copyright:: Copyright (c) Chef Software Inc.
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
-
19
- require_relative "../../json_compat"
20
-
21
- class Chef
22
- class Util
23
- class Powershell
24
- class CmdletResult
25
- attr_reader :output_format
26
-
27
- def initialize(status, streams, output_format)
28
- @status = status
29
- @output_format = output_format
30
- @streams = streams
31
- end
32
-
33
- def stdout
34
- @status.stdout
35
- end
36
-
37
- def stderr
38
- @status.stderr
39
- end
40
-
41
- def stream(name)
42
- @streams[name].read
43
- end
44
-
45
- def return_value
46
- if output_format == :object
47
- Chef::JSONCompat.parse(stream(:json))
48
- elsif output_format == :json
49
- stream(:json)
50
- else
51
- @status.stdout
52
- end
53
- end
54
-
55
- def succeeded?
56
- @succeeded = @status.status.exitstatus == 0
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,111 +0,0 @@
1
- #
2
- # Author:: Adam Edwards (<adamed@chef.io>)
3
- #
4
- # Copyright:: Copyright (c) Chef Software Inc.
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
-
19
- require "chef/json_compat"
20
- require "spec_helper"
21
-
22
- describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do
23
- before(:all) do
24
- @node = Chef::Node.new
25
- @node.consume_external_attrs(OHAI_SYSTEM.data, {})
26
- end
27
- let(:cmd_output_format) { :text }
28
- let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, { depth: 2 }) }
29
- let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) }
30
- let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, { depth: 2 }) }
31
- let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, { depth: 2 }) }
32
- let(:etc_directory) { "#{ENV["systemroot"]}\\system32\\drivers\\etc" }
33
- let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE") }
34
-
35
- it "executes a simple process" do
36
- result = simple_cmdlet.run
37
- expect(result.succeeded?).to eq(true)
38
- end
39
-
40
- it "#run does not raise a PowershellCmdletException exception if the command cannot be executed" do
41
- expect { invalid_cmdlet.run }.not_to raise_error
42
- end
43
-
44
- it "#run! raises a PowershellCmdletException exception if the command cannot be executed" do
45
- expect { invalid_cmdlet.run! }.to raise_error(Chef::Exceptions::PowershellCmdletException)
46
- end
47
-
48
- it "executes a 64-bit command on a 64-bit OS, 32-bit otherwise" do
49
- os_arch = ENV["PROCESSOR_ARCHITEW6432"]
50
- if os_arch.nil?
51
- os_arch = ENV["PROCESSOR_ARCHITECTURE"]
52
- end
53
-
54
- result = architecture_cmdlet.run
55
- execution_arch = result.return_value
56
- execution_arch.strip!
57
- expect(execution_arch).to eq(os_arch)
58
- end
59
-
60
- it "passes command line switches to the command" do
61
- result = cmdlet_alias_requires_switch_or_argument.run({ name: "ls" })
62
- expect(result.succeeded?).to eq(true)
63
- end
64
-
65
- it "passes command line arguments to the command" do
66
- result = cmdlet_alias_requires_switch_or_argument.run({}, {}, "ls")
67
- expect(result.succeeded?).to eq(true)
68
- end
69
-
70
- it "passes command line arguments and switches to the command" do
71
- result = cmdlet_get_item_requires_switch_or_argument.run({ path: etc_directory }, {}, " | select-object -property fullname | format-table -hidetableheaders")
72
- expect(result.succeeded?).to eq(true)
73
- returned_directory = result.return_value
74
- returned_directory.strip!
75
- expect(returned_directory).to eq(etc_directory)
76
- end
77
-
78
- it "passes execution options to the command" do
79
- result = cmdlet_get_item_requires_switch_or_argument.run({}, { cwd: etc_directory }, ". | select-object -property fullname | format-table -hidetableheaders")
80
- expect(result.succeeded?).to eq(true)
81
- returned_directory = result.return_value
82
- returned_directory.strip!
83
- expect(returned_directory).to eq(etc_directory)
84
- end
85
-
86
- context "when returning json" do
87
- let(:cmd_output_format) { :json }
88
- it "returns json format data" do
89
- result = cmdlet_alias_requires_switch_or_argument.run({}, {}, "ls")
90
- expect(result.succeeded?).to eq(true)
91
- expect { Chef::JSONCompat.parse(result.return_value) }.not_to raise_error
92
- end
93
- end
94
-
95
- context "when returning Ruby objects" do
96
- let(:cmd_output_format) { :object }
97
- it "returns object format data" do
98
- result = simple_cmdlet.run({}, { cwd: etc_directory }, "hosts")
99
- expect(result.succeeded?).to eq(true)
100
- data = result.return_value
101
- expect(data["Name"]).to eq("hosts")
102
- end
103
- end
104
-
105
- context "when constructor is given invalid arguments" do
106
- let(:cmd_output_format) { :invalid }
107
- it "throws an exception if an invalid format is passed to the constructor" do
108
- expect { simple_cmdlet }.to raise_error(ArgumentError)
109
- end
110
- end
111
- end
@@ -1,106 +0,0 @@
1
- #
2
- # Author:: Jay Mundrawala <jdm@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
-
19
- require "chef"
20
- require "chef/util/powershell/cmdlet"
21
-
22
- describe Chef::Util::Powershell::Cmdlet do
23
- before (:all) do
24
- @node = Chef::Node.new
25
- @cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Some-Commandlet")
26
- end
27
-
28
- describe "#validate_switch_name!" do
29
- it "should not raise an error if a name contains all upper case letters" do
30
- @cmdlet.send(:validate_switch_name!, "HELLO")
31
- end
32
-
33
- it "should not raise an error if the name contains all lower case letters" do
34
- @cmdlet.send(:validate_switch_name!, "hello")
35
- end
36
-
37
- it "should not raise an error if no special characters are used except _" do
38
- @cmdlet.send(:validate_switch_name!, "hello_world")
39
- end
40
-
41
- %w{! @ # $ % ^ & * & * ( ) - = + \{ \} . ? < > \\ /}.each do |sym|
42
- it "raises an Argument error if it configuration name contains #{sym}" do
43
- expect do
44
- @cmdlet.send(:validate_switch_name!, "Hello#{sym}")
45
- end.to raise_error(ArgumentError)
46
- end
47
- end
48
- end
49
-
50
- describe "#escape_parameter_value" do
51
- # Is this list really complete?
52
- %w{` " # '}.each do |c|
53
- it "escapse #{c}" do
54
- expect(@cmdlet.send(:escape_parameter_value, "stuff #{c}")).to eql("stuff `#{c}")
55
- end
56
- end
57
-
58
- it "does not do anything to a string without special characters" do
59
- expect(@cmdlet.send(:escape_parameter_value, "stuff")).to eql("stuff")
60
- end
61
- end
62
-
63
- describe "#escape_string_parameter_value" do
64
- it "surrounds a string with ''" do
65
- expect(@cmdlet.send(:escape_string_parameter_value, "stuff")).to eql("'stuff'")
66
- end
67
- end
68
-
69
- describe "#command_switches_string" do
70
- it "raises an ArgumentError if the key is not a symbol" do
71
- expect do
72
- @cmdlet.send(:command_switches_string, { "foo" => "bar" })
73
- end.to raise_error(ArgumentError)
74
- end
75
-
76
- it "does not allow invalid switch names" do
77
- expect do
78
- @cmdlet.send(:command_switches_string, { foo!: "bar" })
79
- end.to raise_error(ArgumentError)
80
- end
81
-
82
- it "ignores switches with a false value" do
83
- expect(@cmdlet.send(:command_switches_string, { foo: false })).to eql("")
84
- end
85
-
86
- it "should correctly handle a value type of string" do
87
- expect(@cmdlet.send(:command_switches_string, { foo: "bar" })).to eql("-foo 'bar'")
88
- end
89
-
90
- it "should correctly handle a value type of string even when it is 0 length" do
91
- expect(@cmdlet.send(:command_switches_string, { foo: "" })).to eql("-foo ''")
92
- end
93
-
94
- it "should not quote integers" do
95
- expect(@cmdlet.send(:command_switches_string, { foo: 1 })).to eql("-foo 1")
96
- end
97
-
98
- it "should not quote floats" do
99
- expect(@cmdlet.send(:command_switches_string, { foo: 1.0 })).to eql("-foo 1.0")
100
- end
101
-
102
- it "has just the switch when the value is true" do
103
- expect(@cmdlet.send(:command_switches_string, { foo: true })).to eql("-foo")
104
- end
105
- end
106
- end