cookstyle 7.12.2 → 7.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cookstyle/version.rb +1 -1
- data/lib/rubocop/cop/chef/modernize/windows_registry_uac.rb +31 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b4ac76f05be60a51f678d80bb34d68d4396560b2887214a0a3dd7ac6cd038f
|
4
|
+
data.tar.gz: 74a95cd52549baf8086aa14e3579370d917b8db198deafdc6ced6c28071b3956
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 105f70150e5c66d01b6e157b7f07660a3bf4c755dbb7eed18709fca10b911b54c14fbfff2a2cd41d04ce11b649525b742a469f5f3631ee6c13eaa9f7fa1dc90b
|
7
|
+
data.tar.gz: fb7ffae6e230fa1f26f68626cd9adf4f8d265aee2feeec5fed68c963fde79bbce1022fa973e6bc2cccfbb07e396e4784d81ba0747778915eb3c288ea7e20f19b
|
data/lib/cookstyle/version.rb
CHANGED
@@ -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");
|
@@ -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.12.
|
4
|
+
version: 7.12.3
|
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-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|