chef 17.10.163 → 18.7.10
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 +25 -21
- data/README.md +7 -7
- data/Rakefile +3 -22
- data/{chef-universal-mingw32.gemspec → chef-universal-mingw-ucrt.gemspec} +7 -6
- data/chef.gemspec +33 -27
- data/lib/chef/api_client_v1.rb +9 -1
- data/lib/chef/application/base.rb +20 -2
- data/lib/chef/application/exit_code.rb +3 -3
- data/lib/chef/chef_fs/file_pattern.rb +1 -1
- data/lib/chef/chef_fs/file_system.rb +21 -7
- data/lib/chef/chef_fs/path_utils.rb +7 -9
- data/lib/chef/client.rb +186 -2
- data/lib/chef/compliance/default_attributes.rb +2 -2
- data/lib/chef/compliance/input.rb +1 -1
- data/lib/chef/compliance/profile.rb +1 -1
- data/lib/chef/compliance/profile_collection.rb +0 -1
- data/lib/chef/compliance/runner.rb +6 -1
- data/lib/chef/compliance/waiver.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +4 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +1 -1
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/remote_file_vendor.rb +1 -3
- data/lib/chef/cookbook/synchronizer.rb +21 -3
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_manifest.rb +2 -2
- data/lib/chef/cookbook_version.rb +1 -1
- data/lib/chef/data_collector.rb +14 -0
- data/lib/chef/delayed_evaluator.rb +4 -0
- data/lib/chef/dsl/reader_helpers.rb +1 -1
- data/lib/chef/dsl/rest_resource.rb +77 -0
- data/lib/chef/event_dispatch/base.rb +3 -0
- data/lib/chef/event_dispatch/dispatcher.rb +0 -1
- data/lib/chef/exceptions.rb +9 -1
- data/lib/chef/file_access_control/windows.rb +4 -1
- data/lib/chef/file_cache.rb +17 -2
- data/lib/chef/formatters/doc.rb +1 -1
- data/lib/chef/guard_interpreter/resource_guard_interpreter.rb +2 -0
- data/lib/chef/http/authenticator.rb +253 -3
- data/lib/chef/http/ssl_policies.rb +2 -2
- data/lib/chef/mixin/{homebrew_user.rb → homebrew.rb} +13 -16
- data/lib/chef/mixin/openssl_helper.rb +1 -16
- data/lib/chef/mixin/powershell_exec.rb +5 -28
- data/lib/chef/monkey_patches/net-http.rb +127 -0
- data/lib/chef/node/attribute.rb +3 -11
- data/lib/chef/node/attribute_collections.rb +10 -1
- data/lib/chef/node/immutable_collections.rb +17 -6
- data/lib/chef/node/mixin/immutablize_array.rb +1 -0
- data/lib/chef/node/mixin/state_tracking.rb +7 -4
- data/lib/chef/node/mixin/state_tracking_array.rb +41 -0
- data/lib/chef/node.rb +23 -1
- data/lib/chef/platform/query_helpers.rb +4 -2
- data/lib/chef/policy_builder/policyfile.rb +8 -0
- data/lib/chef/property.rb +13 -6
- data/lib/chef/provider/group/windows.rb +1 -1
- data/lib/chef/provider/http_request.rb +11 -9
- data/lib/chef/provider/launchd.rb +2 -1
- data/lib/chef/provider/mount/linux.rb +6 -1
- data/lib/chef/provider/mount/mount.rb +13 -5
- data/lib/chef/provider/mount/windows.rb +1 -1
- data/lib/chef/provider/package/apt.rb +11 -2
- data/lib/chef/provider/package/chocolatey.rb +260 -22
- data/lib/chef/provider/package/dnf/dnf_helper.py +7 -0
- data/lib/chef/provider/package/homebrew.rb +6 -9
- data/lib/chef/provider/package/powershell.rb +1 -0
- data/lib/chef/provider/package/rubygems.rb +5 -1
- data/lib/chef/provider/package/snap.rb +3 -2
- data/lib/chef/provider/package/windows/msi.rb +2 -2
- data/lib/chef/provider/package/windows/registry_uninstall_entry.rb +1 -1
- data/lib/chef/provider/package/yum/yum_helper.py +3 -3
- data/lib/chef/provider/package/zypper/version.rb +60 -0
- data/lib/chef/provider/package/zypper.rb +47 -3
- data/lib/chef/provider/powershell_script.rb +96 -6
- data/lib/chef/provider/registry_key.rb +2 -0
- data/lib/chef/provider/remote_file/http.rb +1 -1
- data/lib/chef/provider/service/systemd.rb +23 -8
- data/lib/chef/provider/service/windows.rb +1 -1
- data/lib/chef/provider/service.rb +14 -0
- data/lib/chef/provider/user/aix.rb +5 -0
- data/lib/chef/provider/user/linux.rb +29 -0
- data/lib/chef/provider/user/mac.rb +1 -1
- data/lib/chef/provider/user/windows.rb +5 -0
- data/lib/chef/provider/user.rb +45 -9
- data/lib/chef/provider/yum_repository.rb +13 -1
- data/lib/chef/provider.rb +1 -1
- data/lib/chef/recipe.rb +4 -12
- data/lib/chef/resource/_rest_resource.rb +389 -0
- data/lib/chef/resource/alternatives.rb +0 -1
- data/lib/chef/resource/apt_package.rb +21 -1
- data/lib/chef/resource/apt_preference.rb +0 -1
- data/lib/chef/resource/apt_repository.rb +138 -18
- data/lib/chef/resource/apt_update.rb +0 -1
- data/lib/chef/resource/archive_file.rb +0 -1
- data/lib/chef/resource/bash.rb +13 -1
- data/lib/chef/resource/batch.rb +0 -1
- data/lib/chef/resource/bff_package.rb +0 -1
- data/lib/chef/resource/breakpoint.rb +0 -1
- data/lib/chef/resource/build_essential.rb +0 -1
- data/lib/chef/resource/cab_package.rb +0 -1
- data/lib/chef/resource/chef_client_config.rb +12 -14
- data/lib/chef/resource/chef_client_cron.rb +1 -2
- data/lib/chef/resource/chef_client_launchd.rb +2 -2
- data/lib/chef/resource/chef_client_scheduled_task.rb +3 -3
- data/lib/chef/resource/chef_client_systemd_timer.rb +5 -1
- data/lib/chef/resource/chef_client_trusted_certificate.rb +0 -1
- data/lib/chef/resource/chef_gem.rb +1 -2
- data/lib/chef/resource/chef_handler.rb +0 -1
- data/lib/chef/resource/chef_sleep.rb +1 -3
- data/lib/chef/resource/chef_vault_secret.rb +0 -1
- data/lib/chef/resource/chocolatey_config.rb +0 -1
- data/lib/chef/resource/chocolatey_feature.rb +0 -1
- data/lib/chef/resource/chocolatey_installer.rb +207 -0
- data/lib/chef/resource/chocolatey_package.rb +8 -1
- data/lib/chef/resource/chocolatey_source.rb +0 -1
- data/lib/chef/resource/cookbook_file.rb +0 -1
- data/lib/chef/resource/cron/_cron_shared.rb +0 -1
- data/lib/chef/resource/cron/cron.rb +0 -1
- data/lib/chef/resource/cron/cron_d.rb +15 -1
- data/lib/chef/resource/cron_access.rb +0 -1
- data/lib/chef/resource/csh.rb +0 -1
- data/lib/chef/resource/directory.rb +0 -1
- data/lib/chef/resource/dmg_package.rb +2 -1
- data/lib/chef/resource/dnf_package.rb +0 -1
- data/lib/chef/resource/dpkg_package.rb +0 -1
- data/lib/chef/resource/dsc_resource.rb +0 -1
- data/lib/chef/resource/dsc_script.rb +1 -2
- data/lib/chef/resource/execute.rb +8 -7
- data/lib/chef/resource/file.rb +0 -1
- data/lib/chef/resource/freebsd_package.rb +2 -1
- data/lib/chef/resource/gem_package.rb +2 -1
- data/lib/chef/resource/group.rb +25 -2
- data/lib/chef/resource/habitat/habitat_package.rb +0 -1
- data/lib/chef/resource/habitat/habitat_sup.rb +6 -7
- data/lib/chef/resource/habitat/habitat_sup_windows.rb +1 -1
- data/lib/chef/resource/habitat_config.rb +0 -1
- data/lib/chef/resource/habitat_install.rb +2 -2
- data/lib/chef/resource/habitat_service.rb +0 -1
- data/lib/chef/resource/habitat_user_toml.rb +0 -1
- data/lib/chef/resource/homebrew_cask.rb +21 -33
- data/lib/chef/resource/homebrew_package.rb +3 -2
- data/lib/chef/resource/homebrew_tap.rb +32 -18
- data/lib/chef/resource/homebrew_update.rb +4 -6
- data/lib/chef/resource/hostname.rb +0 -1
- data/lib/chef/resource/http_request.rb +0 -1
- data/lib/chef/resource/ifconfig.rb +0 -1
- data/lib/chef/resource/inspec_input.rb +0 -1
- data/lib/chef/resource/inspec_waiver.rb +0 -1
- data/lib/chef/resource/inspec_waiver_file_entry.rb +2 -3
- data/lib/chef/resource/ips_package.rb +0 -1
- data/lib/chef/resource/kernel_module.rb +0 -1
- data/lib/chef/resource/ksh.rb +0 -1
- data/lib/chef/resource/launchd.rb +9 -3
- data/lib/chef/resource/link.rb +0 -1
- data/lib/chef/resource/locale.rb +0 -1
- data/lib/chef/resource/log.rb +0 -1
- data/lib/chef/resource/lwrp_base.rb +0 -4
- data/lib/chef/resource/macos_pkg.rb +111 -0
- data/lib/chef/resource/macos_userdefaults.rb +3 -4
- data/lib/chef/resource/macosx_service.rb +0 -1
- data/lib/chef/resource/macports_package.rb +2 -1
- data/lib/chef/resource/mdadm.rb +0 -1
- data/lib/chef/resource/mount.rb +0 -1
- data/lib/chef/resource/msu_package.rb +0 -1
- data/lib/chef/resource/notify_group.rb +0 -2
- data/lib/chef/resource/ohai.rb +0 -1
- data/lib/chef/resource/ohai_hint.rb +0 -1
- data/lib/chef/resource/openbsd_package.rb +2 -1
- data/lib/chef/resource/openssl_dhparam.rb +0 -2
- data/lib/chef/resource/openssl_ec_private_key.rb +0 -2
- data/lib/chef/resource/openssl_ec_public_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_private_key.rb +0 -2
- data/lib/chef/resource/openssl_rsa_public_key.rb +0 -2
- data/lib/chef/resource/openssl_x509_certificate.rb +0 -2
- data/lib/chef/resource/openssl_x509_crl.rb +0 -2
- data/lib/chef/resource/openssl_x509_request.rb +0 -2
- data/lib/chef/resource/osx_profile.rb +0 -1
- data/lib/chef/resource/package.rb +0 -1
- data/lib/chef/resource/pacman_package.rb +2 -1
- data/lib/chef/resource/paludis_package.rb +0 -1
- data/lib/chef/resource/perl.rb +0 -1
- data/lib/chef/resource/plist.rb +7 -3
- data/lib/chef/resource/portage_package.rb +2 -1
- data/lib/chef/resource/powershell_package.rb +4 -1
- data/lib/chef/resource/powershell_package_source.rb +0 -1
- data/lib/chef/resource/powershell_script.rb +5 -2
- data/lib/chef/resource/python.rb +0 -1
- data/lib/chef/resource/reboot.rb +0 -1
- data/lib/chef/resource/registry_key.rb +6 -1
- data/lib/chef/resource/remote_directory.rb +0 -1
- data/lib/chef/resource/remote_file.rb +0 -1
- data/lib/chef/resource/rhsm_errata.rb +0 -1
- data/lib/chef/resource/rhsm_errata_level.rb +0 -1
- data/lib/chef/resource/rhsm_register.rb +2 -4
- data/lib/chef/resource/rhsm_repo.rb +0 -1
- data/lib/chef/resource/rhsm_subscription.rb +0 -1
- data/lib/chef/resource/route.rb +0 -1
- data/lib/chef/resource/rpm_package.rb +2 -1
- data/lib/chef/resource/ruby.rb +0 -1
- data/lib/chef/resource/ruby_block.rb +0 -1
- data/lib/chef/resource/scm/_scm.rb +0 -2
- data/lib/chef/resource/scm/git.rb +0 -2
- data/lib/chef/resource/scm/subversion.rb +0 -2
- data/lib/chef/resource/script.rb +0 -1
- data/lib/chef/resource/selinux/common_helpers.rb +47 -0
- data/lib/chef/resource/selinux/selinux_debian.erb +18 -0
- data/lib/chef/resource/selinux/selinux_default.erb +15 -0
- data/lib/chef/resource/selinux_boolean.rb +101 -0
- data/lib/chef/resource/selinux_fcontext.rb +160 -0
- data/lib/chef/resource/selinux_install.rb +107 -0
- data/lib/chef/resource/selinux_login.rb +129 -0
- data/lib/chef/resource/selinux_module.rb +143 -0
- data/lib/chef/resource/selinux_permissive.rb +64 -0
- data/lib/chef/resource/selinux_port.rb +118 -0
- data/lib/chef/resource/selinux_state.rb +166 -0
- data/lib/chef/resource/selinux_user.rb +137 -0
- data/lib/chef/resource/service.rb +4 -2
- data/lib/chef/resource/smartos_package.rb +2 -1
- data/lib/chef/resource/snap_package.rb +25 -1
- data/lib/chef/resource/solaris_package.rb +2 -1
- data/lib/chef/resource/ssh_known_hosts_entry.rb +0 -1
- data/lib/chef/resource/sudo.rb +37 -3
- data/lib/chef/resource/support/client.erb +2 -2
- data/lib/chef/resource/support/ulimit.erb +40 -0
- data/lib/chef/resource/swap_file.rb +0 -1
- data/lib/chef/resource/sysctl.rb +2 -2
- data/lib/chef/resource/systemd_unit.rb +0 -1
- data/lib/chef/resource/template.rb +0 -1
- data/lib/chef/resource/timezone.rb +0 -1
- data/lib/chef/resource/user/aix_user.rb +0 -1
- data/lib/chef/resource/user/linux_user.rb +0 -1
- data/lib/chef/resource/user/mac_user.rb +0 -1
- data/lib/chef/resource/user/pw_user.rb +0 -1
- data/lib/chef/resource/user/solaris_user.rb +0 -1
- data/lib/chef/resource/user/windows_user.rb +0 -1
- data/lib/chef/resource/user.rb +10 -1
- data/lib/chef/resource/user_ulimit.rb +38 -1
- data/lib/chef/resource/whyrun_safe_ruby_block.rb +0 -1
- data/lib/chef/resource/windows_ad_join.rb +0 -2
- data/lib/chef/resource/windows_audit_policy.rb +0 -2
- data/lib/chef/resource/windows_auto_run.rb +0 -1
- data/lib/chef/resource/windows_certificate.rb +1 -1
- data/lib/chef/resource/windows_defender.rb +0 -1
- data/lib/chef/resource/windows_defender_exclusion.rb +0 -1
- data/lib/chef/resource/windows_dfs_folder.rb +0 -1
- data/lib/chef/resource/windows_dfs_namespace.rb +0 -1
- data/lib/chef/resource/windows_dfs_server.rb +0 -1
- data/lib/chef/resource/windows_dns_record.rb +0 -1
- data/lib/chef/resource/windows_dns_zone.rb +0 -1
- data/lib/chef/resource/windows_env.rb +0 -1
- data/lib/chef/resource/windows_feature.rb +0 -1
- data/lib/chef/resource/windows_feature_dism.rb +0 -1
- data/lib/chef/resource/windows_feature_powershell.rb +0 -1
- data/lib/chef/resource/windows_firewall_profile.rb +0 -2
- data/lib/chef/resource/windows_firewall_rule.rb +0 -1
- data/lib/chef/resource/windows_font.rb +2 -3
- data/lib/chef/resource/windows_package.rb +3 -4
- data/lib/chef/resource/windows_pagefile.rb +0 -2
- data/lib/chef/resource/windows_path.rb +0 -1
- data/lib/chef/resource/windows_printer.rb +0 -1
- data/lib/chef/resource/windows_printer_port.rb +0 -1
- data/lib/chef/resource/windows_script.rb +0 -2
- data/lib/chef/resource/windows_security_policy.rb +2 -3
- data/lib/chef/resource/windows_service.rb +0 -1
- data/lib/chef/resource/windows_share.rb +0 -1
- data/lib/chef/resource/windows_shortcut.rb +1 -2
- data/lib/chef/resource/windows_task.rb +0 -1
- data/lib/chef/resource/windows_uac.rb +0 -1
- data/lib/chef/resource/windows_update_settings.rb +0 -1
- data/lib/chef/resource/windows_user_privilege.rb +14 -11
- data/lib/chef/resource/windows_workgroup.rb +0 -1
- data/lib/chef/resource/yum_package.rb +2 -1
- data/lib/chef/resource/yum_repository.rb +4 -1
- data/lib/chef/resource/zypper_package.rb +2 -1
- data/lib/chef/resource/zypper_repository.rb +0 -1
- data/lib/chef/resource.rb +23 -5
- data/lib/chef/resource_inspector.rb +25 -7
- data/lib/chef/resource_reporter.rb +4 -0
- data/lib/chef/resources.rb +11 -0
- data/lib/chef/run_context.rb +3 -3
- data/lib/chef/secret_fetcher/azure_key_vault.rb +1 -1
- data/lib/chef/util/powershell/ps_credential.rb +10 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/handle.rb +6 -7
- data/lib/chef/win32/registry.rb +12 -4
- data/lib/chef/win32/security.rb +16 -1
- data/spec/data/rubygems.org/sexp_processor-info +2 -1
- data/spec/data/trusted_certs/intermediate.pem +38 -27
- data/spec/functional/resource/cookbook_file_spec.rb +1 -1
- data/spec/functional/resource/dsc_script_spec.rb +1 -1
- data/spec/functional/resource/execute_spec.rb +1 -1
- data/spec/functional/resource/group_spec.rb +26 -42
- data/spec/functional/resource/link_spec.rb +8 -8
- data/spec/functional/resource/plist_spec.rb +25 -0
- data/spec/functional/resource/registry_spec.rb +233 -609
- data/spec/functional/resource/remote_file_spec.rb +1 -1
- data/spec/functional/resource/user/linux_user_spec.rb +127 -0
- data/spec/functional/resource/windows_certificate_spec.rb +1 -1
- data/spec/functional/resource/windows_font_spec.rb +12 -9
- data/spec/functional/resource/yum_package_spec.rb +1 -1
- data/spec/functional/resource/zypper_package_spec.rb +12 -0
- data/spec/functional/shell_spec.rb +1 -2
- data/spec/functional/version_spec.rb +1 -1
- data/spec/functional/win32/registry_spec.rb +0 -3
- data/spec/integration/client/client_spec.rb +88 -3
- data/spec/integration/client/exit_code_spec.rb +1 -1
- data/spec/integration/client/fips_spec.rb +5 -5
- data/spec/integration/client/ipv6_spec.rb +1 -1
- data/spec/integration/client/open_ssl_spec.rb +3 -3
- data/spec/integration/compliance/compliance_spec.rb +1 -1
- data/spec/integration/recipes/accumulator_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_inline_resources_spec.rb +1 -1
- data/spec/integration/recipes/lwrp_spec.rb +1 -1
- data/spec/integration/recipes/notifies_spec.rb +1 -1
- data/spec/integration/recipes/notifying_block_spec.rb +1 -1
- data/spec/integration/recipes/remote_directory.rb +1 -1
- data/spec/integration/recipes/unified_mode_spec.rb +1 -1
- data/spec/integration/recipes/use_partial_spec.rb +2 -1
- data/spec/integration/solo/solo_spec.rb +2 -2
- data/spec/spec_helper.rb +7 -4
- data/spec/support/chef_helpers.rb +2 -2
- data/spec/support/platform_helpers.rb +28 -7
- data/spec/support/ruby_installer.rb +1 -1
- data/spec/support/shared/functional/file_resource.rb +3 -3
- data/spec/support/shared/functional/windows_script.rb +2 -2
- data/spec/tiny_server.rb +5 -2
- data/spec/unit/application/client_spec.rb +0 -10
- data/spec/unit/chef_fs/file_system_spec.rb +2 -0
- data/spec/unit/client_spec.rb +80 -4
- data/spec/unit/compliance/runner_spec.rb +8 -0
- data/spec/unit/cookbook/syntax_check_spec.rb +3 -0
- data/spec/unit/data_collector_spec.rb +106 -2
- data/spec/unit/delayed_evaluator_spec.rb +35 -0
- data/spec/unit/file_cache_spec.rb +64 -0
- data/spec/unit/http/authenticator_spec.rb +121 -0
- data/spec/unit/mixin/homebrew_spec.rb +118 -0
- data/spec/unit/mixin/openssl_helper_spec.rb +5 -0
- data/spec/unit/mixin/powershell_exec_spec.rb +5 -5
- data/spec/unit/node/vivid_mash_spec.rb +42 -0
- data/spec/unit/node_spec.rb +6 -0
- data/spec/unit/platform/query_helpers_spec.rb +2 -17
- data/spec/unit/property/validation_spec.rb +30 -0
- data/spec/unit/provider/apt_repository_spec.rb +48 -12
- data/spec/unit/provider/cron_spec.rb +2 -0
- data/spec/unit/provider/http_request_spec.rb +60 -72
- data/spec/unit/provider/launchd_spec.rb +2 -2
- data/spec/unit/provider/mount/aix_spec.rb +2 -2
- data/spec/unit/provider/mount/linux_spec.rb +15 -4
- data/spec/unit/provider/mount/mount_spec.rb +8 -8
- data/spec/unit/provider/package/apt_spec.rb +18 -13
- data/spec/unit/provider/package/chocolatey_spec.rb +41 -9
- data/spec/unit/provider/package/homebrew_spec.rb +4 -1
- data/spec/unit/provider/package/rpm_spec.rb +2 -2
- data/spec/unit/provider/package/rubygems_spec.rb +1 -1
- data/spec/unit/provider/package/windows_spec.rb +5 -5
- data/spec/unit/provider/package/zypper_spec.rb +32 -0
- data/spec/unit/provider/powershell_script_spec.rb +100 -4
- data/spec/unit/provider/registry_key_spec.rb +17 -17
- data/spec/unit/provider/remote_file/http_spec.rb +4 -4
- data/spec/unit/provider/service/systemd_service_spec.rb +1 -0
- data/spec/unit/provider/user/linux_spec.rb +51 -1
- data/spec/unit/provider/user/windows_spec.rb +1 -0
- data/spec/unit/provider/user_spec.rb +24 -6
- data/spec/unit/resource/apt_repository_spec.rb +5 -0
- data/spec/unit/resource/archive_file_spec.rb +1 -1
- data/spec/unit/resource/chef_client_cron_spec.rb +5 -0
- data/spec/unit/resource/chef_client_launchd_spec.rb +5 -0
- data/spec/unit/resource/chef_client_scheduled_task_spec.rb +5 -0
- data/spec/unit/resource/chef_client_systemd_timer_spec.rb +1 -1
- data/spec/unit/resource/chocolatey_installer_spec.rb +151 -0
- data/spec/unit/resource/cron_d_spec.rb +37 -1
- data/spec/unit/resource/macos_pkg_spec.rb +38 -0
- data/spec/unit/resource/powershell_script_spec.rb +2 -2
- data/spec/unit/resource/rest_resource_spec.rb +381 -0
- data/spec/unit/resource/selinux_boolean_spec.rb +92 -0
- data/spec/unit/resource/selinux_fcontext_spec.rb +65 -0
- data/spec/unit/resource/selinux_install_spec.rb +60 -0
- data/spec/unit/resource/selinux_login_spec.rb +73 -0
- data/spec/unit/resource/selinux_module_spec.rb +55 -0
- data/spec/unit/resource/selinux_permissive_spec.rb +39 -0
- data/spec/unit/resource/selinux_port_spec.rb +42 -0
- data/spec/unit/resource/selinux_state_spec.rb +46 -0
- data/spec/unit/resource/selinux_user_spec.rb +92 -0
- data/spec/unit/resource/sysctl_spec.rb +2 -2
- data/spec/unit/resource/user/linux_user_spec.rb +42 -0
- data/spec/unit/resource/yum_repository_spec.rb +4 -0
- data/spec/unit/resource_inspector_spec.rb +36 -0
- data/spec/unit/resource_reporter_spec.rb +57 -3
- data/spec/unit/resource_spec.rb +94 -2
- data/spec/unit/util/dsc/local_configuration_manager_spec.rb +1 -1
- data/spec/unit/util/powershell/ps_credential_spec.rb +6 -0
- data/tasks/rspec.rb +1 -1
- metadata +126 -44
- data/lib/chef/powershell.rb +0 -81
- data/spec/unit/mixin/homebrew_user_spec.rb +0 -119
- /data/spec/functional/assets/yumrepo/repodata/{01a3b-filelists.sqlite.bz2 → 4632d67cb92636e7575d911c24f0e04d3505a944e97c483abe0c3e73a7c62d33-filelists.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{6bf96-other.xml.gz → 74599b793e54d877323837d2d81a1c3c594c44e4335f9528234bb490f7b9b439-other.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{5dc1e-primary.sqlite.bz2 → a845d418f919d2115ab95a56b2c76f6825ad0d0bede49181a55c04f58995d057-primary.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{7c365-other.sqlite.bz2 → af9b7cf9ef23bd7b43068d74a460f3b5d06753d638e58e4a0c9edc35bfb9cdc4-other.sqlite.bz2} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{401dc-filelists.xml.gz → bdb4f5f1492a3b9532f22c43110a81500dd744f23da0aec5c33b2a41317c737d-filelists.xml.gz} +0 -0
- /data/spec/functional/assets/yumrepo/repodata/{dabe2-primary.xml.gz → c10d1d34ce99e02f12ec96ef68360543ab1bb7c3cb81a4a2bf78df7d8597e9df-primary.xml.gz} +0 -0
data/lib/chef/client.rb
CHANGED
|
@@ -64,6 +64,19 @@ class Chef
|
|
|
64
64
|
# The main object in a Chef run. Preps a Chef::Node and Chef::RunContext,
|
|
65
65
|
# syncs cookbooks if necessary, and triggers convergence.
|
|
66
66
|
class Client
|
|
67
|
+
CRYPT_EXPORTABLE = 0x00000001
|
|
68
|
+
|
|
69
|
+
# adding these
|
|
70
|
+
# certstore 65536 == 0x00010000 == CurrentUser
|
|
71
|
+
# certstore 131072 == 0x00020000 == LocalMachine
|
|
72
|
+
# Reference: https://github.com/chef/win32-certstore/blob/main/lib/win32/certstore/mixin/crypto.rb#L90
|
|
73
|
+
CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000
|
|
74
|
+
CERT_SYSTEM_STORE_CURRENT_USER = 0x00010000
|
|
75
|
+
CERT_SYSTEM_STORE_SERVICES = 0x00050000
|
|
76
|
+
CERT_SYSTEM_STORE_USERS = 0x00060000
|
|
77
|
+
|
|
78
|
+
attr_reader :local_context
|
|
79
|
+
|
|
67
80
|
extend Chef::Mixin::Deprecation
|
|
68
81
|
|
|
69
82
|
extend Forwardable
|
|
@@ -625,7 +638,17 @@ class Chef
|
|
|
625
638
|
if !config[:client_key]
|
|
626
639
|
events.skipping_registration(client_name, config)
|
|
627
640
|
logger.trace("Client key is unspecified - skipping registration")
|
|
628
|
-
elsif
|
|
641
|
+
elsif ::Chef::Config[:migrate_key_to_keystore] == true && ChefUtils.windows?
|
|
642
|
+
cert_name = "chef-#{client_name}"
|
|
643
|
+
result = check_certstore_for_key(cert_name)
|
|
644
|
+
if result.rassoc("#{cert_name}")
|
|
645
|
+
logger.trace("Client key #{config[:client_key]} is present in Certificate Store - skipping registration")
|
|
646
|
+
else
|
|
647
|
+
create_new_key_and_register(cert_name)
|
|
648
|
+
logger.trace("New client keys created in the Certificate Store - skipping registration")
|
|
649
|
+
end
|
|
650
|
+
events.skipping_registration(client_name, config)
|
|
651
|
+
elsif File.exist?(config[:client_key])
|
|
629
652
|
events.skipping_registration(client_name, config)
|
|
630
653
|
logger.trace("Client key #{config[:client_key]} is present - skipping registration")
|
|
631
654
|
else
|
|
@@ -643,6 +666,166 @@ class Chef
|
|
|
643
666
|
raise
|
|
644
667
|
end
|
|
645
668
|
|
|
669
|
+
# In the brave new world of No Certs On Disk, we want to put the pem file into Keychain or the Certstore
|
|
670
|
+
# But is it already there?
|
|
671
|
+
# We're solving the multi-user scenario where both a system/admin user can run on the box but also someone without
|
|
672
|
+
# admin rights can also run correctly locally.
|
|
673
|
+
def check_certstore_for_key(cert_name)
|
|
674
|
+
require "win32-certstore"
|
|
675
|
+
if Chef::Config[:auth_key_registry_type] == "user"
|
|
676
|
+
win32certstore = ::Win32::Certstore.open("MY", store_location: CERT_SYSTEM_STORE_CURRENT_USER)
|
|
677
|
+
else
|
|
678
|
+
win32certstore = ::Win32::Certstore.open("MY")
|
|
679
|
+
end
|
|
680
|
+
win32certstore.search("#{cert_name}")
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
def generate_pfx_package(cert_name, date)
|
|
684
|
+
self.class.generate_pfx_package(cert_name, date)
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
def self.generate_pfx_package(cert_name, date)
|
|
688
|
+
require "openssl" unless defined?(OpenSSL)
|
|
689
|
+
|
|
690
|
+
key = OpenSSL::PKey::RSA.new(2048)
|
|
691
|
+
public_key = key.public_key
|
|
692
|
+
|
|
693
|
+
subject = "CN=#{cert_name}"
|
|
694
|
+
|
|
695
|
+
cert = OpenSSL::X509::Certificate.new
|
|
696
|
+
cert.subject = cert.issuer = OpenSSL::X509::Name.parse(subject)
|
|
697
|
+
cert.not_before = Time.now
|
|
698
|
+
cert.not_after = Time.parse(date)
|
|
699
|
+
cert.public_key = public_key
|
|
700
|
+
cert.serial = 0x0
|
|
701
|
+
cert.version = 2
|
|
702
|
+
|
|
703
|
+
ef = OpenSSL::X509::ExtensionFactory.new
|
|
704
|
+
ef.subject_certificate = cert
|
|
705
|
+
ef.issuer_certificate = cert
|
|
706
|
+
cert.extensions = [
|
|
707
|
+
ef.create_extension("subjectKeyIdentifier", "hash"),
|
|
708
|
+
ef.create_extension("keyUsage", "digitalSignature,keyEncipherment", true),
|
|
709
|
+
]
|
|
710
|
+
cert.add_extension(ef.create_ext_from_string("extendedKeyUsage=critical,serverAuth,clientAuth"))
|
|
711
|
+
|
|
712
|
+
cert.sign key, OpenSSL::Digest.new("SHA256")
|
|
713
|
+
password = ::Chef::HTTP::Authenticator.get_cert_password
|
|
714
|
+
pfx = OpenSSL::PKCS12.create(password, subject, key, cert)
|
|
715
|
+
pfx
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
def update_key_and_register(cert_name)
|
|
719
|
+
self.class.update_key_and_register(cert_name)
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
def self.update_key_and_register(cert_name, expiring_cert = nil)
|
|
723
|
+
# Chef client and node objects exist on Chef Server already
|
|
724
|
+
# Create a new public/private keypair in secure storage
|
|
725
|
+
# and register the new public cert with Chef Server
|
|
726
|
+
require "time" unless defined?(Time)
|
|
727
|
+
autoload :URI, "uri"
|
|
728
|
+
|
|
729
|
+
node = Chef::Config[:node_name]
|
|
730
|
+
end_date = Time.new + (3600 * 24 * 90)
|
|
731
|
+
end_date = end_date.utc.iso8601
|
|
732
|
+
|
|
733
|
+
new_cert_name = Time.now.utc.iso8601
|
|
734
|
+
payload = {
|
|
735
|
+
name: new_cert_name,
|
|
736
|
+
clientname: node,
|
|
737
|
+
public_key: "",
|
|
738
|
+
expiration_date: end_date,
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
new_pfx = generate_pfx_package(cert_name, end_date)
|
|
742
|
+
payload[:public_key] = new_pfx.certificate.public_key.to_pem
|
|
743
|
+
base_url = "#{Chef::Config[:chef_server_url]}"
|
|
744
|
+
|
|
745
|
+
@tmpdir = Dir.mktmpdir
|
|
746
|
+
file_path = File.join(@tmpdir, "#{node}.pem")
|
|
747
|
+
|
|
748
|
+
# The pfx files expire every 90 days.
|
|
749
|
+
# We check them in /http/authenticator to see if they are expiring when we extract the private key
|
|
750
|
+
# If they are, we come here to update Chef Server with a new public key
|
|
751
|
+
if expiring_cert
|
|
752
|
+
File.open(file_path, "w") { |f| f.write expiring_cert.key.to_pem }
|
|
753
|
+
signing_cert = file_path
|
|
754
|
+
client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: signing_cert )
|
|
755
|
+
File.delete(file_path)
|
|
756
|
+
else
|
|
757
|
+
client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: Chef::Config[:client_key] )
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
# Get the list of keys for this client
|
|
761
|
+
# Then add the new key we just created
|
|
762
|
+
# Then we delete the old one.
|
|
763
|
+
cert_list = client.get(base_url + "/clients/#{node}/keys")
|
|
764
|
+
client.post(base_url + "/clients/#{node}/keys", payload)
|
|
765
|
+
|
|
766
|
+
# We want to remove the old key for various reasons
|
|
767
|
+
# In the case where more than 1 certificate is returned we assume
|
|
768
|
+
# there is some special condition applied to the client so we won't delete the old
|
|
769
|
+
# certificates
|
|
770
|
+
if cert_list.count < 2
|
|
771
|
+
cert_hash = cert_list.reduce({}, :merge!)
|
|
772
|
+
old_cert_name = cert_hash["name"]
|
|
773
|
+
new_key = new_pfx.key.to_pem
|
|
774
|
+
File.open(file_path, "w") { |f| f.write new_key }
|
|
775
|
+
client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:node_name], signing_key_filename: file_path)
|
|
776
|
+
client.delete(base_url + "/clients/#{node}/keys/#{old_cert_name}")
|
|
777
|
+
File.delete(file_path)
|
|
778
|
+
end
|
|
779
|
+
import_pfx_to_store(new_pfx)
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
def create_new_key_and_register(cert_name)
|
|
783
|
+
require "time" unless defined?(Time)
|
|
784
|
+
autoload :URI, "uri"
|
|
785
|
+
|
|
786
|
+
node = Chef::Config[:node_name]
|
|
787
|
+
d = Time.now
|
|
788
|
+
if d.month == 10 || d.month == 11 || d.month == 12
|
|
789
|
+
end_date = Time.new(d.year + 1, d.month - 9, d.day, d.hour, d.min, d.sec).utc.iso8601
|
|
790
|
+
else
|
|
791
|
+
end_date = Time.new(d.year, d.month + 3, d.day, d.hour, d.min, d.sec).utc.iso8601
|
|
792
|
+
end
|
|
793
|
+
|
|
794
|
+
payload = {
|
|
795
|
+
name: node,
|
|
796
|
+
clientname: node,
|
|
797
|
+
public_key: "",
|
|
798
|
+
expiration_date: end_date,
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
new_pfx = generate_pfx_package(cert_name, end_date)
|
|
802
|
+
payload[:public_key] = new_pfx.certificate.public_key.to_pem
|
|
803
|
+
base_url = "#{Chef::Config[:chef_server_url]}"
|
|
804
|
+
client = Chef::ServerAPI.new(base_url, client_name: Chef::Config[:validation_client_name], signing_key_filename: Chef::Config[:validation_key])
|
|
805
|
+
client.post(base_url + "/clients", payload)
|
|
806
|
+
Chef::Log.trace("Updated client data: #{client.inspect}")
|
|
807
|
+
import_pfx_to_store(new_pfx)
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
def import_pfx_to_store(new_pfx)
|
|
811
|
+
self.class.import_pfx_to_store(new_pfx)
|
|
812
|
+
end
|
|
813
|
+
|
|
814
|
+
def self.import_pfx_to_store(new_pfx)
|
|
815
|
+
password = ::Chef::HTTP::Authenticator.get_cert_password
|
|
816
|
+
require "win32-certstore"
|
|
817
|
+
tempfile = Tempfile.new("#{Chef::Config[:node_name]}.pfx")
|
|
818
|
+
File.open(tempfile, "wb") { |f| f.print new_pfx.to_der }
|
|
819
|
+
# Need to determine where to store the key
|
|
820
|
+
if Chef::Config[:auth_key_registry_type] == "user"
|
|
821
|
+
win32certstore = ::Win32::Certstore.open("MY", store_location: CERT_SYSTEM_STORE_CURRENT_USER)
|
|
822
|
+
else
|
|
823
|
+
win32certstore = ::Win32::Certstore.open("MY")
|
|
824
|
+
end
|
|
825
|
+
win32certstore.add_pfx(tempfile, password, CRYPT_EXPORTABLE)
|
|
826
|
+
tempfile.unlink
|
|
827
|
+
end
|
|
828
|
+
|
|
646
829
|
#
|
|
647
830
|
# Converges all compiled resources.
|
|
648
831
|
#
|
|
@@ -871,7 +1054,7 @@ class Chef
|
|
|
871
1054
|
end
|
|
872
1055
|
|
|
873
1056
|
def empty_directory?(path)
|
|
874
|
-
!File.
|
|
1057
|
+
!File.exist?(path) || (Dir.entries(path).size <= 2)
|
|
875
1058
|
end
|
|
876
1059
|
|
|
877
1060
|
def is_last_element?(index, object)
|
|
@@ -907,3 +1090,4 @@ end
|
|
|
907
1090
|
require_relative "cookbook_loader"
|
|
908
1091
|
require_relative "cookbook_version"
|
|
909
1092
|
require_relative "cookbook/synchronizer"
|
|
1093
|
+
|
|
@@ -38,8 +38,8 @@ class Chef
|
|
|
38
38
|
# Allow for connections to HTTPS endpoints using self-signed ssl certificates.
|
|
39
39
|
"insecure" => nil,
|
|
40
40
|
|
|
41
|
-
#
|
|
42
|
-
"quiet" =>
|
|
41
|
+
# When set to true, it will suppress CLI output for compliance phase.
|
|
42
|
+
"quiet" => false,
|
|
43
43
|
|
|
44
44
|
# Chef Inspec Compliance profiles to be used for scan of node.
|
|
45
45
|
# See Compliance Phase documentation for further details:
|
|
@@ -101,7 +101,7 @@ class Chef
|
|
|
101
101
|
# and cookbook_name are required this is probably not externally useful.
|
|
102
102
|
#
|
|
103
103
|
def self.from_yaml(events, string, path = nil, cookbook_name = nil)
|
|
104
|
-
from_hash(events, YAML.
|
|
104
|
+
from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
# @param filename [String] full path to the yml file in the cookbook
|
|
@@ -108,7 +108,7 @@ class Chef
|
|
|
108
108
|
# and cookbook_name are required this is probably not externally useful.
|
|
109
109
|
#
|
|
110
110
|
def self.from_yaml(events, string, path, cookbook_name)
|
|
111
|
-
from_hash(events, YAML.
|
|
111
|
+
from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
# @param filename [String] full path to the inspec.yml file in the cookbook
|
|
@@ -368,7 +368,12 @@ class Chef
|
|
|
368
368
|
end
|
|
369
369
|
|
|
370
370
|
def requested_reporters
|
|
371
|
-
|
|
371
|
+
if node["audit"]["quiet"]
|
|
372
|
+
logger.info "node[\"audit\"][\"quiet\"] is set to true, skipping cli reporter"
|
|
373
|
+
Array(node["audit"]["reporter"]).uniq - ["cli"]
|
|
374
|
+
else
|
|
375
|
+
(Array(node["audit"]["reporter"]) + ["cli"]).uniq
|
|
376
|
+
end
|
|
372
377
|
end
|
|
373
378
|
|
|
374
379
|
def create_timestamp_file
|
|
@@ -101,7 +101,7 @@ class Chef
|
|
|
101
101
|
# and cookbook_name are required this is probably not externally useful.
|
|
102
102
|
#
|
|
103
103
|
def self.from_yaml(events, string, path = nil, cookbook_name = nil)
|
|
104
|
-
from_hash(events, YAML.
|
|
104
|
+
from_hash(events, YAML.safe_load(string, permitted_classes: [Date]), path, cookbook_name)
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
# @param filename [String] full path to the yml file in the cookbook
|
|
@@ -50,7 +50,10 @@ class Chef
|
|
|
50
50
|
ignore_globs = []
|
|
51
51
|
if @ignore_file && readable_file_or_symlink?(@ignore_file)
|
|
52
52
|
File.foreach(@ignore_file) do |line|
|
|
53
|
-
|
|
53
|
+
unless COMMENTS_AND_WHITESPACE.match?(line)
|
|
54
|
+
line.strip!
|
|
55
|
+
ignore_globs << line
|
|
56
|
+
end
|
|
54
57
|
end
|
|
55
58
|
else
|
|
56
59
|
Chef::Log.debug("No chefignore file found. No files will be ignored!")
|
|
@@ -215,7 +215,7 @@ class Chef
|
|
|
215
215
|
Dir.entries(cookbook_path).each do |top_filename|
|
|
216
216
|
# Skip top-level directories starting with "."
|
|
217
217
|
top_path = File.join(cookbook_path, top_filename)
|
|
218
|
-
next if
|
|
218
|
+
next if top_filename.start_with?(".") && File.directory?(top_path)
|
|
219
219
|
|
|
220
220
|
# Use Find.find because it:
|
|
221
221
|
# (a) returns any children, recursively
|
|
@@ -391,7 +391,7 @@ class Chef
|
|
|
391
391
|
def recipes_from_cookbook_version(cookbook)
|
|
392
392
|
cookbook.fully_qualified_recipe_names.map do |recipe_name|
|
|
393
393
|
unqualified_name =
|
|
394
|
-
if
|
|
394
|
+
if recipe_name.end_with?("::default")
|
|
395
395
|
name.to_s
|
|
396
396
|
else
|
|
397
397
|
recipe_name
|
|
@@ -43,9 +43,7 @@ class Chef
|
|
|
43
43
|
raise "get_filename: Cannot determine segment/filename for incoming filename #{filename}"
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
found_manifest_record = @manifest.files_for(segment).find { |manifest_record| manifest_record[:path] == filename }
|
|
46
|
+
found_manifest_record = @manifest.manifest_records_by_path[filename]
|
|
49
47
|
raise "No such file #{filename} in #{@cookbook_name}" unless found_manifest_record
|
|
50
48
|
|
|
51
49
|
cache_filename = File.join("cookbooks", @cookbook_name, found_manifest_record["path"])
|
|
@@ -219,14 +219,31 @@ class Chef
|
|
|
219
219
|
|
|
220
220
|
# remove deleted files in cookbooks that are being used on the node
|
|
221
221
|
def remove_deleted_files
|
|
222
|
+
cache_file_hash = {}
|
|
223
|
+
@cookbooks_by_name.each_key do |k|
|
|
224
|
+
cache_file_hash[k] = {}
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
# First populate files from cache
|
|
222
228
|
cache.find(File.join(%w{cookbooks ** {*,.*}})).each do |cache_file|
|
|
223
229
|
md = cache_file.match(%r{^cookbooks/([^/]+)/([^/]+)/(.*)})
|
|
224
230
|
next unless md
|
|
225
231
|
|
|
226
|
-
(
|
|
232
|
+
(cookbook_name, segment, file) = md[1..3]
|
|
227
233
|
if have_cookbook?(cookbook_name)
|
|
234
|
+
cache_file_hash[cookbook_name][segment] ||= {}
|
|
235
|
+
cache_file_hash[cookbook_name][segment]["#{segment}/#{file}"] = cache_file
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
# Determine which files don't match manifest
|
|
239
|
+
@cookbooks_by_name.each_key do |cookbook_name|
|
|
240
|
+
cache_file_hash[cookbook_name].each_key do |segment|
|
|
228
241
|
manifest_segment = cookbook_segment(cookbook_name, segment)
|
|
229
|
-
|
|
242
|
+
manifest_record_paths = manifest_segment.map { |manifest_record| manifest_record["path"] }
|
|
243
|
+
to_be_removed = cache_file_hash[cookbook_name][segment].keys - manifest_record_paths
|
|
244
|
+
to_be_removed.each do |path|
|
|
245
|
+
cache_file = cache_file_hash[cookbook_name][segment][path]
|
|
246
|
+
|
|
230
247
|
Chef::Log.info("Removing #{cache_file} from the cache; its is no longer in the cookbook manifest.")
|
|
231
248
|
cache.delete(cache_file)
|
|
232
249
|
@events.removed_cookbook_file(cache_file)
|
|
@@ -263,8 +280,9 @@ class Chef
|
|
|
263
280
|
end
|
|
264
281
|
|
|
265
282
|
def ensure_cookbook_paths
|
|
283
|
+
cookbook_path = File.join(Chef::Config[:file_cache_path], "cookbooks")
|
|
266
284
|
cookbooks.each do |cookbook|
|
|
267
|
-
cb_dir = File.join(
|
|
285
|
+
cb_dir = File.join(cookbook_path, cookbook.name)
|
|
268
286
|
cookbook.root_paths = Array(cb_dir)
|
|
269
287
|
end
|
|
270
288
|
end
|
|
@@ -248,8 +248,8 @@ class Chef
|
|
|
248
248
|
# Debugs ruby syntax errors by printing the path to the file and any
|
|
249
249
|
# diagnostic info given in +error_message+
|
|
250
250
|
def invalid_ruby_file(ruby_file, error_message)
|
|
251
|
-
file_relative_path = ruby_file[
|
|
252
|
-
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error
|
|
251
|
+
file_relative_path = ruby_file[ruby_file.index(cookbook_path.split("/").last), ruby_file.length]
|
|
252
|
+
Chef::Log.fatal("Cookbook file #{file_relative_path} has a ruby syntax error.")
|
|
253
253
|
error_message.each_line { |l| Chef::Log.fatal(l.chomp) }
|
|
254
254
|
false
|
|
255
255
|
end
|
|
@@ -173,9 +173,9 @@ class Chef
|
|
|
173
173
|
def files_for(part)
|
|
174
174
|
return root_files if part.to_s == "root_files"
|
|
175
175
|
|
|
176
|
+
part_match = "#{part}/"
|
|
176
177
|
manifest[:all_files].select do |file|
|
|
177
|
-
|
|
178
|
-
part.to_s == seg
|
|
178
|
+
file[:name].start_with?(part_match)
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
data/lib/chef/data_collector.rb
CHANGED
|
@@ -270,6 +270,20 @@ class Chef
|
|
|
270
270
|
send_run_start unless sent_run_start?
|
|
271
271
|
|
|
272
272
|
message = Chef::DataCollector::RunEndMessage.construct_message(self, status)
|
|
273
|
+
|
|
274
|
+
begin
|
|
275
|
+
if ChefUtils.windows?
|
|
276
|
+
# Remove registry key values that are not present in the after state - CHEF-9126
|
|
277
|
+
message["resources"]&.each do |resource|
|
|
278
|
+
next unless resource["type"] == :registry_key
|
|
279
|
+
|
|
280
|
+
resource["before"][:values]&.reject! { |value| !resource["after"][:values].any? { |after_value| after_value[:name] == value[:name] } }
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
rescue StandardError => e
|
|
284
|
+
Chef::Log.warn("Error while processing registry key values: #{e.message}, #{e.backtrace[0..5]}")
|
|
285
|
+
end
|
|
286
|
+
|
|
273
287
|
send_to_data_collector(message)
|
|
274
288
|
send_to_output_locations(message)
|
|
275
289
|
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright 2008-2016, Chef, 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 "chef/constants" unless defined?(NOT_PASSED)
|
|
19
|
+
|
|
20
|
+
class Chef
|
|
21
|
+
module DSL
|
|
22
|
+
module RestResource
|
|
23
|
+
def rest_property_map(rest_property_map = NOT_PASSED)
|
|
24
|
+
if rest_property_map != NOT_PASSED
|
|
25
|
+
rest_property_map = rest_property_map.to_h { |k| [k.to_sym, k] } if rest_property_map.is_a? Array
|
|
26
|
+
|
|
27
|
+
@rest_property_map = rest_property_map
|
|
28
|
+
end
|
|
29
|
+
@rest_property_map
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# URL to collection
|
|
33
|
+
def rest_api_collection(rest_api_collection = NOT_PASSED)
|
|
34
|
+
if rest_api_collection != NOT_PASSED
|
|
35
|
+
raise ArgumentError, "You must pass an absolute path to rest_api_collection" unless rest_api_collection.start_with? "/"
|
|
36
|
+
|
|
37
|
+
@rest_api_collection = rest_api_collection
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
@rest_api_collection
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# RFC6570-Templated URL to document
|
|
44
|
+
def rest_api_document(rest_api_document = NOT_PASSED, first_element_only: false)
|
|
45
|
+
if rest_api_document != NOT_PASSED
|
|
46
|
+
raise ArgumentError, "You must pass an absolute path to rest_api_document" unless rest_api_document.start_with? "/"
|
|
47
|
+
|
|
48
|
+
@rest_api_document = rest_api_document
|
|
49
|
+
@rest_api_document_first_element_only = first_element_only
|
|
50
|
+
end
|
|
51
|
+
@rest_api_document
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Explicit REST document identity mapping
|
|
55
|
+
def rest_identity_map(rest_identity_map = NOT_PASSED)
|
|
56
|
+
@rest_identity_map = rest_identity_map if rest_identity_map != NOT_PASSED
|
|
57
|
+
@rest_identity_map
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Mark up properties for POST only, not PATCH/PUT
|
|
61
|
+
def rest_post_only_properties(rest_post_only_properties = NOT_PASSED)
|
|
62
|
+
if rest_post_only_properties != NOT_PASSED
|
|
63
|
+
@rest_post_only_properties = Array(rest_post_only_properties).map(&:to_sym)
|
|
64
|
+
end
|
|
65
|
+
@rest_post_only_properties || []
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def rest_api_document_first_element_only(rest_api_document_first_element_only = NOT_PASSED)
|
|
69
|
+
if rest_api_document_first_element_only != NOT_PASSED
|
|
70
|
+
@rest_api_document_first_element_only = rest_api_document_first_element_only
|
|
71
|
+
end
|
|
72
|
+
@rest_api_document_first_element_only
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -273,6 +273,9 @@ class Chef
|
|
|
273
273
|
# Called if the converge phase fails
|
|
274
274
|
def converge_failed(exception); end
|
|
275
275
|
|
|
276
|
+
# Called when migrating from a pem on disk to a pem stored in Keychain or Windows Certstore
|
|
277
|
+
def key_migration_status(key_migrated = false); end
|
|
278
|
+
|
|
276
279
|
# TODO: need events for notification resolve?
|
|
277
280
|
# def notifications_resolved
|
|
278
281
|
# end
|
data/lib/chef/exceptions.rb
CHANGED
|
@@ -170,7 +170,7 @@ class Chef
|
|
|
170
170
|
class PowershellCmdletException < RuntimeError; end
|
|
171
171
|
class LCMParser < RuntimeError; end
|
|
172
172
|
|
|
173
|
-
class
|
|
173
|
+
class CannotDetermineHomebrewPath < Package; end
|
|
174
174
|
class CannotDetermineWindowsInstallerType < Package; end
|
|
175
175
|
class NoWindowsPackageSource < Package; end
|
|
176
176
|
|
|
@@ -561,5 +561,13 @@ class Chef
|
|
|
561
561
|
super "before subscription from #{notification.resource} resource cannot be setup to #{notification.notifying_resource} resource, which has already fired while in unified mode"
|
|
562
562
|
end
|
|
563
563
|
end
|
|
564
|
+
|
|
565
|
+
class RestError < RuntimeError; end
|
|
566
|
+
|
|
567
|
+
class RestTargetError < RestError; end
|
|
568
|
+
|
|
569
|
+
class RestTimeout < RestError; end
|
|
570
|
+
|
|
571
|
+
class RestOperationFailed < RestError; end
|
|
564
572
|
end
|
|
565
573
|
end
|
|
@@ -324,7 +324,10 @@ class Chef
|
|
|
324
324
|
acls += mode_ace(SID.Everyone, (mode & 07))
|
|
325
325
|
end
|
|
326
326
|
|
|
327
|
-
acls.nil?
|
|
327
|
+
# 'acls.nil?' is true if uninitialized, but false if the initial empty array value.
|
|
328
|
+
# 'acls.empty?' cannot be called if acls is nil but successfully guards against using the empty array value.
|
|
329
|
+
# either case should return nil from this method.
|
|
330
|
+
(acls.nil? || acls.empty?) ? nil : Chef::ReservedNames::Win32::Security::ACL.create(acls)
|
|
328
331
|
end
|
|
329
332
|
|
|
330
333
|
def target_group
|
data/lib/chef/file_cache.rb
CHANGED
|
@@ -159,9 +159,24 @@ class Chef
|
|
|
159
159
|
# [String] - An array of file cache keys matching the glob
|
|
160
160
|
def find(glob_pattern)
|
|
161
161
|
keys = []
|
|
162
|
-
|
|
162
|
+
file_cache_dir = Chef::Util::PathHelper.escape_glob_dir(file_cache_path)
|
|
163
|
+
first_filename = Dir[file_cache_dir].first # directory of the cache
|
|
164
|
+
return keys unless first_filename
|
|
165
|
+
|
|
166
|
+
# TODO: The usage of Regexp.escape and the match here is likely
|
|
167
|
+
# vestigial, but since it's only getting called once per method, the
|
|
168
|
+
# effort needed to confirm that its removal won't break something else
|
|
169
|
+
# isn't worth it. A task for a brave soul ;-)
|
|
170
|
+
regexp_pattern = /^(#{Regexp.escape(first_filename) + File::Separator}).+/
|
|
171
|
+
|
|
172
|
+
files = Dir[File.join(file_cache_dir, glob_pattern)]
|
|
173
|
+
until files.empty?
|
|
174
|
+
f = files.shift
|
|
163
175
|
if File.file?(f)
|
|
164
|
-
|
|
176
|
+
# We remove the cache directory from the string of each entry
|
|
177
|
+
path_to_remove ||= f[regexp_pattern, 1]
|
|
178
|
+
f.delete_prefix!(path_to_remove)
|
|
179
|
+
keys << f
|
|
165
180
|
end
|
|
166
181
|
end
|
|
167
182
|
keys
|
data/lib/chef/formatters/doc.rb
CHANGED
|
@@ -57,7 +57,7 @@ class Chef
|
|
|
57
57
|
# Print out deprecations.
|
|
58
58
|
unless deprecations.empty?
|
|
59
59
|
puts_line ""
|
|
60
|
-
puts_line "Deprecation warnings that must be addressed before upgrading to
|
|
60
|
+
puts_line "Deprecation warnings that must be addressed before upgrading to #{ChefUtils::Dist::Infra::PRODUCT} #{Chef::VERSION.to_i + 1}:"
|
|
61
61
|
puts_line ""
|
|
62
62
|
deprecations.each do |message, details|
|
|
63
63
|
locations = details[:locations]
|