chef 17.0.242-universal-mingw32 → 17.4.25-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -14
  3. data/Rakefile +2 -2
  4. data/chef.gemspec +10 -20
  5. data/lib/chef/action_collection.rb +6 -26
  6. data/lib/chef/application/base.rb +15 -0
  7. data/lib/chef/application.rb +4 -2
  8. data/lib/chef/chef_fs/file_pattern.rb +2 -2
  9. data/lib/chef/client.rb +7 -1
  10. data/lib/chef/compliance/default_attributes.rb +5 -3
  11. data/lib/chef/compliance/reporter/automate.rb +1 -1
  12. data/lib/chef/compliance/runner.rb +17 -3
  13. data/lib/chef/cookbook/cookbook_version_loader.rb +3 -3
  14. data/lib/chef/cookbook/gem_installer.rb +5 -1
  15. data/lib/chef/cookbook_version.rb +26 -4
  16. data/lib/chef/data_collector/run_end_message.rb +1 -1
  17. data/lib/chef/data_collector.rb +0 -1
  18. data/lib/chef/deprecated.rb +14 -4
  19. data/lib/chef/dsl/declare_resource.rb +5 -10
  20. data/lib/chef/dsl/render_helpers.rb +44 -0
  21. data/lib/chef/dsl/secret.rb +64 -0
  22. data/lib/chef/dsl/toml.rb +116 -0
  23. data/lib/chef/dsl/universal.rb +5 -0
  24. data/lib/chef/dsl.rb +1 -0
  25. data/lib/chef/event_dispatch/base.rb +2 -1
  26. data/lib/chef/exceptions.rb +23 -0
  27. data/lib/chef/formatters/doc.rb +2 -1
  28. data/lib/chef/formatters/error_mapper.rb +2 -2
  29. data/lib/chef/handler/slow_report.rb +66 -0
  30. data/lib/chef/handler.rb +46 -8
  31. data/lib/chef/json_compat.rb +1 -1
  32. data/lib/chef/node.rb +21 -20
  33. data/lib/chef/policy_builder/policyfile.rb +88 -45
  34. data/lib/chef/provider/directory.rb +6 -6
  35. data/lib/chef/provider/execute.rb +1 -1
  36. data/lib/chef/provider/file.rb +2 -2
  37. data/lib/chef/provider/group/dscl.rb +1 -1
  38. data/lib/chef/provider/launchd.rb +6 -6
  39. data/lib/chef/provider/link.rb +1 -1
  40. data/lib/chef/provider/lwrp_base.rb +1 -1
  41. data/lib/chef/provider/package/dnf/dnf_helper.py +11 -10
  42. data/lib/chef/provider/package/dnf/python_helper.rb +9 -8
  43. data/lib/chef/provider/package/habitat.rb +168 -0
  44. data/lib/chef/provider/package/powershell.rb +5 -0
  45. data/lib/chef/provider/package/yum/python_helper.rb +15 -10
  46. data/lib/chef/provider/package/yum/yum_helper.py +46 -62
  47. data/lib/chef/provider/package/yum.rb +1 -4
  48. data/lib/chef/provider/registry_key.rb +1 -1
  49. data/lib/chef/provider/service/systemd.rb +1 -1
  50. data/lib/chef/provider/subversion.rb +4 -4
  51. data/lib/chef/provider/support/yum_repo.erb +1 -1
  52. data/lib/chef/provider/support/zypper_repo.erb +4 -2
  53. data/lib/chef/provider/systemd_unit.rb +18 -17
  54. data/lib/chef/provider/template/content.rb +1 -1
  55. data/lib/chef/provider/user/mac.rb +3 -3
  56. data/lib/chef/provider/windows_script.rb +1 -1
  57. data/lib/chef/provider/yum_repository.rb +27 -43
  58. data/lib/chef/provider/zypper_repository.rb +30 -34
  59. data/lib/chef/provider.rb +26 -1
  60. data/lib/chef/provider_resolver.rb +8 -2
  61. data/lib/chef/providers.rb +1 -0
  62. data/lib/chef/resource/alternatives.rb +5 -5
  63. data/lib/chef/resource/apt_preference.rb +2 -2
  64. data/lib/chef/resource/apt_repository.rb +2 -2
  65. data/lib/chef/resource/apt_update.rb +4 -4
  66. data/lib/chef/resource/build_essential.rb +1 -1
  67. data/lib/chef/resource/chef_client_config.rb +10 -5
  68. data/lib/chef/resource/chef_client_cron.rb +3 -3
  69. data/lib/chef/resource/chef_client_launchd.rb +3 -3
  70. data/lib/chef/resource/chef_client_scheduled_task.rb +15 -15
  71. data/lib/chef/resource/chef_client_systemd_timer.rb +3 -3
  72. data/lib/chef/resource/chef_client_trusted_certificate.rb +2 -2
  73. data/lib/chef/resource/chef_handler.rb +2 -2
  74. data/lib/chef/resource/chef_sleep.rb +1 -1
  75. data/lib/chef/resource/chef_vault_secret.rb +2 -2
  76. data/lib/chef/resource/chocolatey_feature.rb +2 -2
  77. data/lib/chef/resource/chocolatey_source.rb +1 -1
  78. data/lib/chef/resource/cron/cron_d.rb +4 -6
  79. data/lib/chef/resource/cron_access.rb +1 -1
  80. data/lib/chef/resource/dmg_package.rb +1 -1
  81. data/lib/chef/resource/dsc_resource.rb +1 -1
  82. data/lib/chef/resource/execute.rb +5 -5
  83. data/lib/chef/resource/gem_package.rb +2 -1
  84. data/lib/chef/resource/group.rb +4 -4
  85. data/lib/chef/resource/habitat/_habitat_shared.rb +28 -0
  86. data/lib/chef/resource/habitat/habitat_package.rb +129 -0
  87. data/lib/chef/resource/habitat/habitat_sup.rb +329 -0
  88. data/lib/chef/resource/habitat/habitat_sup_systemd.rb +67 -0
  89. data/lib/chef/resource/habitat/habitat_sup_windows.rb +90 -0
  90. data/lib/chef/resource/habitat_config.rb +107 -0
  91. data/lib/chef/resource/habitat_install.rb +247 -0
  92. data/lib/chef/resource/habitat_service.rb +451 -0
  93. data/lib/chef/resource/habitat_user_toml.rb +92 -0
  94. data/lib/chef/resource/homebrew_cask.rb +18 -7
  95. data/lib/chef/resource/homebrew_package.rb +1 -1
  96. data/lib/chef/resource/homebrew_tap.rb +4 -3
  97. data/lib/chef/resource/homebrew_update.rb +2 -2
  98. data/lib/chef/resource/hostname.rb +49 -7
  99. data/lib/chef/resource/inspec_waiver_file_entry.rb +156 -0
  100. data/lib/chef/resource/kernel_module.rb +6 -6
  101. data/lib/chef/resource/launchd.rb +3 -3
  102. data/lib/chef/resource/locale.rb +1 -1
  103. data/lib/chef/resource/lwrp_base.rb +18 -3
  104. data/lib/chef/resource/macos_userdefaults.rb +2 -2
  105. data/lib/chef/resource/ohai_hint.rb +2 -6
  106. data/lib/chef/resource/openbsd_package.rb +17 -0
  107. data/lib/chef/resource/openssl_dhparam.rb +1 -2
  108. data/lib/chef/resource/openssl_ec_private_key.rb +1 -3
  109. data/lib/chef/resource/openssl_ec_public_key.rb +1 -3
  110. data/lib/chef/resource/openssl_rsa_private_key.rb +1 -3
  111. data/lib/chef/resource/openssl_rsa_public_key.rb +1 -3
  112. data/lib/chef/resource/openssl_x509_certificate.rb +1 -4
  113. data/lib/chef/resource/openssl_x509_crl.rb +1 -3
  114. data/lib/chef/resource/openssl_x509_request.rb +1 -3
  115. data/lib/chef/resource/osx_profile.rb +3 -3
  116. data/lib/chef/resource/plist.rb +1 -1
  117. data/lib/chef/resource/powershell_package_source.rb +2 -4
  118. data/lib/chef/resource/reboot.rb +38 -9
  119. data/lib/chef/resource/remote_directory.rb +2 -2
  120. data/lib/chef/resource/remote_file.rb +3 -3
  121. data/lib/chef/resource/rhsm_errata.rb +0 -2
  122. data/lib/chef/resource/rhsm_errata_level.rb +1 -5
  123. data/lib/chef/resource/rhsm_repo.rb +15 -0
  124. data/lib/chef/resource/rhsm_subscription.rb +5 -5
  125. data/lib/chef/resource/ruby_block.rb +100 -0
  126. data/lib/chef/resource/scm/subversion.rb +1 -1
  127. data/lib/chef/resource/ssh_known_hosts_entry.rb +4 -7
  128. data/lib/chef/resource/sudo.rb +2 -6
  129. data/lib/chef/resource/support/HabService.dll.config.erb +19 -0
  130. data/lib/chef/resource/support/client.erb +8 -1
  131. data/lib/chef/resource/support/sup.toml.erb +179 -0
  132. data/lib/chef/resource/swap_file.rb +2 -6
  133. data/lib/chef/resource/sysctl.rb +2 -2
  134. data/lib/chef/resource/systemd_unit.rb +3 -3
  135. data/lib/chef/resource/timezone.rb +1 -1
  136. data/lib/chef/resource/user_ulimit.rb +2 -2
  137. data/lib/chef/resource/windows_ad_join.rb +2 -2
  138. data/lib/chef/resource/windows_audit_policy.rb +2 -2
  139. data/lib/chef/resource/windows_auto_run.rb +2 -2
  140. data/lib/chef/resource/windows_certificate.rb +1 -1
  141. data/lib/chef/resource/windows_defender.rb +163 -0
  142. data/lib/chef/resource/windows_defender_exclusion.rb +125 -0
  143. data/lib/chef/resource/windows_dfs_folder.rb +2 -2
  144. data/lib/chef/resource/windows_dfs_namespace.rb +2 -2
  145. data/lib/chef/resource/windows_dns_record.rb +2 -2
  146. data/lib/chef/resource/windows_dns_zone.rb +2 -2
  147. data/lib/chef/resource/windows_env.rb +1 -1
  148. data/lib/chef/resource/windows_feature.rb +3 -3
  149. data/lib/chef/resource/windows_feature_dism.rb +3 -5
  150. data/lib/chef/resource/windows_feature_powershell.rb +3 -3
  151. data/lib/chef/resource/windows_firewall_profile.rb +2 -2
  152. data/lib/chef/resource/windows_firewall_rule.rb +20 -6
  153. data/lib/chef/resource/windows_font.rb +2 -2
  154. data/lib/chef/resource/windows_pagefile.rb +104 -65
  155. data/lib/chef/resource/windows_path.rb +4 -4
  156. data/lib/chef/resource/windows_printer.rb +80 -61
  157. data/lib/chef/resource/windows_printer_port.rb +48 -65
  158. data/lib/chef/resource/windows_security_policy.rb +7 -4
  159. data/lib/chef/resource/windows_share.rb +2 -2
  160. data/lib/chef/resource/windows_shortcut.rb +1 -1
  161. data/lib/chef/resource/windows_task.rb +2 -2
  162. data/lib/chef/resource/windows_uac.rb +3 -5
  163. data/lib/chef/resource/windows_update_settings.rb +259 -0
  164. data/lib/chef/resource/windows_user_privilege.rb +2 -2
  165. data/lib/chef/resource/windows_workgroup.rb +2 -2
  166. data/lib/chef/resource/yum_package.rb +11 -15
  167. data/lib/chef/resource/zypper_package.rb +4 -4
  168. data/lib/chef/resource/zypper_repository.rb +28 -8
  169. data/lib/chef/resource.rb +20 -25
  170. data/lib/chef/resource_builder.rb +8 -2
  171. data/lib/chef/resource_inspector.rb +6 -2
  172. data/lib/chef/resource_reporter.rb +0 -1
  173. data/lib/chef/resources.rb +13 -1
  174. data/lib/chef/run_lock.rb +1 -1
  175. data/lib/chef/runner.rb +1 -1
  176. data/lib/chef/secret_fetcher/aws_secrets_manager.rb +65 -0
  177. data/lib/chef/secret_fetcher/azure_key_vault.rb +78 -0
  178. data/lib/chef/secret_fetcher/base.rb +76 -0
  179. data/lib/chef/secret_fetcher/example.rb +46 -0
  180. data/lib/chef/secret_fetcher.rb +55 -0
  181. data/lib/chef/shell/ext.rb +3 -3
  182. data/lib/chef/version.rb +1 -1
  183. data/lib/chef/win32/api.rb +9 -2
  184. data/spec/data/knife-home/.chef/plugins/knife/example_home_subcommand.rb +0 -0
  185. data/spec/data/knife-site-subcommands/plugins/knife/example_subcommand.rb +0 -0
  186. data/spec/data/knife_subcommand/test_explicit_category.rb +7 -0
  187. data/spec/data/knife_subcommand/test_name_mapping.rb +4 -0
  188. data/spec/data/knife_subcommand/test_yourself.rb +21 -0
  189. data/spec/functional/mixin/from_file_spec.rb +1 -1
  190. data/spec/functional/resource/dnf_package_spec.rb +857 -537
  191. data/spec/functional/resource/group_spec.rb +1 -1
  192. data/spec/functional/resource/link_spec.rb +1 -1
  193. data/spec/functional/resource/remote_file_spec.rb +1 -1
  194. data/spec/functional/resource/windows_env_spec.rb +2 -2
  195. data/spec/functional/resource/windows_hostname_spec.rb +91 -0
  196. data/spec/functional/resource/windows_pagefile_spec.rb +98 -0
  197. data/spec/functional/resource/yum_package_spec.rb +495 -428
  198. data/spec/integration/client/client_spec.rb +0 -20
  199. data/spec/integration/compliance/compliance_spec.rb +1 -0
  200. data/spec/integration/recipes/recipe_dsl_spec.rb +1 -1
  201. data/spec/integration/recipes/resource_action_spec.rb +6 -6
  202. data/spec/integration/recipes/unified_mode_spec.rb +70 -0
  203. data/spec/spec_helper.rb +3 -0
  204. data/spec/support/chef_helpers.rb +1 -1
  205. data/spec/support/shared/functional/execute_resource.rb +1 -1
  206. data/spec/support/shared/functional/knife.rb +37 -0
  207. data/spec/support/shared/integration/knife_support.rb +192 -0
  208. data/spec/support/shared/unit/knife_shared.rb +39 -0
  209. data/spec/support/shared/unit/provider/file.rb +3 -9
  210. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +1 -1
  211. data/spec/unit/compliance/runner_spec.rb +46 -2
  212. data/spec/unit/cookbook_version_spec.rb +52 -0
  213. data/spec/unit/data_collector_spec.rb +47 -1
  214. data/spec/unit/dsl/render_helpers_spec.rb +102 -0
  215. data/spec/unit/dsl/secret_spec.rb +71 -0
  216. data/spec/unit/handler_spec.rb +8 -2
  217. data/spec/unit/policy_builder/dynamic_spec.rb +0 -5
  218. data/spec/unit/policy_builder/policyfile_spec.rb +144 -56
  219. data/spec/unit/provider/apt_update_spec.rb +3 -1
  220. data/spec/unit/provider/link_spec.rb +1 -1
  221. data/spec/unit/provider/mount/aix_spec.rb +1 -1
  222. data/spec/unit/provider/package/dnf/python_helper_spec.rb +1 -0
  223. data/spec/unit/provider/package/powershell_spec.rb +74 -12
  224. data/spec/unit/provider/package/yum/python_helper_spec.rb +1 -0
  225. data/spec/unit/provider/service/systemd_service_spec.rb +2 -2
  226. data/spec/unit/provider/systemd_unit_spec.rb +2 -2
  227. data/spec/unit/provider/zypper_repository_spec.rb +3 -10
  228. data/spec/unit/provider_spec.rb +23 -0
  229. data/spec/unit/resource/homebrew_cask_spec.rb +29 -11
  230. data/spec/unit/resource/inspec_waiver_file_entry_spec.rb +80 -0
  231. data/spec/unit/resource/rhsm_subscription_spec.rb +50 -3
  232. data/spec/unit/resource/systemd_unit_spec.rb +1 -1
  233. data/spec/unit/resource/windows_defender_exclusion_spec.rb +62 -0
  234. data/spec/unit/resource/windows_defender_spec.rb +71 -0
  235. data/spec/unit/resource/windows_firewall_rule_spec.rb +12 -7
  236. data/spec/unit/resource/windows_pagefile_spec.rb +4 -9
  237. data/spec/unit/resource/windows_update_settings_spec.rb +64 -0
  238. data/spec/unit/resource/zypper_repository_spec.rb +1 -1
  239. data/spec/unit/resource_spec.rb +19 -8
  240. data/spec/unit/secret_fetcher/aws_secrets_manager_spec.rb +70 -0
  241. data/spec/unit/secret_fetcher/azure_key_vault_spec.rb +70 -0
  242. data/spec/unit/secret_fetcher_spec.rb +82 -0
  243. data/tasks/rspec.rb +4 -9
  244. metadata +65 -161
  245. data/lib/chef/provider/package/yum/simplejson/LICENSE.txt +0 -79
  246. data/lib/chef/provider/package/yum/simplejson/__init__.py +0 -318
  247. data/lib/chef/provider/package/yum/simplejson/__init__.pyc +0 -0
  248. data/lib/chef/provider/package/yum/simplejson/decoder.py +0 -354
  249. data/lib/chef/provider/package/yum/simplejson/decoder.pyc +0 -0
  250. data/lib/chef/provider/package/yum/simplejson/encoder.py +0 -440
  251. data/lib/chef/provider/package/yum/simplejson/encoder.pyc +0 -0
  252. data/lib/chef/provider/package/yum/simplejson/scanner.py +0 -65
  253. data/lib/chef/provider/package/yum/simplejson/scanner.pyc +0 -0
  254. data/lib/chef/provider/package/yum/simplejson/tool.py +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41c93beb21c79d39b06a7ae7939e826e5cd3f206993e883ee26ad048ca92d8fc
4
- data.tar.gz: bca43e03deba7211b7ac186b970db08d08d1568d4f58a0caf5600c86ffa11384
3
+ metadata.gz: b16e62ba7d28cff9fe62328af38e23c484ff0f7f4f6e8c8ea24c768fa2da78d4
4
+ data.tar.gz: 007b4a36cd90ec76ba99b61b1a8dda12687e20787f1e3611d37a81504a831e05
5
5
  SHA512:
6
- metadata.gz: 0326db2eedf4d75bd23467b9df9cee1eda1ebc5aad091d6d585b311699f64c50f09c7dd38214d0a09ad7467090d2d2b6046108fd8cdb43ce147e11a07212a561
7
- data.tar.gz: d91d49ddbb7efffefd6a416f7994a1a14c836478651a0b6a985d7e46b57e05b016ec327d94bf13d9ef886923c07602d2c0a08fb655da790dd4a8ca86e57d0043
6
+ metadata.gz: 9dd9c1790477e60242859ba4e0e7bed672e04702946aebd965fcc7bb31bf5ecb6e43eb8db6e44d55968760c2f2b8bc4cfc472072eb4f662b2c58eb031d04b651
7
+ data.tar.gz: 79249489f9347537dffa27bd7b8b152e2ebea6486d54c64a570a638fdf91c17c5e4079a37198ffea8b762bcf3572ff8d80631865cf5a21dfece9106c01dbbf63
data/Gemfile CHANGED
@@ -1,10 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Note we do not use the gemspec DSL which restricts to the
4
- # gemspec for the current platform and filters out other platforms
5
- # during a bundle lock operation. We actually want dependencies from
6
- # both of our gemspecs. Also note this this mimics gemspec behavior
7
- # of bundler versions prior to 1.12.0 (https://github.com/bundler/bundler/commit/193a14fe5e0d56294c7b370a0e59f93b2c216eed)
8
3
  gem "chef", path: "."
9
4
 
10
5
  gem "ohai", git: "https://github.com/chef/ohai.git", branch: "master"
@@ -22,8 +17,6 @@ end
22
17
 
23
18
  gem "cheffish", ">= 17"
24
19
 
25
- gem "chef-telemetry", ">=1.0.8" # 1.0.8 removes the http dep
26
-
27
20
  group(:omnibus_package) do
28
21
  gem "appbundler"
29
22
  gem "rb-readline"
@@ -32,17 +25,14 @@ group(:omnibus_package) do
32
25
  end
33
26
 
34
27
  group(:omnibus_package, :pry) do
35
- gem "pry"
28
+ # Locked because pry-byebug is broken with 13+.
29
+ # some work is ongoing? https://github.com/deivid-rodriguez/pry-byebug/issues/343
30
+ gem "pry", "= 0.13.0"
36
31
  # byebug does not install on freebsd on ruby 3.0
37
- # gem "pry-byebug"
32
+ gem "pry-byebug" unless RUBY_PLATFORM =~ /freebsd/i
38
33
  gem "pry-stack_explorer"
39
34
  end
40
35
 
41
- # Everything except AIX
42
- group(:ruby_prof) do
43
- gem "ruby-prof"
44
- end
45
-
46
36
  # Everything except AIX and Windows
47
37
  group(:ruby_shadow) do
48
38
  # if ruby-shadow does a release that supports ruby-3.0 this can be removed
data/Rakefile CHANGED
@@ -108,8 +108,8 @@ task :update_chef_exec_dll do
108
108
 
109
109
  sh("hab pkg install chef/chef-powershell-shim")
110
110
  sh("hab pkg install chef/chef-powershell-shim-x86")
111
- x64 = `hab pkg path chef/chef-powershell-shim`.chomp.tr('\\', "/")
112
- x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.tr('\\', "/")
111
+ x64 = `hab pkg path chef/chef-powershell-shim`.chomp.tr("\\", "/")
112
+ x86 = `hab pkg path chef/chef-powershell-shim-x86`.chomp.tr("\\", "/")
113
113
  FileUtils.rm_rf(Dir["distro/ruby_bin_folder/AMD64/*"])
114
114
  FileUtils.rm_rf(Dir["distro/ruby_bin_folder/x86/*"])
115
115
  puts "Copying #{x64}/bin/* to distro/ruby_bin_folder/AMD64"
data/chef.gemspec CHANGED
@@ -40,38 +40,28 @@ Gem::Specification.new do |s|
40
40
 
41
41
  s.add_dependency "ffi", ">= 1.5.0"
42
42
  s.add_dependency "ffi-yajl", "~> 2.2"
43
- s.add_dependency "net-ssh", ">= 5.1", "< 7"
44
- s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
45
- s.add_dependency "net-sftp", ">= 2.1.2", "< 4.0"
46
- s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
47
- s.add_dependency "bcrypt_pbkdf", "~> 1.1" # ed25519 ssh key support
48
- s.add_dependency "highline", ">= 1.6.9", "< 3"
49
- s.add_dependency "tty-prompt", "~> 0.21" # knife ui.ask prompt
50
- s.add_dependency "tty-screen", "~> 0.6" # knife list
51
- s.add_dependency "tty-table", "~> 0.11" # knife render table output.
52
- s.add_dependency "pastel" # knife ui.color
53
- s.add_dependency "erubis", "~> 2.7"
54
- s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output
55
- s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3"
43
+ s.add_dependency "net-sftp", ">= 2.1.2", "< 4.0" # remote_file resource
44
+ s.add_dependency "erubis", "~> 2.7" # template resource / cookbook syntax check
45
+ s.add_dependency "diff-lcs", ">= 1.2.4", "< 1.4.0" # 1.4 breaks output. Used in lib/chef/util/diff
46
+ s.add_dependency "ffi-libarchive", "~> 1.0", ">= 1.0.3" # archive_file resource
56
47
  s.add_dependency "chef-zero", ">= 14.0.11"
57
- s.add_dependency "chef-vault"
48
+ s.add_dependency "chef-vault" # chef-vault resources and helpers
58
49
 
59
- s.add_dependency "plist", "~> 3.2"
60
- s.add_dependency "iniparse", "~> 1.4"
50
+ s.add_dependency "plist", "~> 3.2" # launchd, dscl/mac user, macos_userdefaults, osx_profile and plist resources
51
+ s.add_dependency "iniparse", "~> 1.4" # systemd_unit resource
61
52
  s.add_dependency "addressable"
62
53
  s.add_dependency "syslog-logger", "~> 1.6"
63
- s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0"
54
+ s.add_dependency "uuidtools", ">= 2.1.5", "< 3.0" # osx_profile resource
64
55
 
65
56
  s.add_dependency "proxifier", "~> 1.0"
66
57
 
58
+ s.add_dependency "aws-sdk-secretsmanager", "~> 1.46"
67
59
  s.bindir = "bin"
68
60
  s.executables = %w{ }
69
61
 
70
62
  s.require_paths = %w{ lib }
71
63
  s.files = %w{Gemfile Rakefile LICENSE README.md} +
72
- Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject do |f|
73
- File.directory?(f) || File.path(f).match(/knife*/)
74
- end +
64
+ Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } +
75
65
  Dir.glob("*.gemspec") +
76
66
  Dir.glob("tasks/rspec.rb")
77
67
 
@@ -87,13 +87,11 @@ class Chef
87
87
  attr_reader :action_records
88
88
  attr_reader :pending_updates
89
89
  attr_reader :run_context
90
- attr_reader :consumers
91
90
  attr_reader :events
92
91
 
93
92
  def initialize(events, run_context = nil, action_records = [])
94
93
  @action_records = action_records
95
94
  @pending_updates = []
96
- @consumers = []
97
95
  @events = events
98
96
  @run_context = run_context
99
97
  end
@@ -118,17 +116,17 @@ class Chef
118
116
  self.class.new(events, run_context, subrecords)
119
117
  end
120
118
 
119
+ def resources
120
+ action_records.map(&:new_resource)
121
+ end
122
+
121
123
  # This hook gives us the run_context immediately after it is created so that we can wire up this object to it.
122
124
  #
123
- # This also causes the action_collection_registration event to fire, all consumers that have not yet registered with the
124
- # action_collection must register via this callback. This is the latest point before resources actually start to get
125
- # evaluated.
126
- #
127
125
  # (see EventDispatch::Base#)
128
126
  #
129
127
  def cookbook_compilation_start(run_context)
130
128
  run_context.action_collection = self
131
- # fire the action_colleciton_registration hook after cookbook_compilation_start -- last chance for consumers to register
129
+ # this hook is now poorly named since it is just a callback that lets other consumers snag a reference to the action_collection
132
130
  run_context.events.enqueue(:action_collection_registration, self)
133
131
  @run_context = run_context
134
132
  end
@@ -139,7 +137,7 @@ class Chef
139
137
  # @params object [Object] callers should call with `self`
140
138
  #
141
139
  def register(object)
142
- consumers << object
140
+ Chef::Log.warn "the action collection no longer requires registration at #{caller[0]}"
143
141
  end
144
142
 
145
143
  # End of an unsuccessful converge used to fire off detect_unprocessed_resources.
@@ -147,8 +145,6 @@ class Chef
147
145
  # (see EventDispatch::Base#)
148
146
  #
149
147
  def converge_failed(exception)
150
- return if consumers.empty?
151
-
152
148
  detect_unprocessed_resources
153
149
  end
154
150
 
@@ -159,8 +155,6 @@ class Chef
159
155
  # (see EventDispatch::Base#)
160
156
  #
161
157
  def resource_action_start(new_resource, action, notification_type = nil, notifier = nil)
162
- return if consumers.empty?
163
-
164
158
  pending_updates << ActionRecord.new(new_resource, action, pending_updates.length)
165
159
  end
166
160
 
@@ -170,8 +164,6 @@ class Chef
170
164
  # (see EventDispatch::Base#)
171
165
  #
172
166
  def resource_current_state_loaded(new_resource, action, current_resource)
173
- return if consumers.empty?
174
-
175
167
  current_record.current_resource = current_resource
176
168
  end
177
169
 
@@ -181,8 +173,6 @@ class Chef
181
173
  # (see EventDispatch::Base#)
182
174
  #
183
175
  def resource_after_state_loaded(new_resource, action, after_resource)
184
- return if consumers.empty?
185
-
186
176
  current_record.after_resource = after_resource
187
177
  end
188
178
 
@@ -191,8 +181,6 @@ class Chef
191
181
  # (see EventDispatch::Base#)
192
182
  #
193
183
  def resource_up_to_date(new_resource, action)
194
- return if consumers.empty?
195
-
196
184
  current_record.status = :up_to_date
197
185
  end
198
186
 
@@ -201,8 +189,6 @@ class Chef
201
189
  # (see EventDispatch::Base#)
202
190
  #
203
191
  def resource_skipped(resource, action, conditional)
204
- return if consumers.empty?
205
-
206
192
  current_record.status = :skipped
207
193
  current_record.conditional = conditional
208
194
  end
@@ -212,8 +198,6 @@ class Chef
212
198
  # (see EventDispatch::Base#)
213
199
  #
214
200
  def resource_updated(new_resource, action)
215
- return if consumers.empty?
216
-
217
201
  current_record.status = :updated
218
202
  end
219
203
 
@@ -222,8 +206,6 @@ class Chef
222
206
  # (see EventDispatch::Base#)
223
207
  #
224
208
  def resource_failed(new_resource, action, exception)
225
- return if consumers.empty?
226
-
227
209
  current_record.status = :failed
228
210
  current_record.exception = exception
229
211
  current_record.error_description = Formatters::ErrorMapper.resource_failed(new_resource, action, exception).for_json
@@ -234,8 +216,6 @@ class Chef
234
216
  # (see EventDispatch::Base#)
235
217
  #
236
218
  def resource_completed(new_resource)
237
- return if consumers.empty?
238
-
239
219
  current_record.elapsed_time = new_resource.elapsed_time
240
220
 
241
221
  # Verify if the resource has sensitive data and create a new blank resource with only
@@ -297,6 +297,21 @@ class Chef::Application::Base < Chef::Application
297
297
  long: "--named-run-list NAMED_RUN_LIST",
298
298
  description: "Use a policyfile's named run list instead of the default run list."
299
299
 
300
+ option :slow_report,
301
+ long: "--[no-]slow-report [COUNT]",
302
+ description: "List the slowest resources at the end of the run (default: 10).",
303
+ boolean: true,
304
+ default: false,
305
+ proc: lambda { |argument|
306
+ if argument.nil?
307
+ true
308
+ elsif argument == false
309
+ false
310
+ else
311
+ Integer(argument)
312
+ end
313
+ }
314
+
300
315
  IMMEDIATE_RUN_SIGNAL = "1".freeze
301
316
  RECONFIGURE_SIGNAL = "H".freeze
302
317
 
@@ -310,7 +310,7 @@ class Chef
310
310
  logger.info "Forking #{ChefUtils::Dist::Infra::PRODUCT} instance to converge..."
311
311
  pid = fork do
312
312
  # Want to allow forked processes to finish converging when
313
- # TERM singal is received (exit gracefully)
313
+ # TERM signal is received (exit gracefully)
314
314
  trap("TERM") do
315
315
  logger.debug("SIGTERM received during converge," +
316
316
  " finishing converge to exit normally (send SIGINT to terminate immediately)")
@@ -377,7 +377,9 @@ class Chef
377
377
 
378
378
  Chef::FileCache.store("#{ChefUtils::Dist::Infra::SHORT}-stacktrace.out", chef_stacktrace_out)
379
379
  logger.fatal("Stacktrace dumped to #{Chef::FileCache.load("#{ChefUtils::Dist::Infra::SHORT}-stacktrace.out", false)}")
380
- logger.fatal("Please provide the contents of the stacktrace.out file if you file a bug report")
380
+ logger.fatal("---------------------------------------------------------------------------------------")
381
+ logger.fatal("PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT")
382
+ logger.fatal("---------------------------------------------------------------------------------------")
381
383
  if Chef::Config[:always_dump_stacktrace]
382
384
  logger.fatal(message)
383
385
  else
@@ -255,7 +255,7 @@ class Chef
255
255
  end
256
256
 
257
257
  def self.regexp_escape_characters
258
- [ "[", '\\', "^", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}" ]
258
+ [ "[", "\\", "^", "$", ".", "|", "?", "*", "+", "(", ")", "{", "}" ]
259
259
  end
260
260
 
261
261
  def self.pattern_to_regexp(pattern)
@@ -281,7 +281,7 @@ class Chef
281
281
  exact = nil
282
282
  regexp << "."
283
283
  else
284
- if part[0, 1] == '\\' && part.length == 2
284
+ if part[0, 1] == "\\" && part.length == 2
285
285
  # backslash escapes are only supported on Unix, and are handled here by leaving the escape on (it means the same thing in a regex)
286
286
  exact << part[1, 1] unless exact.nil?
287
287
  if regexp_escape_characters.include?(part[1, 1])
data/lib/chef/client.rb CHANGED
@@ -751,7 +751,7 @@ class Chef
751
751
  end
752
752
 
753
753
  # Notification registration
754
- class<<self
754
+ class << self
755
755
  #
756
756
  # Add a listener for the 'client run started' event.
757
757
  #
@@ -863,6 +863,12 @@ class Chef
863
863
  end
864
864
 
865
865
  def start_profiling
866
+ if Chef::Config[:slow_report]
867
+ require_relative "handler/slow_report"
868
+
869
+ Chef::Config.report_handlers << Chef::Handler::SlowReport.new(Chef::Config[:slow_report])
870
+ end
871
+
866
872
  return unless Chef::Config[:profile_ruby]
867
873
 
868
874
  profiling_prereqs!
@@ -28,7 +28,7 @@ class Chef
28
28
  # Controls what is done with the resulting report after the Chef InSpec run.
29
29
  # Accepts a single string value or an array of multiple values.
30
30
  # Accepted values: 'chef-server-automate', 'chef-automate', 'json-file', 'audit-enforcer', 'cli'
31
- "reporter" => "json-file",
31
+ "reporter" => "cli",
32
32
 
33
33
  # Controls if Chef InSpec profiles should be fetched from Chef Automate or Chef Infra Server
34
34
  # in addition to the default fetch locations provided by Chef Inspec.
@@ -47,8 +47,10 @@ class Chef
47
47
  "profiles" => {},
48
48
 
49
49
  # Extra inputs passed to Chef InSpec to allow finer-grained control over behavior.
50
- # These are mapped to Chef InSpec's inputs, but are named attributes here for legacy reasons.
51
50
  # See Chef Inspec's documentation for more information: https://docs.chef.io/inspec/inputs/
51
+ "inputs" => {},
52
+
53
+ # Legacy alias for inputs
52
54
  "attributes" => {},
53
55
 
54
56
  # A string path or an array of paths to Chef InSpec waiver files.
@@ -88,7 +90,7 @@ class Chef
88
90
 
89
91
  # If enabled, a hash representation of the Chef Infra node object will be sent to Chef InSpec in an input
90
92
  # named `chef_node`.
91
- "chef_node_attribute_enabled" => false,
93
+ "chef_node_attribute_enabled" => true,
92
94
 
93
95
  # Should the built-in compliance phase run. True and false force the behavior. Nil does magic based on if you have
94
96
  # profiles defined but do not have the audit cookbook enabled.
@@ -44,7 +44,7 @@ class Chef
44
44
  end
45
45
 
46
46
  unless @url && @token
47
- raise "CMPL006: data_collector.token and data_collector.server_url must be configured in client.rb! Further information: https://docs.chef.io/chef_compliance_phase/#direct-reporting-to-chef-automate"
47
+ raise "CMPL006: data_collector.token and data_collector.server_url must be configured in client.rb! Further information: https://docs.chef.io/automate/data_collection/#configure-your-chef-infra-client-to-send-data-to-chef-automate-without-chef-infra-server"
48
48
  end
49
49
  end
50
50
 
@@ -113,8 +113,17 @@ class Chef
113
113
  logger.info "Chef Infra Compliance Phase Complete"
114
114
  end
115
115
 
116
+ def inputs_from_attributes
117
+ if !node["audit"]["inputs"].empty?
118
+ node["audit"]["inputs"].to_h
119
+ else
120
+ node["audit"]["attributes"].to_h
121
+ end
122
+ end
123
+
116
124
  def inspec_opts
117
- inputs = node["audit"]["attributes"].to_h
125
+ inputs = inputs_from_attributes
126
+
118
127
  if node["audit"]["chef_node_attribute_enabled"]
119
128
  inputs["chef_node"] = node.to_h
120
129
  inputs["chef_node"]["chef_environment"] = node.chef_environment
@@ -288,7 +297,7 @@ class Chef
288
297
  # supports it.
289
298
  Array(node["audit"]["reporter"]).each do |type|
290
299
  unless SUPPORTED_REPORTERS.include? type
291
- raise "CMPL003: '#{type}' found in node['audit']['reporter'] is not a supported reporter for Compliance Phase. Supported reporters are: #{SUPPORTED_REPORTERS.join(", ")}. For more information, see the documentation at https://docs.chef.io/chef_compliance_phase/chef_compliance_runners/#reporters"
300
+ raise "CMPL003: '#{type}' found in node['audit']['reporter'] is not a supported reporter for Compliance Phase. Supported reporters are: #{SUPPORTED_REPORTERS.join(", ")}. For more information, see the documentation at https://docs.chef.io/chef_compliance_phase#reporters"
292
301
  end
293
302
 
294
303
  @reporters[type] = reporter(type)
@@ -297,9 +306,14 @@ class Chef
297
306
 
298
307
  unless (fetcher = node["audit"]["fetcher"]).nil?
299
308
  unless SUPPORTED_FETCHERS.include? fetcher
300
- raise "CMPL002: Unrecognized Compliance Phase fetcher (node['audit']['fetcher'] = #{fetcher}). Supported fetchers are: #{SUPPORTED_FETCHERS.join(", ")}, or nil. For more information, see the documentation at https://docs.chef.io/chef_compliance_phase/chef_compliance_runners/#fetchers"
309
+ raise "CMPL002: Unrecognized Compliance Phase fetcher (node['audit']['fetcher'] = #{fetcher}). Supported fetchers are: #{SUPPORTED_FETCHERS.join(", ")}, or nil. For more information, see the documentation at https://docs.chef.io/chef_compliance_phase#fetch-profiles"
301
310
  end
302
311
  end
312
+
313
+ if !node["audit"]["attributes"].empty? && !node["audit"]["inputs"].empty?
314
+ raise "CMPL011: both node['audit']['inputs'] and node['audit']['attributes'] are set. The node['audit']['attributes'] setting is deprecated and should not be used."
315
+ end
316
+
303
317
  @validation_passed = true
304
318
  end
305
319
  end
@@ -160,13 +160,13 @@ class Chef
160
160
  def metadata_filenames
161
161
  return @metadata_filenames unless @metadata_filenames.empty?
162
162
 
163
- if File.exists?(File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE))
163
+ if File.exist?(File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE))
164
164
  @uploaded_cookbook_version_file = File.join(cookbook_path, UPLOADED_COOKBOOK_VERSION_FILE)
165
165
  end
166
166
 
167
- if File.exists?(File.join(cookbook_path, "metadata.json"))
167
+ if File.exist?(File.join(cookbook_path, "metadata.json"))
168
168
  @metadata_filenames << File.join(cookbook_path, "metadata.json")
169
- elsif File.exists?(File.join(cookbook_path, "metadata.rb"))
169
+ elsif File.exist?(File.join(cookbook_path, "metadata.rb"))
170
170
  @metadata_filenames << File.join(cookbook_path, "metadata.rb")
171
171
  elsif uploaded_cookbook_version_file
172
172
  @metadata_filenames << uploaded_cookbook_version_file
@@ -70,7 +70,11 @@ class Chef
70
70
  unless Chef::Config[:skip_gem_metadata_installation]
71
71
  # Add additional options to bundle install
72
72
  cmd = [ "bundle", "install", Chef::Config[:gem_installer_bundler_options] ]
73
- so = shell_out!(cmd, cwd: dir, env: { "PATH" => path_with_prepended_ruby_bin })
73
+ env = {
74
+ "PATH" => path_with_prepended_ruby_bin,
75
+ "BUNDLE_SILENCE_ROOT_WARNING" => "1",
76
+ }
77
+ so = shell_out!(cmd, cwd: dir, env: env)
74
78
  Chef::Log.info(so.stdout)
75
79
  end
76
80
  end
@@ -138,11 +138,14 @@ class Chef
138
138
  end
139
139
 
140
140
  def recipe_yml_filenames_by_name
141
- @recipe_ym_filenames_by_name ||= begin
141
+ @recipe_yml_filenames_by_name ||= begin
142
142
  name_map = yml_filenames_by_name(files_for("recipes"))
143
- root_alias = cookbook_manifest.root_files.find { |record| record[:name] == "root_files/recipe.yml" }
143
+ root_alias = cookbook_manifest.root_files.find { |record|
144
+ record[:name] == "root_files/recipe.yml" ||
145
+ record[:name] == "root_files/recipe.yaml"
146
+ }
144
147
  if root_alias
145
- Chef::Log.error("Cookbook #{name} contains both recipe.yml and and recipes/default.yml, ignoring recipes/default.yml") if name_map["default"]
148
+ Chef::Log.error("Cookbook #{name} contains both recipe.yml and recipes/default.yml, ignoring recipes/default.yml") if name_map["default"]
146
149
  name_map["default"] = root_alias[:full_path]
147
150
  end
148
151
  name_map
@@ -582,8 +585,27 @@ class Chef
582
585
  records.select { |record| record[:name] =~ /\.rb$/ }.inject({}) { |memo, record| memo[File.basename(record[:name], ".rb")] = record[:full_path]; memo }
583
586
  end
584
587
 
588
+ # Filters YAML files from the superset of provided files.
589
+ # Checks for duplicate basenames with differing extensions (eg yaml v yml)
590
+ # and raises error if any are detected.
591
+ # This prevents us from arbitrarily the ".yaml" or ".yml" version when both are present,
592
+ # because we don't know which is correct.
593
+ # This method runs in O(n^2) where N = number of yml files present. This number should be consistently
594
+ # low enough that there's no noticeable perf impact.
585
595
  def yml_filenames_by_name(records)
586
- records.select { |record| record[:name] =~ /\.yml$/ }.inject({}) { |memo, record| memo[File.basename(record[:name], ".yml")] = record[:full_path]; memo }
596
+ yml_files = records.select { |record| record[:name] =~ /\.(y[a]?ml)$/ }
597
+ result = yml_files.inject({}) do |acc, record|
598
+ filename = record[:name]
599
+ base_dup_name = File.join(File.dirname(filename), File.basename(filename, File.extname(filename)))
600
+ yml_files.each do |other|
601
+ if other[:name] =~ /#{(File.extname(filename) == ".yml") ? "#{base_dup_name}.yaml" : "#{base_dup_name}.yml"}$/
602
+ raise Chef::Exceptions::AmbiguousYAMLFile.new("Cookbook #{name}@#{version} contains ambiguous files: #{filename} and #{other[:name]}. Please update the cookbook to remove the incorrect file.")
603
+ end
604
+ end
605
+ acc[File.basename(record[:name], File.extname(record[:name]))] = record[:full_path]
606
+ acc
607
+ end
608
+ result
587
609
  end
588
610
 
589
611
  def file_vendor