cookstyle 7.11.3 → 7.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +20 -2
- data/config/disable_all.yml +2 -0
- data/config/upstream.yml +11 -3
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/invalid_default_action.rb +10 -11
- data/lib/rubocop/cop/chef/correctness/invalid_platform_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/invalid_version_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/lazy_eval_node_attribute_defaults.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/metadata_missing_name.rb +9 -10
- data/lib/rubocop/cop/chef/correctness/notifies_action_not_symbol.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/resource_sets_name_property.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/resource_with_none_action.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/service_resource.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/supports_must_be_float.rb +0 -1
- data/lib/rubocop/cop/chef/correctness/tmp_path.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/cb_depends_on_self.rb +11 -12
- data/lib/rubocop/cop/chef/deprecation/chef_handler_recipe.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chef_handler_supports.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chef_rest.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chef_rewind.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chef_shellout.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chef_sugar_helpers.rb +22 -23
- data/lib/rubocop/cop/chef/deprecation/chefdk_generators.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/cheffile.rb +2 -3
- data/lib/rubocop/cop/chef/deprecation/chefspec_coverage_report.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chefspec_legacy_runner.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/chocolatey_package_uninstall_action.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_chefspec_platform.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_mixins.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_platform_methods.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/deprecated_shellout_methods.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/easy_install.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/eol_audit_mode.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/epic_fail.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/erl_call.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/execute_path_property.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb +86 -0
- data/lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/log_resource_notifications.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/macos_userdefaults_global_property.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/require_recipe.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb +84 -0
- data/lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb +0 -1
- data/lib/rubocop/cop/chef/deprecation/windows_package_installer_type_string.rb +0 -1
- data/lib/rubocop/cop/chef/effortless/berksfile.rb +0 -1
- data/lib/rubocop/cop/chef/effortless/chef_vault_used.rb +0 -2
- data/lib/rubocop/cop/chef/effortless/depends_chef_vault.rb +0 -2
- data/lib/rubocop/cop/chef/modernize/chef_gem_nokogiri.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/foodcritic_comments.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/includes_mixin_shellout.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/libarchive_file.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/resource_set_or_return.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/resource_with_attributes.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/seven_zip_archive.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/shell_out_helper.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/simplify_apt_ppa_setup.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/unnecessary_mixlib_shellout_require.rb +0 -1
- data/lib/rubocop/cop/chef/modernize/windows_registry_uac.rb +37 -18
- data/lib/rubocop/cop/chef/modernize/zipfile_resource.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/attribute_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/conflicts_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/custom_resource_with_allowed_actions.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/grouping_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/long_description_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/multiple_platform_checks.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/ohai_attribute_to_string.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/provides_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/recipe_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/replaces_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/redundant/suggests_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb +0 -1
- data/lib/rubocop/cop/chef/sharing/empty_metadata_field.rb +0 -1
- data/lib/rubocop/cop/chef/sharing/invalid_license_string.rb +0 -1
- data/lib/rubocop/cop/chef/style/attribute_keys.rb +0 -1
- data/lib/rubocop/cop/chef/style/chef_whaaat.rb +0 -1
- data/lib/rubocop/cop/chef/style/comment_sentence_spacing.rb +0 -1
- data/lib/rubocop/cop/chef/style/comments_copyright_format.rb +0 -1
- data/lib/rubocop/cop/chef/style/comments_default_copyright.rb +0 -1
- data/lib/rubocop/cop/chef/style/comments_format.rb +0 -1
- data/lib/rubocop/cop/chef/style/file_mode.rb +0 -1
- data/lib/rubocop/cop/chef/style/include_recipe_with_parentheses.rb +0 -1
- metadata +6 -4
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright:: 2020, Chef Software, Inc.
|
3
|
+
# Copyright:: 2020-2021, Chef Software, Inc.
|
4
4
|
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -32,12 +32,12 @@ module RuboCop
|
|
32
32
|
# action :create
|
33
33
|
# end
|
34
34
|
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
35
|
+
# #### correct
|
36
|
+
# windows_uac 'Set Windows UAC settings' do
|
37
|
+
# enable_uac false
|
38
|
+
# prompt_on_secure_desktop true
|
39
|
+
# consent_behavior_admins :no_prompt
|
40
|
+
# end
|
41
41
|
#
|
42
42
|
class WindowsRegistryUAC < Base
|
43
43
|
include RuboCop::Chef::CookbookHelpers
|
@@ -47,24 +47,43 @@ module RuboCop
|
|
47
47
|
|
48
48
|
MSG = 'Chef Infra Client 15.0 and later includes a windows_uac resource that should be used to set Windows UAC values instead of setting registry keys directly.'
|
49
49
|
RESTRICT_ON_SEND = [:registry_key].freeze
|
50
|
+
VALID_VALUES = %w(EnableLUA ValidateAdminCodeSignatures PromptOnSecureDesktop ConsentPromptBehaviorAdmin ConsentPromptBehaviorUser EnableInstallerDetection).freeze
|
50
51
|
|
51
|
-
#
|
52
|
-
def
|
53
|
-
return unless node
|
54
|
-
|
55
|
-
|
56
|
-
# use source instead of .value in case there's string interpolation which adds a complex dstr type
|
57
|
-
# with a nested string and a begin. Source allows us to avoid a lot of defensive programming here
|
52
|
+
# block registry_key resources
|
53
|
+
def on_block(node)
|
54
|
+
return unless node.method_name == :registry_key
|
55
|
+
return unless correct_key?(node)
|
56
|
+
return unless uac_supported_values?(node)
|
58
57
|
add_offense(node, message: MSG, severity: :refactor)
|
59
58
|
end
|
60
59
|
|
61
|
-
#
|
62
|
-
|
60
|
+
# make sure the values passed are all the ones in the uac resource
|
61
|
+
# this key has other values we don't support in the windows_uac resource
|
62
|
+
def uac_supported_values?(node)
|
63
|
+
match_property_in_resource?(:registry_key, 'values', node) do |val_prop|
|
64
|
+
return false unless val_prop&.arguments[0].array_type? # make sure values isn't being passed a variable or method
|
65
|
+
val_prop.arguments[0].each_value do |array|
|
66
|
+
array.each_pair do |key, value|
|
67
|
+
if key == s(:sym, :name)
|
68
|
+
return false unless value.str_type? # make sure it isn't being a variable or method that we can't parse
|
69
|
+
return false unless VALID_VALUES.include?(value.value)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
# make sure the registry_key resource is running against the correct key
|
78
|
+
# check the block name and the key property (registry_key's name property)
|
79
|
+
def correct_key?(node)
|
80
|
+
return true if node.send_node.arguments.first.source.match?(/(HKLM|HKEY_LOCAL_MACHINE)\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System/i)
|
81
|
+
|
63
82
|
match_property_in_resource?(:registry_key, 'key', node) do |key_prop|
|
64
83
|
property_data = method_arg_ast_to_string(key_prop)
|
65
|
-
return
|
66
|
-
add_offense(node, message: MSG, severity: :refactor)
|
84
|
+
return true if property_data && property_data.match?(/(HKLM|HKEY_LOCAL_MACHINE)\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System/i)
|
67
85
|
end
|
86
|
+
false
|
68
87
|
end
|
69
88
|
end
|
70
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookstyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-05-
|
12
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: 1.15.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
27
|
+
version: 1.15.0
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/rubocop/cop/chef/deprecation/execute_relative_creates_without_cwd.rb
|
117
117
|
- lib/rubocop/cop/chef/deprecation/foodcritic_testing.rb
|
118
118
|
- lib/rubocop/cop/chef/deprecation/hwrp_without_provides.rb
|
119
|
+
- lib/rubocop/cop/chef/deprecation/hwrp_without_unified_mode_true.rb
|
119
120
|
- lib/rubocop/cop/chef/deprecation/inherits_compat_resource.rb
|
120
121
|
- lib/rubocop/cop/chef/deprecation/launchd_deprecated_hash_property.rb
|
121
122
|
- lib/rubocop/cop/chef/deprecation/legacy_notify_syntax.rb
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- lib/rubocop/cop/chef/deprecation/resource_uses_only_resource_name.rb
|
141
142
|
- lib/rubocop/cop/chef/deprecation/resource_uses_provider_base_method.rb
|
142
143
|
- lib/rubocop/cop/chef/deprecation/resource_uses_updated_method.rb
|
144
|
+
- lib/rubocop/cop/chef/deprecation/resource_without_unified_mode_true.rb
|
143
145
|
- lib/rubocop/cop/chef/deprecation/ruby_27_keyword_argument_warnings.rb
|
144
146
|
- lib/rubocop/cop/chef/deprecation/ruby_block_create_action.rb
|
145
147
|
- lib/rubocop/cop/chef/deprecation/run_command_helper.rb
|