diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:11:54 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2019-07-02 15:11:54 -0700 |
commit | e71560df5cebbfb209089c6255e37e65f0e34d95 (patch) | |
tree | 5cd0a1d01eb9609d7f5681b2e04faa902de67e84 /lib/chef | |
parent | 7a1a6c8ef26c787e4b6dd1602f3d158b37e81720 (diff) | |
download | chef-e71560df5cebbfb209089c6255e37e65f0e34d95.tar.gz |
Style/SymbolArray
start enforcing using %i{} instead of arrays of symbols
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef')
56 files changed, 627 insertions, 627 deletions
diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb index 2921c3d964..655cc3fe96 100644 --- a/lib/chef/application/windows_service_manager.rb +++ b/lib/chef/application/windows_service_manager.rb @@ -78,7 +78,7 @@ class Chef raise ArgumentError, "Service definition is not provided" if service_options.nil? - required_options = [:service_name, :service_display_name, :service_description, :service_file_path] + required_options = %i{service_name service_display_name service_description service_file_path} required_options.each do |req_option| if !service_options.key?(req_option) diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb index 336f3592d5..67b7e992b3 100644 --- a/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb @@ -139,7 +139,7 @@ class Chef are_same = true Chef::ChefFS::CommandLine.diff_entries(self, other, nil, :name_only).each do |type, old_entry, new_entry| - if [ :directory_to_file, :file_to_directory, :deleted, :added, :modified ].include?(type) + if %i{directory_to_file file_to_directory deleted added modified}.include?(type) are_same = false end end diff --git a/lib/chef/config.rb b/lib/chef/config.rb index 759818261e..135ae622f7 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -74,7 +74,7 @@ class Chef # by redefining the config_attr_writer to not warn for these options. # # REMOVEME once the warnings for these configurables are removed from Ohai. - [ :log_level, :log_location ].each do |option| + %i{log_level log_location}.each do |option| config_attr_writer option do |value| value end diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index ff12d865c3..1060eaa09c 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -53,10 +53,10 @@ class Chef OHAI_VERSIONS = "ohai_versions".freeze GEMS = "gems".freeze - COMPARISON_FIELDS = [ :name, :description, :long_description, :maintainer, - :maintainer_email, :license, :platforms, :dependencies, - :providing, :recipes, :version, :source_url, :issues_url, - :privacy, :chef_versions, :ohai_versions, :gems ].freeze + COMPARISON_FIELDS = %i{name description long_description maintainer + maintainer_email license platforms dependencies + providing recipes version source_url issues_url + privacy chef_versions ohai_versions gems}.freeze VERSION_CONSTRAINTS = { depends: DEPENDENCIES, provides: PROVIDING, diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb index 6ef66a0337..e149947603 100644 --- a/lib/chef/cookbook_version.rb +++ b/lib/chef/cookbook_version.rb @@ -42,7 +42,7 @@ class Chef def_delegator :@cookbook_manifest, :files_for def_delegator :@cookbook_manifest, :each_file - COOKBOOK_SEGMENTS = [ :resources, :providers, :recipes, :definitions, :libraries, :attributes, :files, :templates, :root_files ].freeze + COOKBOOK_SEGMENTS = %i{resources providers recipes definitions libraries attributes files templates root_files}.freeze attr_reader :all_files diff --git a/lib/chef/http.rb b/lib/chef/http.rb index 546b9c0fbe..b5f6a91c5d 100644 --- a/lib/chef/http.rb +++ b/lib/chef/http.rb @@ -382,7 +382,7 @@ class Chef elsif response.kind_of?(Net::HTTPNotModified) # Must be tested before Net::HTTPRedirection because it's subclass. [response, request, false] elsif redirect_location = redirected_to(response) - if [:GET, :HEAD].include?(method) + if %i{GET HEAD}.include?(method) follow_redirect do redirected_url = url + redirect_location if http_disable_auth_on_redirect diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index 7eb20e6dfb..ea0ff2d064 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -1015,7 +1015,7 @@ class Chef non_interactive: false, keys_only: false, key_files: [], - auth_methods: [:password, :keyboard_interactive], + auth_methods: %i{password keyboard_interactive}, } end diff --git a/lib/chef/knife/bootstrap/train_connector.rb b/lib/chef/knife/bootstrap/train_connector.rb index 490be38f3e..8487116f08 100644 --- a/lib/chef/knife/bootstrap/train_connector.rb +++ b/lib/chef/knife/bootstrap/train_connector.rb @@ -23,7 +23,7 @@ class Chef class Knife class Bootstrap < Knife class TrainConnector - SSH_CONFIG_OVERRIDE_KEYS ||= [:user, :port, :proxy].freeze + SSH_CONFIG_OVERRIDE_KEYS ||= %i{user port proxy}.freeze MKTEMP_WIN_COMMAND ||= <<~EOM.freeze $parent = [System.IO.Path]::GetTempPath(); diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index eb59f184d1..9da8ae4c2f 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -128,7 +128,7 @@ class Chef if permission < 0 || permission > 1 << 32 raise ArgumentError, "permissions flags must be positive and <= 32 bits (#{permission})" end - elsif !([:full_control, :modify, :read_execute, :read, :write].include?(permission.to_sym)) + elsif !(%i{full_control modify read_execute read write}.include?(permission.to_sym)) raise ArgumentError, "permissions parameter must be :full_control, :modify, :read_execute, :read, :write or an integer representing Windows permission flags" end end diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb index 38de13e6b6..488a80acdb 100644 --- a/lib/chef/mixin/template.rb +++ b/lib/chef/mixin/template.rb @@ -184,7 +184,7 @@ class Chef def _extend_modules(module_names) module_names.each do |mod| - context_methods = [:node, :render, :render_template, :render_template_from_string] + context_methods = %i{node render render_template render_template_from_string} context_methods.each do |core_method| if mod.method_defined?(core_method) || mod.private_method_defined?(core_method) Chef::Log.warn("Core template method `#{core_method}' overridden by extension module #{mod}") diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb index 2fc5d55a8e..ae3e3bd7ac 100644 --- a/lib/chef/node/attribute.rb +++ b/lib/chef/node/attribute.rb @@ -51,109 +51,109 @@ class Chef # List of the component attribute hashes, in order of precedence, low to # high. - COMPONENTS = [ - :@default, - :@env_default, - :@role_default, - :@force_default, - :@normal, - :@override, - :@role_override, - :@env_override, - :@force_override, - :@automatic, - ].freeze - - DEFAULT_COMPONENTS = [ - :@default, - :@env_default, - :@role_default, - :@force_default, - ].freeze - - OVERRIDE_COMPONENTS = [ - :@override, - :@role_override, - :@env_override, - :@force_override, - ].freeze - - ENUM_METHODS = [ - :all?, - :any?, - :assoc, - :chunk, - :collect, - :collect_concat, - :compare_by_identity, - :compare_by_identity?, - :count, - :cycle, - :detect, - :drop, - :drop_while, - :each, - :each_cons, - :each_entry, - :each_key, - :each_pair, - :each_slice, - :each_value, - :each_with_index, - :each_with_object, - :empty?, - :entries, - :except, - :fetch, - :find, - :find_all, - :find_index, - :first, - :flat_map, - :flatten, - :grep, - :group_by, - :has_value?, - :include?, - :index, - :inject, - :invert, - :key, - :keys, - :length, - :map, - :max, - :max_by, - :merge, - :min, - :min_by, - :minmax, - :minmax_by, - :none?, - :one?, - :partition, - :rassoc, - :reduce, - :reject, - :reverse_each, - :select, - :size, - :slice_before, - :sort, - :sort_by, - :store, - :symbolize_keys, - :take, - :take_while, - :to_a, - :to_h, - :to_hash, - :to_set, - :value?, - :values, - :values_at, - :zip, - ].freeze + COMPONENTS = %i{ + @default + @env_default + @role_default + @force_default + @normal + @override + @role_override + @env_override + @force_override + @automatic + }.freeze + + DEFAULT_COMPONENTS = %i{ + @default + @env_default + @role_default + @force_default + }.freeze + + OVERRIDE_COMPONENTS = %i{ + @override + @role_override + @env_override + @force_override + }.freeze + + ENUM_METHODS = %i{ + all? + any? + assoc + chunk + collect + collect_concat + compare_by_identity + compare_by_identity? + count + cycle + detect + drop + drop_while + each + each_cons + each_entry + each_key + each_pair + each_slice + each_value + each_with_index + each_with_object + empty? + entries + except + fetch + find + find_all + find_index + first + flat_map + flatten + grep + group_by + has_value? + include? + index + inject + invert + key + keys + length + map + max + max_by + merge + min + min_by + minmax + minmax_by + none? + one? + partition + rassoc + reduce + reject + reverse_each + select + size + slice_before + sort + sort_by + store + symbolize_keys + take + take_while + to_a + to_h + to_hash + to_set + value? + values + values_at + zip + }.freeze ENUM_METHODS.each do |delegated_method| define_method(delegated_method) do |*args, &block| @@ -487,7 +487,7 @@ class Chef end def inspect - "#<#{self.class} " << (COMPONENTS + [:@merged_attributes, :@properties]).map do |iv| + "#<#{self.class} " << (COMPONENTS + %i{@merged_attributes @properties}).map do |iv| "#{iv}=#{instance_variable_get(iv).inspect}" end.join(", ") << ">" end diff --git a/lib/chef/node/attribute_collections.rb b/lib/chef/node/attribute_collections.rb index 3f19321afa..dadc209ae9 100644 --- a/lib/chef/node/attribute_collections.rb +++ b/lib/chef/node/attribute_collections.rb @@ -106,7 +106,7 @@ class Chef # Methods that mutate a VividMash. Each of them is overridden so that it # also invalidates the cached merged_attributes on the root Attribute # object. - MUTATOR_METHODS = Chef::Node::Mixin::ImmutablizeHash::DISALLOWED_MUTATOR_METHODS - [ :write, :write!, :unlink, :unlink! ] + MUTATOR_METHODS = Chef::Node::Mixin::ImmutablizeHash::DISALLOWED_MUTATOR_METHODS - %i{write write! unlink unlink!} # For all of the mutating methods on Mash, override them so that they # also invalidate the cached `merged_attributes` on the root Attribute diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb index a2b8649268..2788f5635e 100644 --- a/lib/chef/node/mixin/immutablize_array.rb +++ b/lib/chef/node/mixin/immutablize_array.rb @@ -21,150 +21,150 @@ class Chef module ImmutablizeArray # Allowed methods that MUST NOT mutate the object # (if any of these methods mutate the underlying object that is a bug that needs to be fixed) - ALLOWED_METHODS = [ - :&, - :*, - :+, - :-, - :[], - :abbrev, - :all?, - :any?, - :assoc, - :at, - :bsearch, - :bsearch_index, - :chain, - :chunk, - :chunk_while, - :collect, - :collect_concat, - :combination, - :compact, - :count, - :cycle, - :detect, - :difference, - :dig, - :drop, - :drop_while, - :each, - :each_cons, - :each_entry, - :each_index, - :each_slice, - :each_with_index, - :each_with_object, - :empty?, - :entries, - :fetch, - :filter, - :find, - :find_all, - :find_index, - :first, - :flat_map, - :flatten, - :grep, - :grep_v, - :group_by, - :include?, - :index, - :inject, - :join, - :last, - :lazy, - :length, - :map, - :max, - :max_by, - :member?, - :min, - :min_by, - :minmax, - :minmax_by, - :none?, - :one?, - :pack, - :partition, - :permutation, - :product, - :rassoc, - :reduce, - :reject, - :repeated_combination, - :repeated_permutation, - :reverse, - :reverse_each, - :rindex, - :rotate, - :sample, - :save_plist, - :select, - :shelljoin, - :shuffle, - :size, - :slice, - :slice_after, - :slice_before, - :slice_when, - :sort, - :sort_by, - :sum, - :take, - :take_while, - :to_a, - :to_ary, - :to_csv, - :to_h, - :to_plist, - :to_set, - :transpose, - :union, - :uniq, - :values_at, - :zip, - :|, - ].freeze + ALLOWED_METHODS = %i{ + & + * + + + - + \[\] + abbrev + all? + any? + assoc + at + bsearch + bsearch_index + chain + chunk + chunk_while + collect + collect_concat + combination + compact + count + cycle + detect + difference + dig + drop + drop_while + each + each_cons + each_entry + each_index + each_slice + each_with_index + each_with_object + empty? + entries + fetch + filter + find + find_all + find_index + first + flat_map + flatten + grep + grep_v + group_by + include? + index + inject + join + last + lazy + length + map + max + max_by + member? + min + min_by + minmax + minmax_by + none? + one? + pack + partition + permutation + product + rassoc + reduce + reject + repeated_combination + repeated_permutation + reverse + reverse_each + rindex + rotate + sample + save_plist + select + shelljoin + shuffle + size + slice + slice_after + slice_before + slice_when + sort + sort_by + sum + take + take_while + to_a + to_ary + to_csv + to_h + to_plist + to_set + transpose + union + uniq + values_at + zip + | + }.freeze # A list of methods that mutate Array. Each of these is overridden to # raise an error, making this instances of this class more or less # immutable. - DISALLOWED_MUTATOR_METHODS = [ - :<<, - :[]=, - :append, - :clear, - :collect!, - :compact!, - :concat, - :default=, - :default_proc=, - :delete, - :delete_at, - :delete_if, - :fill, - :filter!, - :flatten!, - :insert, - :keep_if, - :map!, - :merge!, - :pop, - :prepend, - :push, - :reject!, - :replace, - :reverse!, - :rotate!, - :select!, - :shift, - :shuffle!, - :slice!, - :sort!, - :sort_by!, - :uniq!, - :unshift, - ].freeze + DISALLOWED_MUTATOR_METHODS = %i{ + << + \[\]= + append + clear + collect! + compact! + concat + default= + default_proc= + delete + delete_at + delete_if + fill + filter! + flatten! + insert + keep_if + map! + merge! + pop + prepend + push + reject! + replace + reverse! + rotate! + select! + shift + shuffle! + slice! + sort! + sort_by! + uniq! + unshift + }.freeze # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" diff --git a/lib/chef/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb index 109390ed74..2cf65d2b2e 100644 --- a/lib/chef/node/mixin/immutablize_hash.rb +++ b/lib/chef/node/mixin/immutablize_hash.rb @@ -21,136 +21,136 @@ class Chef module ImmutablizeHash # allowed methods that MUST NOT mutate the object # (if any of these methods mutate the underlying object that is a bug that needs to be fixed) - ALLOWED_METHODS = [ - :<, - :<=, - :>, - :>=, - :[], - :all?, - :any?, - :assoc, - :chain, - :chunk, - :chunk_while, - :collect, - :collect_concat, - :compact, - :compare_by_identity, - :compare_by_identity?, - :count, - :cycle, - :default, - :default_proc, - :detect, - :dig, - :drop, - :drop_while, - :each, - :each_cons, - :each_entry, - :each_key, - :each_pair, - :each_slice, - :each_value, - :each_with_index, - :each_with_object, - :empty?, - :entries, - :fetch, - :fetch_values, - :filter, - :find, - :find_all, - :find_index, - :first, - :flat_map, - :flatten, - :grep, - :grep_v, - :group_by, - :has_key?, - :has_value?, - :include?, - :index, - :inject, - :invert, - :key, - :key?, - :keys, - :lazy, - :length, - :map, - :max, - :max_by, - :member?, - :merge, - :min, - :min_by, - :minmax, - :minmax_by, - :none?, - :normalize_param, - :one?, - :partition, - :rassoc, - :reduce, - :reject, - :reverse_each, - :save_plist, - :select, - :size, - :slice, - :slice_after, - :slice_before, - :slice_when, - :sort, - :sort_by, - :sum, - :take, - :take_while, - :to_a, - :to_h, - :to_hash, - :to_plist, - :to_proc, - :to_set, - :to_xml_attributes, - :transform_keys, - :transform_values, - :uniq, - :value?, - :values, - :values_at, - :zip, - ].freeze - DISALLOWED_MUTATOR_METHODS = [ - :[]=, - :clear, - :collect!, - :compact!, - :default=, - :default_proc=, - :delete, - :delete_if, - :filter!, - :keep_if, - :map!, - :merge!, - :rehash, - :reject!, - :replace, - :select!, - :shift, - :store, - :transform_keys!, - :transform_values!, - :unlink!, - :unlink, - :update, - :write!, - :write, - ].freeze + ALLOWED_METHODS = %i{ + < + <= + > + >= + \[\] + all? + any? + assoc + chain + chunk + chunk_while + collect + collect_concat + compact + compare_by_identity + compare_by_identity? + count + cycle + default + default_proc + detect + dig + drop + drop_while + each + each_cons + each_entry + each_key + each_pair + each_slice + each_value + each_with_index + each_with_object + empty? + entries + fetch + fetch_values + filter + find + find_all + find_index + first + flat_map + flatten + grep + grep_v + group_by + has_key? + has_value? + include? + index + inject + invert + key + key? + keys + lazy + length + map + max + max_by + member? + merge + min + min_by + minmax + minmax_by + none? + normalize_param + one? + partition + rassoc + reduce + reject + reverse_each + save_plist + select + size + slice + slice_after + slice_before + slice_when + sort + sort_by + sum + take + take_while + to_a + to_h + to_hash + to_plist + to_proc + to_set + to_xml_attributes + transform_keys + transform_values + uniq + value? + values + values_at + zip + }.freeze + DISALLOWED_MUTATOR_METHODS = %i{ + \[\]= + clear + collect! + compact! + default= + default_proc= + delete + delete_if + filter! + keep_if + map! + merge! + rehash + reject! + replace + select! + shift + store + transform_keys! + transform_values! + unlink! + unlink + update + write! + write + }.freeze # Redefine all of the methods that mutate a Hash to raise an error when called. # This is the magic that makes this object "Immutable" diff --git a/lib/chef/platform/service_helpers.rb b/lib/chef/platform/service_helpers.rb index 2faec6fc8a..dddddbe90e 100644 --- a/lib/chef/platform/service_helpers.rb +++ b/lib/chef/platform/service_helpers.rb @@ -72,7 +72,7 @@ class Chef configs = [] if file_exist?(Chef.path_to("/etc/init.d/#{service_name}")) - configs += [ :initd, :systemd ] + configs += %i{initd systemd} end if file_exist?(Chef.path_to("/etc/init/#{service_name}.conf")) diff --git a/lib/chef/property.rb b/lib/chef/property.rb index 24dbd56f2c..5c9a62bed2 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -322,7 +322,7 @@ class Chef # def validation_options @validation_options ||= options.reject do |k, v| - [:declared_in, :name, :instance_variable_name, :desired_state, :identity, :default, :name_property, :coerce, :required, :nillable, :sensitive, :description, :introduced, :deprecated, :default_description, :skip_docs].include?(k) + %i{declared_in name instance_variable_name desired_state identity default name_property coerce required nillable sensitive description introduced deprecated default_description skip_docs}.include?(k) end end diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index 7a6f3d666f..ec810739ab 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -25,9 +25,9 @@ class Chef provides :cron, os: ["!aix", "!solaris2"] - SPECIAL_TIME_VALUES = [:reboot, :yearly, :annually, :monthly, :weekly, :daily, :midnight, :hourly].freeze - CRON_ATTRIBUTES = [:minute, :hour, :day, :month, :weekday, :time, :command, :mailto, :path, :shell, :home, :environment].freeze - WEEKDAY_SYMBOLS = [:sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday].freeze + SPECIAL_TIME_VALUES = %i{reboot yearly annually monthly weekly daily midnight hourly}.freeze + CRON_ATTRIBUTES = %i{minute hour day month weekday time command mailto path shell home environment}.freeze + WEEKDAY_SYMBOLS = %i{sunday monday tuesday wednesday thursday friday saturday}.freeze CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/.freeze SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/.freeze @@ -219,7 +219,7 @@ class Chef def get_crontab_entry newcron = "" newcron << "# Chef Name: #{new_resource.name}\n" - [ :mailto, :path, :shell, :home ].each do |v| + %i{mailto path shell home}.each do |v| newcron << "#{v.to_s.upcase}=\"#{new_resource.send(v)}\"\n" if new_resource.send(v) end new_resource.environment.each do |name, value| diff --git a/lib/chef/provider/launchd.rb b/lib/chef/provider/launchd.rb index 838ec22abd..4f20a417a6 100644 --- a/lib/chef/provider/launchd.rb +++ b/lib/chef/provider/launchd.rb @@ -29,18 +29,18 @@ class Chef extend Forwardable provides :launchd, os: "darwin" - def_delegators :new_resource, *[ - :backup, - :cookbook, - :group, - :label, - :mode, - :owner, - :path, - :source, - :session_type, - :type, - ] + def_delegators :new_resource, *%i{ + backup + cookbook + group + label + mode + owner + path + source + session_type + type + } def load_current_resource current_resource = Chef::Resource::Launchd.new(new_resource.name) @@ -114,7 +114,7 @@ class Chef console_user = Etc.getpwuid(::File.stat("/dev/console").uid).name root = console_user == "root" agent = type == "agent" - invalid_action = [:delete, :disable, :enable, :restart].include?(action) + invalid_action = %i{delete disable enable restart}.include?(action) lltstype = "" if new_resource.limit_load_to_session_type lltstype = new_resource.limit_load_to_session_type diff --git a/lib/chef/provider/package/dpkg.rb b/lib/chef/provider/package/dpkg.rb index eaeb5c8fce..47bc53ba8a 100644 --- a/lib/chef/provider/package/dpkg.rb +++ b/lib/chef/provider/package/dpkg.rb @@ -218,7 +218,7 @@ class Chef # # @return [Boolean] true if we're doing :install or :upgrade def installing? - [:install, :upgrade].include?(action) + %i{install upgrade}.include?(action) end end diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb index af0f25bea9..f99b17bcce 100644 --- a/lib/chef/provider/package/yum/python_helper.rb +++ b/lib/chef/provider/package/yum/python_helper.rb @@ -165,7 +165,7 @@ class Chef end # Special handling for certain action / param combos - if [:whatinstalled, :whatavailable].include?(action) + if %i{whatinstalled whatavailable}.include?(action) add_version(hash, parameters["version"]) unless parameters["version"].nil? end diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 11d9f3f9b3..9a9df61b2b 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -122,7 +122,7 @@ class Chef new_resource.unscrubbed_values.each do |value| if @name_hash.key?(value[:name].downcase) current_value = @name_hash[value[:name].downcase] - if [:dword, :dword_big_endian, :qword].include? value[:type] + if %i{dword dword_big_endian qword}.include? value[:type] value[:data] = value[:data].to_i end unless current_value[:type] == value[:type] && current_value[:data] == value[:data] diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index d28bb3c53a..dd3ece4786 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -36,7 +36,7 @@ class Chef def load_current_resource @current_resource = Chef::Resource::Subversion.new(new_resource.name) - unless [:export, :force_export].include?(Array(new_resource.action).first) + unless %i{export force_export}.include?(Array(new_resource.action).first) if current_revision = find_current_revision current_resource.revision current_revision end diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb index da739e41ec..38fe233d76 100644 --- a/lib/chef/provider/user.rb +++ b/lib/chef/provider/user.rb @@ -109,7 +109,7 @@ class Chef def compare_user return true if !new_resource.home.nil? && Pathname.new(new_resource.home).cleanpath != Pathname.new(current_resource.home).cleanpath - [ :comment, :shell, :password, :uid, :gid ].each do |user_attrib| + %i{comment shell password uid gid}.each do |user_attrib| return true if !new_resource.send(user_attrib).nil? && new_resource.send(user_attrib).to_s != current_resource.send(user_attrib).to_s end diff --git a/lib/chef/provider/user/windows.rb b/lib/chef/provider/user/windows.rb index 892759e93f..6d50e2c8ee 100644 --- a/lib/chef/provider/user/windows.rb +++ b/lib/chef/provider/user/windows.rb @@ -65,7 +65,7 @@ class Chef logger.trace("#{new_resource} password has changed") return true end - [ :uid, :comment, :home, :shell, :full_name ].any? do |user_attrib| + %i{uid comment home shell full_name}.any? do |user_attrib| !new_resource.send(user_attrib).nil? && new_resource.send(user_attrib) != current_resource.send(user_attrib) end end diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index f1184094f1..d5f830063f 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1197,9 +1197,9 @@ class Chef # # FORBIDDEN_IVARS do not show up when the resource is converted to JSON (ie. hidden from data_collector and sending to the chef server via #to_json/to_h/as_json/inspect) - FORBIDDEN_IVARS = [:@run_context, :@logger, :@not_if, :@only_if, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated, :@default_description, :@skip_docs, :@executed_by_runner].freeze + FORBIDDEN_IVARS = %i{@run_context @logger @not_if @only_if @enclosing_provider @description @introduced @examples @validation_message @deprecated @default_description @skip_docs @executed_by_runner}.freeze # HIDDEN_IVARS do not show up when the resource is displayed to the user as text (ie. in the error inspector output via #to_text) - HIDDEN_IVARS = [:@allowed_actions, :@resource_name, :@source_line, :@run_context, :@logger, :@name, :@not_if, :@only_if, :@elapsed_time, :@enclosing_provider, :@description, :@introduced, :@examples, :@validation_message, :@deprecated, :@default_description, :@skip_docs, :@executed_by_runner].freeze + HIDDEN_IVARS = %i{@allowed_actions @resource_name @source_line @run_context @logger @name @not_if @only_if @elapsed_time @enclosing_provider @description @introduced @examples @validation_message @deprecated @default_description @skip_docs @executed_by_runner}.freeze include Chef::Mixin::ConvertToClassName extend Chef::Mixin::ConvertToClassName diff --git a/lib/chef/resource/dsc_resource.rb b/lib/chef/resource/dsc_resource.rb index 8d03231367..3ccc30f0fb 100644 --- a/lib/chef/resource/dsc_resource.rb +++ b/lib/chef/resource/dsc_resource.rb @@ -99,7 +99,7 @@ class Chef # If the set method of the DSC resource indicate that a reboot # is necessary, reboot_action provides the mechanism for a reboot to # be requested. - property :reboot_action, Symbol, default: :nothing, equal_to: [:nothing, :reboot_now, :request_reboot], + property :reboot_action, Symbol, default: :nothing, equal_to: %i{nothing reboot_now request_reboot}, introduced: "12.6", description: "Use to request an immediate reboot or to queue a reboot using the :reboot_now (immediate reboot) or :request_reboot (queued reboot) actions built into the reboot resource." diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb index 66388a6463..dd618845bf 100644 --- a/lib/chef/resource/link.rb +++ b/lib/chef/resource/link.rb @@ -57,7 +57,7 @@ class Chef property :link_type, [String, Symbol], description: "The type of link: :symbolic or :hard.", coerce: proc { |arg| arg.kind_of?(String) ? arg.to_sym : arg }, - equal_to: [ :symbolic, :hard ], default: :symbolic + equal_to: %i{symbolic hard}, default: :symbolic property :group, [String, Integer], description: "A group name or ID number that identifies the group associated with a symbolic link.", diff --git a/lib/chef/resource/log.rb b/lib/chef/resource/log.rb index 4f76ea12de..98cf0fb204 100644 --- a/lib/chef/resource/log.rb +++ b/lib/chef/resource/log.rb @@ -43,7 +43,7 @@ class Chef description: "The message to be added to a log file. If not specified we'll use the resource's name instead." property :level, Symbol, - equal_to: [ :debug, :info, :warn, :error, :fatal ], default: :info, + equal_to: %i{debug info warn error fatal}, default: :info, description: "The logging level to display this message at." allowed_actions :write diff --git a/lib/chef/resource/registry_key.rb b/lib/chef/resource/registry_key.rb index cd4edda5a9..a5c99313bf 100644 --- a/lib/chef/resource/registry_key.rb +++ b/lib/chef/resource/registry_key.rb @@ -88,7 +88,7 @@ class Chef raise ArgumentError, "Missing name key in RegistryKey values hash" unless v.key?(:name) v.each_key do |key| - raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless [:name, :type, :data].include?(key) + raise ArgumentError, "Bad key #{key} in RegistryKey values hash" unless %i{name type data}.include?(key) end raise ArgumentError, "Type of name => #{v[:name]} should be string" unless v[:name].is_a?(String) @@ -103,7 +103,7 @@ class Chef end property :recursive, [TrueClass, FalseClass], default: false - property :architecture, Symbol, default: :machine, equal_to: [:machine, :x86_64, :i386] + property :architecture, Symbol, default: :machine, equal_to: %i{machine x86_64 i386} private @@ -123,7 +123,7 @@ class Chef # Some data types may raise errors when sent as json. Returns true if this # value's data may need to be converted to a checksum. def needs_checksum?(value) - unsafe_types = [:binary, :dword, :dword_big_endian, :qword] + unsafe_types = %i{binary dword dword_big_endian qword} unsafe_types.include?(value[:type]) end diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index d654829ee7..7dcfeb3c2c 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -98,7 +98,7 @@ class Chef property :remote_password, String, sensitive: true - property :authentication, equal_to: [:remote, :local], default: :remote + property :authentication, equal_to: %i{remote local}, default: :remote def after_created validate_identity_platform(remote_user, remote_password, remote_domain) diff --git a/lib/chef/resource/route.rb b/lib/chef/resource/route.rb index 42302afe6a..ecd63966cf 100644 --- a/lib/chef/resource/route.rb +++ b/lib/chef/resource/route.rb @@ -50,7 +50,7 @@ class Chef property :route_type, [Symbol, String], description: "", - equal_to: [:host, :net], default: :host, desired_state: false + equal_to: %i{host net}, default: :host, desired_state: false end end end diff --git a/lib/chef/resource/windows_ad_join.rb b/lib/chef/resource/windows_ad_join.rb index e62b931a75..23faa60ee5 100644 --- a/lib/chef/resource/windows_ad_join.rb +++ b/lib/chef/resource/windows_ad_join.rb @@ -48,7 +48,7 @@ class Chef description: "The path to the Organizational Unit where the host will be placed." property :reboot, Symbol, - equal_to: [:immediate, :delayed, :never, :request_reboot, :reboot_now], + equal_to: %i{immediate delayed never request_reboot reboot_now}, validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)", description: "Controls the system reboot behavior post domain joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", default: :immediate diff --git a/lib/chef/resource/windows_feature.rb b/lib/chef/resource/windows_feature.rb index e937c6f990..cc80284019 100644 --- a/lib/chef/resource/windows_feature.rb +++ b/lib/chef/resource/windows_feature.rb @@ -44,7 +44,7 @@ class Chef property :install_method, Symbol, description: "The underlying installation method to use for feature installation. Specify ':windows_feature_dism' for DISM or ':windows_feature_powershell' for PowerShell.", - equal_to: [:windows_feature_dism, :windows_feature_powershell, :windows_feature_servermanagercmd], + equal_to: %i{windows_feature_dism windows_feature_powershell windows_feature_servermanagercmd}, default: :windows_feature_dism property :timeout, Integer, diff --git a/lib/chef/resource/windows_firewall_rule.rb b/lib/chef/resource/windows_firewall_rule.rb index f933ba9139..5ac38bc8b7 100644 --- a/lib/chef/resource/windows_firewall_rule.rb +++ b/lib/chef/resource/windows_firewall_rule.rb @@ -54,7 +54,7 @@ class Chef description: "The remote port the firewall rule applies to." property :direction, [Symbol, String], - default: :inbound, equal_to: [:inbound, :outbound], + default: :inbound, equal_to: %i{inbound outbound}, description: "The direction of the firewall rule. Direction means either inbound or outbound traffic.", coerce: proc { |d| d.is_a?(String) ? d.downcase.to_sym : d } @@ -63,12 +63,12 @@ class Chef description: "The protocol the firewall rule applies to." property :firewall_action, [Symbol, String], - default: :allow, equal_to: [:allow, :block, :notconfigured], + default: :allow, equal_to: %i{allow block notconfigured}, description: "The action of the firewall rule.", coerce: proc { |f| f.is_a?(String) ? f.downcase.to_sym : f } property :profile, [Symbol, String], - default: :any, equal_to: [:public, :private, :domain, :any, :notapplicable], + default: :any, equal_to: %i{public private domain any notapplicable}, description: "The profile the firewall rule applies to.", coerce: proc { |p| p.is_a?(String) ? p.downcase.to_sym : p } @@ -79,7 +79,7 @@ class Chef description: "The service the firewall rule applies to." property :interface_type, [Symbol, String], - default: :any, equal_to: [:any, :wireless, :wired, :remoteaccess], + default: :any, equal_to: %i{any wireless wired remoteaccess}, description: "The interface type the firewall rule applies to.", coerce: proc { |i| i.is_a?(String) ? i.downcase.to_sym : i } diff --git a/lib/chef/resource/windows_service.rb b/lib/chef/resource/windows_service.rb index 91c3450603..b8ee4edf9c 100644 --- a/lib/chef/resource/windows_service.rb +++ b/lib/chef/resource/windows_service.rb @@ -58,7 +58,7 @@ class Chef # - :manual # - :disabled # Reference: https://github.com/chef/win32-service/blob/ffi/lib/win32/windows/constants.rb#L49-L54 - property :startup_type, [Symbol], equal_to: [:automatic, :manual, :disabled], default: :automatic, coerce: proc { |x| + property :startup_type, [Symbol], equal_to: %i{automatic manual disabled}, default: :automatic, coerce: proc { |x| if x.is_a?(Integer) ALLOWED_START_TYPES.invert.fetch(x) do Chef::Log.warn("Unsupported startup_type #{x}, falling back to :automatic") diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb index db3eb11b96..0ce5bf2031 100644 --- a/lib/chef/resource/windows_task.rb +++ b/lib/chef/resource/windows_task.rb @@ -49,7 +49,7 @@ class Chef property :password, String, description: "The user’s password. The user property must be set if using this property." - property :run_level, Symbol, equal_to: [:highest, :limited], + property :run_level, Symbol, equal_to: %i{highest limited}, description: "Run with ':limited' or ':highest' privileges.", default: :limited @@ -64,16 +64,16 @@ class Chef property :frequency_modifier, [Integer, String], default: 1 - property :frequency, Symbol, equal_to: [:minute, - :hourly, - :daily, - :weekly, - :monthly, - :once, - :on_logon, - :onstart, - :on_idle, - :none], + property :frequency, Symbol, equal_to: %i{minute + hourly + daily + weekly + monthly + once + on_logon + onstart + on_idle + none}, description: "The frequency with which to run the task." property :start_day, String, @@ -175,7 +175,7 @@ class Chef end def validate_frequency(frequency) - if frequency.nil? || !([:minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none].include?(frequency)) + if frequency.nil? || !(%i{minute hourly daily weekly monthly once on_logon onstart on_idle none}.include?(frequency)) raise ArgumentError, "Frequency needs to be provided. Valid frequencies are :minute, :hourly, :daily, :weekly, :monthly, :once, :on_logon, :onstart, :on_idle, :none." end end @@ -201,7 +201,7 @@ class Chef end def validate_random_delay(random_delay, frequency) - if [:on_logon, :onstart, :on_idle, :none].include? frequency + if %i{on_logon onstart on_idle none}.include? frequency raise ArgumentError, "`random_delay` property is supported only for frequency :once, :minute, :hourly, :daily, :weekly and :monthly" end @@ -256,7 +256,7 @@ class Chef alias non_system_user? password_required? def validate_create_frequency_modifier(frequency, frequency_modifier) - if ([:on_logon, :onstart, :on_idle, :none].include?(frequency)) && ( frequency_modifier != 1) + if (%i{on_logon onstart on_idle none}.include?(frequency)) && ( frequency_modifier != 1) raise ArgumentError, "frequency_modifier property not supported with frequency :#{frequency}" end @@ -288,7 +288,7 @@ class Chef end def validate_create_day(day, frequency, frequency_modifier) - raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless [:weekly, :monthly].include?(frequency) + raise ArgumentError, "day property is only valid for tasks that run monthly or weekly" unless %i{weekly monthly}.include?(frequency) # This has been verified with schtask.exe https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks#d-dayday-- # verified with earlier code if day "*" is given with frequency it raised exception Invalid value for /D option diff --git a/lib/chef/resource/windows_uac.rb b/lib/chef/resource/windows_uac.rb index f53767f4b8..c4d5b53c14 100644 --- a/lib/chef/resource/windows_uac.rb +++ b/lib/chef/resource/windows_uac.rb @@ -44,12 +44,12 @@ class Chef property :consent_behavior_admins, Symbol, description: 'Behavior of the elevation prompt for administrators in Admin Approval Mode. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorAdmin.', - equal_to: [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries], + equal_to: %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}, default: :prompt_for_consent_non_windows_binaries property :consent_behavior_users, Symbol, description: 'Behavior of the elevation prompt for standard users. Sets HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA\ConsentPromptBehaviorUser.', - equal_to: [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds], + equal_to: %i{auto_deny secure_prompt_for_creds prompt_for_creds}, default: :prompt_for_creds action :configure do @@ -79,14 +79,14 @@ class Chef # # @return [Integer] def consent_behavior_admins_symbol_to_reg(sym) - [:no_prompt, :secure_prompt_for_creds, :secure_prompt_for_consent, :prompt_for_creds, :prompt_for_consent, :prompt_for_consent_non_windows_binaries].index(sym) + %i{no_prompt secure_prompt_for_creds secure_prompt_for_consent prompt_for_creds prompt_for_consent prompt_for_consent_non_windows_binaries}.index(sym) end # converts the symbols we use in the consent_behavior_users property into numbers 0-2 based on their array index # # @return [Integer] def consent_behavior_users_symbol_to_reg(sym) - [:auto_deny, :secure_prompt_for_creds, :prompt_for_creds].index(sym) + %i{auto_deny secure_prompt_for_creds prompt_for_creds}.index(sym) end end end diff --git a/lib/chef/resource/windows_workgroup.rb b/lib/chef/resource/windows_workgroup.rb index f455c013af..b1ae5c2b95 100644 --- a/lib/chef/resource/windows_workgroup.rb +++ b/lib/chef/resource/windows_workgroup.rb @@ -45,7 +45,7 @@ class Chef desired_state: false property :reboot, Symbol, - equal_to: [:never, :request_reboot, :reboot_now], + equal_to: %i{never request_reboot reboot_now}, validation_message: "The reboot property accepts :immediate (reboot as soon as the resource completes), :delayed (reboot once the #{Chef::Dist::PRODUCT} run completes), and :never (Don't reboot)", description: "Controls the system reboot behavior post workgroup joining. Reboot immediately, after the #{Chef::Dist::PRODUCT} run completes, or never. Note that a reboot is necessary for changes to take effect.", coerce: proc { |x| clarify_reboot(x) }, diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb index 716f84b92c..31cc917a9f 100644 --- a/lib/chef/resource_collection.rb +++ b/lib/chef/resource_collection.rb @@ -87,9 +87,9 @@ class Chef # Read-only methods are simple to delegate - doing that below resource_list_methods = Enumerable.instance_methods + - [:iterator, :all_resources, :[], :each, :execute_each_resource, :each_index, :empty?] - + %i{iterator all_resources \[\] each execute_each_resource each_index empty?} - [:find] # find overridden below - resource_set_methods = [:resources, :keys, :validate_lookup_spec!] + resource_set_methods = %i{resources keys validate_lookup_spec!} def_delegators :resource_list, *resource_list_methods def_delegators :resource_set, *resource_set_methods diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb index 8afbd5dd06..5f69908a5e 100644 --- a/lib/chef/resource_collection/resource_list.rb +++ b/lib/chef/resource_collection/resource_list.rb @@ -36,7 +36,7 @@ class Chef private :resources # Delegate direct access methods to the @resources array # 4 extra methods here are not included in the Enumerable's instance methods - direct_access_methods = Enumerable.instance_methods + [ :[], :each, :each_index, :empty? ] + direct_access_methods = Enumerable.instance_methods + %i{\[\] each each_index empty?} def_delegators :resources, *(direct_access_methods) def initialize diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb index f98673b019..68acaf1e44 100644 --- a/lib/chef/version_class.rb +++ b/lib/chef/version_class.rb @@ -33,7 +33,7 @@ class Chef end def <=>(other) - [:major, :minor, :patch].each do |method| + %i{major minor patch}.each do |method| version = send(method) begin ans = (version <=> other.send(method)) diff --git a/lib/chef/win32/api/crypto.rb b/lib/chef/win32/api/crypto.rb index 1b73ac65d1..13828dd62a 100644 --- a/lib/chef/win32/api/crypto.rb +++ b/lib/chef/win32/api/crypto.rb @@ -47,15 +47,15 @@ class Chef end - safe_attach_function :CryptProtectData, [ - :PDATA_BLOB, - :LPCWSTR, - :PDATA_BLOB, - :pointer, - :PCRYPTPROTECT_PROMPTSTRUCT, - :DWORD, - :PDATA_BLOB, - ], :BOOL + safe_attach_function :CryptProtectData, %i{ + PDATA_BLOB + LPCWSTR + PDATA_BLOB + pointer + PCRYPTPROTECT_PROMPTSTRUCT + DWORD + PDATA_BLOB + }, :BOOL end end diff --git a/lib/chef/win32/api/error.rb b/lib/chef/win32/api/error.rb index 618ce266f6..79b65c8509 100644 --- a/lib/chef/win32/api/error.rb +++ b/lib/chef/win32/api/error.rb @@ -905,8 +905,8 @@ DWORD WINAPI FormatMessage( __in_opt va_list *Arguments ); =end - safe_attach_function :FormatMessageA, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPTSTR, :DWORD, :varargs], :DWORD - safe_attach_function :FormatMessageW, [:DWORD, :HANDLE, :DWORD, :DWORD, :LPWSTR, :DWORD, :varargs], :DWORD + safe_attach_function :FormatMessageA, %i{DWORD HANDLE DWORD DWORD LPTSTR DWORD varargs}, :DWORD + safe_attach_function :FormatMessageW, %i{DWORD HANDLE DWORD DWORD LPWSTR DWORD varargs}, :DWORD =begin DWORD WINAPI GetLastError(void); @@ -918,7 +918,7 @@ void WINAPI SetLastError( ); =end safe_attach_function :SetLastError, [:DWORD], :void - safe_attach_function :SetLastErrorEx, [:DWORD, :DWORD], :void + safe_attach_function :SetLastErrorEx, %i{DWORD DWORD}, :void =begin UINT WINAPI GetErrorMode(void);s =end @@ -938,7 +938,7 @@ HMODULE WINAPI LoadLibraryEx( _In_ DWORD dwFlags ); =end - safe_attach_function :LoadLibraryExW, [:LPCTSTR, :HANDLE, :DWORD], :HANDLE + safe_attach_function :LoadLibraryExW, %i{LPCTSTR HANDLE DWORD}, :HANDLE =begin https://msdn.microsoft.com/en-us/library/windows/desktop/ms683152(v=vs.85).aspx diff --git a/lib/chef/win32/api/file.rb b/lib/chef/win32/api/file.rb index eea46ce87d..bdc2d6f6e5 100644 --- a/lib/chef/win32/api/file.rb +++ b/lib/chef/win32/api/file.rb @@ -369,7 +369,7 @@ HANDLE WINAPI CreateFile( __in_opt HANDLE hTemplateFile ); =end - safe_attach_function :CreateFileW, [:LPCTSTR, :DWORD, :DWORD, :LPSECURITY_ATTRIBUTES, :DWORD, :DWORD, :pointer], :HANDLE + safe_attach_function :CreateFileW, %i{LPCTSTR DWORD DWORD LPSECURITY_ATTRIBUTES DWORD DWORD pointer}, :HANDLE =begin BOOL WINAPI FindClose( @@ -393,7 +393,7 @@ DWORD WINAPI GetFinalPathNameByHandle( __in DWORD dwFlags ); =end - safe_attach_function :GetFinalPathNameByHandleW, [:HANDLE, :LPTSTR, :DWORD, :DWORD], :DWORD + safe_attach_function :GetFinalPathNameByHandleW, %i{HANDLE LPTSTR DWORD DWORD}, :DWORD =begin BOOL WINAPI GetFileInformationByHandle( @@ -401,7 +401,7 @@ BOOL WINAPI GetFileInformationByHandle( __out LPBY_HANDLE_FILE_INFORMATION lpFileInformation ); =end - safe_attach_function :GetFileInformationByHandle, [:HANDLE, :LPBY_HANDLE_FILE_INFORMATION], :BOOL + safe_attach_function :GetFileInformationByHandle, %i{HANDLE LPBY_HANDLE_FILE_INFORMATION}, :BOOL =begin HANDLE WINAPI FindFirstFile( @@ -409,7 +409,7 @@ HANDLE WINAPI FindFirstFile( __out LPWIN32_FIND_DATA lpFindFileData ); =end - safe_attach_function :FindFirstFileW, [:LPCTSTR, :LPWIN32_FIND_DATA], :HANDLE + safe_attach_function :FindFirstFileW, %i{LPCTSTR LPWIN32_FIND_DATA}, :HANDLE =begin BOOL WINAPI CreateHardLink( @@ -418,7 +418,7 @@ BOOL WINAPI CreateHardLink( __reserved LPSECURITY_ATTRIBUTES lpSecurityAttributes ); =end - safe_attach_function :CreateHardLinkW, [:LPCTSTR, :LPCTSTR, :LPSECURITY_ATTRIBUTES], :BOOLEAN + safe_attach_function :CreateHardLinkW, %i{LPCTSTR LPCTSTR LPSECURITY_ATTRIBUTES}, :BOOLEAN =begin BOOLEAN WINAPI CreateSymbolicLink( @@ -427,7 +427,7 @@ BOOLEAN WINAPI CreateSymbolicLink( __in DWORD dwFlags ); =end - safe_attach_function :CreateSymbolicLinkW, [:LPTSTR, :LPTSTR, :DWORD], :BOOLEAN + safe_attach_function :CreateSymbolicLinkW, %i{LPTSTR LPTSTR DWORD}, :BOOLEAN =begin DWORD WINAPI GetLongPathName( @@ -436,7 +436,7 @@ DWORD WINAPI GetLongPathName( __in DWORD cchBuffer ); =end - safe_attach_function :GetLongPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD + safe_attach_function :GetLongPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD =begin DWORD WINAPI GetShortPathName( @@ -445,7 +445,7 @@ DWORD WINAPI GetShortPathName( __in DWORD cchBuffer ); =end - safe_attach_function :GetShortPathNameW, [:LPCTSTR, :LPTSTR, :DWORD], :DWORD + safe_attach_function :GetShortPathNameW, %i{LPCTSTR LPTSTR DWORD}, :DWORD =begin BOOL WINAPI DeviceIoControl( @@ -459,7 +459,7 @@ BOOL WINAPI DeviceIoControl( __inout_opt LPOVERLAPPED lpOverlapped ); =end - safe_attach_function :DeviceIoControl, [:HANDLE, :DWORD, :LPVOID, :DWORD, :LPVOID, :DWORD, :LPDWORD, :pointer], :BOOL + safe_attach_function :DeviceIoControl, %i{HANDLE DWORD LPVOID DWORD LPVOID DWORD LPDWORD pointer}, :BOOL # BOOL WINAPI DeleteVolumeMountPoint( # _In_ LPCTSTR lpszVolumeMountPoint @@ -470,14 +470,14 @@ BOOL WINAPI DeviceIoControl( # _In_ LPCTSTR lpszVolumeMountPoint, # _In_ LPCTSTR lpszVolumeName # ); - safe_attach_function :SetVolumeMountPointW, [:LPCTSTR, :LPCTSTR], :BOOL + safe_attach_function :SetVolumeMountPointW, %i{LPCTSTR LPCTSTR}, :BOOL # BOOL WINAPI GetVolumeNameForVolumeMountPoint( # _In_ LPCTSTR lpszVolumeMountPoint, # _Out_ LPTSTR lpszVolumeName, # _In_ DWORD cchBufferLength # ); - safe_attach_function :GetVolumeNameForVolumeMountPointW, [:LPCTSTR, :LPTSTR, :DWORD], :BOOL + safe_attach_function :GetVolumeNameForVolumeMountPointW, %i{LPCTSTR LPTSTR DWORD}, :BOOL =begin BOOL WINAPI GetFileVersionInfo( @@ -487,7 +487,7 @@ BOOL WINAPI GetFileVersionInfo( _Out_ LPVOID lpData ); =end - safe_attach_function :GetFileVersionInfoW, [:LPCTSTR, :DWORD, :DWORD, :LPVOID], :BOOL + safe_attach_function :GetFileVersionInfoW, %i{LPCTSTR DWORD DWORD LPVOID}, :BOOL =begin DWORD WINAPI GetFileVersionInfoSize( @@ -495,7 +495,7 @@ DWORD WINAPI GetFileVersionInfoSize( _Out_opt_ LPDWORD lpdwHandle ); =end - safe_attach_function :GetFileVersionInfoSizeW, [:LPCTSTR, :LPDWORD], :DWORD + safe_attach_function :GetFileVersionInfoSizeW, %i{LPCTSTR LPDWORD}, :DWORD =begin BOOL WINAPI VerQueryValue( @@ -505,7 +505,7 @@ BOOL WINAPI VerQueryValue( _Out_ PUINT puLen ); =end - safe_attach_function :VerQueryValueW, [:LPCVOID, :LPCTSTR, :LPVOID, :PUINT], :BOOL + safe_attach_function :VerQueryValueW, %i{LPCVOID LPCTSTR LPVOID PUINT}, :BOOL ############################################### # Helpers diff --git a/lib/chef/win32/api/installer.rb b/lib/chef/win32/api/installer.rb index 118afe8c8f..5af1be7eba 100644 --- a/lib/chef/win32/api/installer.rb +++ b/lib/chef/win32/api/installer.rb @@ -44,7 +44,7 @@ UINT MsiOpenPackage( _Out_ MSIHANDLE *hProduct ); =end - safe_attach_function :msi_open_package, :MsiOpenPackageExA, [ :string, :int, :pointer ], :int + safe_attach_function :msi_open_package, :MsiOpenPackageExA, %i{string int pointer}, :int =begin UINT MsiGetProductProperty( @@ -54,7 +54,7 @@ UINT MsiGetProductProperty( _Inout_ DWORD *pcchValueBuf ); =end - safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, [ :pointer, :pointer, :pointer, :pointer ], :int + safe_attach_function :msi_get_product_property, :MsiGetProductPropertyA, %i{pointer pointer pointer pointer}, :int =begin UINT MsiGetProductInfo( @@ -64,7 +64,7 @@ UINT MsiGetProductInfo( _Inout_ DWORD *pcchValueBuf ); =end - safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, [ :pointer, :pointer, :pointer, :pointer ], :int + safe_attach_function :msi_get_product_info, :MsiGetProductInfoA, %i{pointer pointer pointer pointer}, :int =begin UINT MsiCloseHandle( diff --git a/lib/chef/win32/api/memory.rb b/lib/chef/win32/api/memory.rb index 369ab5e650..cd7d9f0eb0 100644 --- a/lib/chef/win32/api/memory.rb +++ b/lib/chef/win32/api/memory.rb @@ -56,7 +56,7 @@ HLOCAL WINAPI LocalAlloc( __in SIZE_T uBytes ); =end - safe_attach_function :LocalAlloc, [ :UINT, :SIZE_T ], :pointer + safe_attach_function :LocalAlloc, %i{UINT SIZE_T}, :pointer =begin UINT WINAPI LocalFlags( @@ -79,7 +79,7 @@ HLOCAL WINAPI LocalReAlloc( __in UINT uFlags ); =end - safe_attach_function :LocalReAlloc, [ :pointer, :SIZE_T, :UINT ], :pointer + safe_attach_function :LocalReAlloc, %i{pointer SIZE_T UINT}, :pointer =begin UINT WINAPI LocalSize( @@ -95,9 +95,9 @@ UINT WINAPI LocalSize( ffi_lib FFI::Library::LIBC safe_attach_function :malloc, [:size_t], :pointer safe_attach_function :calloc, [:size_t], :pointer - safe_attach_function :realloc, [:pointer, :size_t], :pointer + safe_attach_function :realloc, %i{pointer size_t}, :pointer safe_attach_function :free, [:pointer], :void - safe_attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer + safe_attach_function :memcpy, %i{pointer pointer size_t}, :pointer end end diff --git a/lib/chef/win32/api/net.rb b/lib/chef/win32/api/net.rb index 392a442962..182c31cf66 100644 --- a/lib/chef/win32/api/net.rb +++ b/lib/chef/win32/api/net.rb @@ -169,9 +169,9 @@ class Chef # _In_ LPBYTE buf, # _Out_ LPDWORD parm_err # ); - safe_attach_function :NetLocalGroupAdd, [ - :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD - ], :DWORD + safe_attach_function :NetLocalGroupAdd, %i{ + LPCWSTR DWORD LPBYTE LPDWORD + }, :DWORD # NET_API_STATUS NetLocalGroupSetInfo( # _In_ LPCWSTR servername, @@ -180,15 +180,15 @@ class Chef # _In_ LPBYTE buf, # _Out_ LPDWORD parm_err # ); - safe_attach_function :NetLocalGroupSetInfo, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD - ], :DWORD + safe_attach_function :NetLocalGroupSetInfo, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD + }, :DWORD # NET_API_STATUS NetLocalGroupDel( # _In_ LPCWSTR servername, # _In_ LPCWSTR groupname # ); - safe_attach_function :NetLocalGroupDel, [:LPCWSTR, :LPCWSTR], :DWORD + safe_attach_function :NetLocalGroupDel, %i{LPCWSTR LPCWSTR}, :DWORD # NET_API_STATUS NetLocalGroupGetMembers( # _In_ LPCWSTR servername, @@ -200,10 +200,10 @@ class Chef # _Out_ LPDWORD totalentries, # _Inout_ PDWORD_PTR resumehandle # ); - safe_attach_function :NetLocalGroupGetMembers, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD, - :LPDWORD, :LPDWORD, :PDWORD_PTR - ], :DWORD + safe_attach_function :NetLocalGroupGetMembers, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE DWORD + LPDWORD LPDWORD PDWORD_PTR + }, :DWORD # NET_API_STATUS NetUserEnum( # _In_ LPCWSTR servername, @@ -215,10 +215,10 @@ class Chef # _Out_ LPDWORD totalentries, # _Inout_ LPDWORD resume_handle # ); - safe_attach_function :NetUserEnum, [ - :LPCWSTR, :DWORD, :DWORD, :LPBYTE, - :DWORD, :LPDWORD, :LPDWORD, :LPDWORD - ], :DWORD + safe_attach_function :NetUserEnum, %i{ + LPCWSTR DWORD DWORD LPBYTE + DWORD LPDWORD LPDWORD LPDWORD + }, :DWORD # NET_API_STATUS NetApiBufferFree( # _In_ LPVOID Buffer @@ -231,9 +231,9 @@ class Chef # _In_ LPBYTE buf, # _Out_ LPDWORD parm_err # ); - safe_attach_function :NetUserAdd, [ - :LMSTR, :DWORD, :LPBYTE, :LPDWORD - ], :DWORD + safe_attach_function :NetUserAdd, %i{ + LMSTR DWORD LPBYTE LPDWORD + }, :DWORD # NET_API_STATUS NetLocalGroupAddMembers( # _In_ LPCWSTR servername, @@ -242,9 +242,9 @@ class Chef # _In_ LPBYTE buf, # _In_ DWORD totalentries # ); - safe_attach_function :NetLocalGroupAddMembers, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD - ], :DWORD + safe_attach_function :NetLocalGroupAddMembers, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE DWORD + }, :DWORD # NET_API_STATUS NetLocalGroupSetMembers( # _In_ LPCWSTR servername, @@ -253,9 +253,9 @@ class Chef # _In_ LPBYTE buf, # _In_ DWORD totalentries # ); - safe_attach_function :NetLocalGroupSetMembers, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD - ], :DWORD + safe_attach_function :NetLocalGroupSetMembers, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE DWORD + }, :DWORD # NET_API_STATUS NetLocalGroupDelMembers( # _In_ LPCWSTR servername, @@ -264,9 +264,9 @@ class Chef # _In_ LPBYTE buf, # _In_ DWORD totalentries # ); - safe_attach_function :NetLocalGroupDelMembers, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :DWORD - ], :DWORD + safe_attach_function :NetLocalGroupDelMembers, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE DWORD + }, :DWORD # NET_API_STATUS NetUserGetInfo( # _In_ LPCWSTR servername, @@ -274,9 +274,9 @@ class Chef # _In_ DWORD level, # _Out_ LPBYTE *bufptr # ); - safe_attach_function :NetUserGetInfo, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE - ], :DWORD + safe_attach_function :NetUserGetInfo, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE + }, :DWORD # NET_API_STATUS NetApiBufferFree( # _In_ LPVOID Buffer @@ -290,22 +290,22 @@ class Chef # _In_ LPBYTE buf, # _Out_ LPDWORD parm_err # ); - safe_attach_function :NetUserSetInfo, [ - :LPCWSTR, :LPCWSTR, :DWORD, :LPBYTE, :LPDWORD - ], :DWORD + safe_attach_function :NetUserSetInfo, %i{ + LPCWSTR LPCWSTR DWORD LPBYTE LPDWORD + }, :DWORD # NET_API_STATUS NetUserDel( # _In_ LPCWSTR servername, # _In_ LPCWSTR username # ); - safe_attach_function :NetUserDel, [:LPCWSTR, :LPCWSTR], :DWORD + safe_attach_function :NetUserDel, %i{LPCWSTR LPCWSTR}, :DWORD # NET_API_STATUS NetUseDel( # _In_ LMSTR UncServerName, # _In_ LMSTR UseName, # _In_ DWORD ForceCond # ); - safe_attach_function :NetUseDel, [:LMSTR, :LMSTR, :DWORD], :DWORD + safe_attach_function :NetUseDel, %i{LMSTR LMSTR DWORD}, :DWORD # NET_API_STATUS NetUseGetInfo( # _In_ LMSTR UncServerName, @@ -313,7 +313,7 @@ class Chef # _In_ DWORD Level, # _Out_ LPBYTE *BufPtr # ); - safe_attach_function :NetUseGetInfo, [:LMSTR, :LMSTR, :DWORD, :pointer], :DWORD + safe_attach_function :NetUseGetInfo, %i{LMSTR LMSTR DWORD pointer}, :DWORD # NET_API_STATUS NetUseAdd( # _In_ LMSTR UncServerName, @@ -321,7 +321,7 @@ class Chef # _In_ LPBYTE Buf, # _Out_ LPDWORD ParmError # ); - safe_attach_function :NetUseAdd, [:LMSTR, :DWORD, :LPBYTE, :LPDWORD], :DWORD + safe_attach_function :NetUseAdd, %i{LMSTR DWORD LPBYTE LPDWORD}, :DWORD end end end diff --git a/lib/chef/win32/api/process.rb b/lib/chef/win32/api/process.rb index 3ac6a5c222..81a411e099 100644 --- a/lib/chef/win32/api/process.rb +++ b/lib/chef/win32/api/process.rb @@ -31,10 +31,10 @@ class Chef ffi_lib "kernel32" safe_attach_function :GetCurrentProcess, [], :HANDLE - safe_attach_function :GetProcessHandleCount, [ :HANDLE, :LPDWORD ], :BOOL + safe_attach_function :GetProcessHandleCount, %i{HANDLE LPDWORD}, :BOOL safe_attach_function :GetProcessId, [ :HANDLE ], :DWORD safe_attach_function :CloseHandle, [ :HANDLE ], :BOOL - safe_attach_function :IsWow64Process, [ :HANDLE, :PBOOL ], :BOOL + safe_attach_function :IsWow64Process, %i{HANDLE PBOOL}, :BOOL end end diff --git a/lib/chef/win32/api/psapi.rb b/lib/chef/win32/api/psapi.rb index 852cb9710b..491fe22c50 100644 --- a/lib/chef/win32/api/psapi.rb +++ b/lib/chef/win32/api/psapi.rb @@ -43,7 +43,7 @@ class Chef ffi_lib "psapi" - safe_attach_function :GetProcessMemoryInfo, [ :HANDLE, :pointer, :DWORD ], :BOOL + safe_attach_function :GetProcessMemoryInfo, %i{HANDLE pointer DWORD}, :BOOL end end diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb index c368add37a..49f0da0010 100644 --- a/lib/chef/win32/api/registry.rb +++ b/lib/chef/win32/api/registry.rb @@ -36,14 +36,14 @@ class Chef # _In_ REGSAM samDesired, # _Reserved_ DWORD Reserved # ); - safe_attach_function :RegDeleteKeyExW, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG - safe_attach_function :RegDeleteKeyExA, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG + safe_attach_function :RegDeleteKeyExW, %i{HKEY LPCTSTR LONG DWORD}, :LONG + safe_attach_function :RegDeleteKeyExA, %i{HKEY LPCTSTR LONG DWORD}, :LONG # LONG WINAPI RegDeleteValue( # _In_ HKEY hKey, # _In_opt_ LPCTSTR lpValueName # ); - safe_attach_function :RegDeleteValueW, [ :HKEY, :LPCTSTR ], :LONG + safe_attach_function :RegDeleteValueW, %i{HKEY LPCTSTR}, :LONG end end diff --git a/lib/chef/win32/api/security.rb b/lib/chef/win32/api/security.rb index a856fbd0a1..b651283758 100644 --- a/lib/chef/win32/api/security.rb +++ b/lib/chef/win32/api/security.rb @@ -216,21 +216,21 @@ class Chef # Win32 API Bindings ############################################### - SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, [ - :SE_UNKNOWN_OBJECT_TYPE, - :SE_FILE_OBJECT, - :SE_SERVICE, - :SE_PRINTER, - :SE_REGISTRY_KEY, - :SE_LMSHARE, - :SE_KERNEL_OBJECT, - :SE_WINDOW_OBJECT, - :SE_DS_OBJECT, - :SE_DS_OBJECT_ALL, - :SE_PROVIDER_DEFINED_OBJECT, - :SE_WMIGUID_OBJECT, - :SE_REGISTRY_WOW64_32KEY, - ] + SE_OBJECT_TYPE = enum :SE_OBJECT_TYPE, %i{ + SE_UNKNOWN_OBJECT_TYPE + SE_FILE_OBJECT + SE_SERVICE + SE_PRINTER + SE_REGISTRY_KEY + SE_LMSHARE + SE_KERNEL_OBJECT + SE_WINDOW_OBJECT + SE_DS_OBJECT + SE_DS_OBJECT_ALL + SE_PROVIDER_DEFINED_OBJECT + SE_WMIGUID_OBJECT + SE_REGISTRY_WOW64_32KEY + } SID_NAME_USE = enum :SID_NAME_USE, [ :SidTypeUser, 1, @@ -298,12 +298,12 @@ class Chef end # https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572%28v=vs.85%29.aspx - SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, [ - :SecurityAnonymous, - :SecurityIdentification, - :SecurityImpersonation, - :SecurityDelegation, - ] + SECURITY_IMPERSONATION_LEVEL = enum :SECURITY_IMPERSONATION_LEVEL, %i{ + SecurityAnonymous + SecurityIdentification + SecurityImpersonation + SecurityDelegation + } # https://msdn.microsoft.com/en-us/library/windows/desktop/bb530718%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 ELEVATION_TYPE = enum :ELEVATION_TYPE, [ @@ -415,58 +415,58 @@ class Chef ffi_lib "advapi32" - safe_attach_function :AccessCheck, [:pointer, :HANDLE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer], :BOOL - safe_attach_function :AddAce, [ :pointer, :DWORD, :DWORD, :LPVOID, :DWORD ], :BOOL - safe_attach_function :AddAccessAllowedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL - safe_attach_function :AddAccessAllowedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL - safe_attach_function :AddAccessDeniedAce, [ :pointer, :DWORD, :DWORD, :pointer ], :BOOL - safe_attach_function :AddAccessDeniedAceEx, [ :pointer, :DWORD, :DWORD, :DWORD, :pointer ], :BOOL - safe_attach_function :AdjustTokenPrivileges, [ :HANDLE, :BOOL, :pointer, :DWORD, :pointer, :PDWORD ], :BOOL - safe_attach_function :ConvertSidToStringSidA, [ :pointer, :pointer ], :BOOL - safe_attach_function :ConvertStringSidToSidW, [ :pointer, :pointer ], :BOOL - safe_attach_function :DeleteAce, [ :pointer, :DWORD ], :BOOL - safe_attach_function :DuplicateToken, [:HANDLE, :SECURITY_IMPERSONATION_LEVEL, :PHANDLE], :BOOL - safe_attach_function :EqualSid, [ :pointer, :pointer ], :BOOL + safe_attach_function :AccessCheck, %i{pointer HANDLE DWORD pointer pointer pointer pointer pointer}, :BOOL + safe_attach_function :AddAce, %i{pointer DWORD DWORD LPVOID DWORD}, :BOOL + safe_attach_function :AddAccessAllowedAce, %i{pointer DWORD DWORD pointer}, :BOOL + safe_attach_function :AddAccessAllowedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL + safe_attach_function :AddAccessDeniedAce, %i{pointer DWORD DWORD pointer}, :BOOL + safe_attach_function :AddAccessDeniedAceEx, %i{pointer DWORD DWORD DWORD pointer}, :BOOL + safe_attach_function :AdjustTokenPrivileges, %i{HANDLE BOOL pointer DWORD pointer PDWORD}, :BOOL + safe_attach_function :ConvertSidToStringSidA, %i{pointer pointer}, :BOOL + safe_attach_function :ConvertStringSidToSidW, %i{pointer pointer}, :BOOL + safe_attach_function :DeleteAce, %i{pointer DWORD}, :BOOL + safe_attach_function :DuplicateToken, %i{HANDLE SECURITY_IMPERSONATION_LEVEL PHANDLE}, :BOOL + safe_attach_function :EqualSid, %i{pointer pointer}, :BOOL safe_attach_function :FreeSid, [ :pointer ], :pointer - safe_attach_function :GetAce, [ :pointer, :DWORD, :pointer ], :BOOL - safe_attach_function :GetFileSecurityW, [:LPCWSTR, :DWORD, :pointer, :DWORD, :pointer], :BOOL + safe_attach_function :GetAce, %i{pointer DWORD pointer}, :BOOL + safe_attach_function :GetFileSecurityW, %i{LPCWSTR DWORD pointer DWORD pointer}, :BOOL safe_attach_function :GetLengthSid, [ :pointer ], :DWORD - safe_attach_function :GetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer, :pointer ], :DWORD - safe_attach_function :GetSecurityDescriptorControl, [ :pointer, :PWORD, :LPDWORD], :BOOL - safe_attach_function :GetSecurityDescriptorDacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL - safe_attach_function :GetSecurityDescriptorGroup, [ :pointer, :pointer, :LPBOOL], :BOOL - safe_attach_function :GetSecurityDescriptorOwner, [ :pointer, :pointer, :LPBOOL], :BOOL - safe_attach_function :GetSecurityDescriptorSacl, [ :pointer, :LPBOOL, :pointer, :LPBOOL ], :BOOL - safe_attach_function :InitializeAcl, [ :pointer, :DWORD, :DWORD ], :BOOL - safe_attach_function :InitializeSecurityDescriptor, [ :pointer, :DWORD ], :BOOL + safe_attach_function :GetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer pointer}, :DWORD + safe_attach_function :GetSecurityDescriptorControl, %i{pointer PWORD LPDWORD}, :BOOL + safe_attach_function :GetSecurityDescriptorDacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL + safe_attach_function :GetSecurityDescriptorGroup, %i{pointer pointer LPBOOL}, :BOOL + safe_attach_function :GetSecurityDescriptorOwner, %i{pointer pointer LPBOOL}, :BOOL + safe_attach_function :GetSecurityDescriptorSacl, %i{pointer LPBOOL pointer LPBOOL}, :BOOL + safe_attach_function :InitializeAcl, %i{pointer DWORD DWORD}, :BOOL + safe_attach_function :InitializeSecurityDescriptor, %i{pointer DWORD}, :BOOL safe_attach_function :IsValidAcl, [ :pointer ], :BOOL safe_attach_function :IsValidSecurityDescriptor, [ :pointer ], :BOOL safe_attach_function :IsValidSid, [ :pointer ], :BOOL - safe_attach_function :LookupAccountNameW, [ :LPCWSTR, :LPCWSTR, :pointer, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL - safe_attach_function :LookupAccountSidW, [ :LPCWSTR, :pointer, :LPWSTR, :LPDWORD, :LPWSTR, :LPDWORD, :pointer ], :BOOL - safe_attach_function :LookupPrivilegeNameW, [ :LPCWSTR, :PLUID, :LPWSTR, :LPDWORD ], :BOOL - safe_attach_function :LookupPrivilegeDisplayNameW, [ :LPCWSTR, :LPCWSTR, :LPWSTR, :LPDWORD, :LPDWORD ], :BOOL - safe_attach_function :LookupPrivilegeValueW, [ :LPCWSTR, :LPCWSTR, :PLUID ], :BOOL - safe_attach_function :LsaAddAccountRights, [ :pointer, :pointer, :pointer, :ULONG ], :NTSTATUS - safe_attach_function :LsaRemoveAccountRights, [ :pointer, :pointer, :BOOL, :pointer, :ULONG ], :NTSTATUS + safe_attach_function :LookupAccountNameW, %i{LPCWSTR LPCWSTR pointer LPDWORD LPWSTR LPDWORD pointer}, :BOOL + safe_attach_function :LookupAccountSidW, %i{LPCWSTR pointer LPWSTR LPDWORD LPWSTR LPDWORD pointer}, :BOOL + safe_attach_function :LookupPrivilegeNameW, %i{LPCWSTR PLUID LPWSTR LPDWORD}, :BOOL + safe_attach_function :LookupPrivilegeDisplayNameW, %i{LPCWSTR LPCWSTR LPWSTR LPDWORD LPDWORD}, :BOOL + safe_attach_function :LookupPrivilegeValueW, %i{LPCWSTR LPCWSTR PLUID}, :BOOL + safe_attach_function :LsaAddAccountRights, %i{pointer pointer pointer ULONG}, :NTSTATUS + safe_attach_function :LsaRemoveAccountRights, %i{pointer pointer BOOL pointer ULONG}, :NTSTATUS safe_attach_function :LsaClose, [ :LSA_HANDLE ], :NTSTATUS - safe_attach_function :LsaEnumerateAccountRights, [ :LSA_HANDLE, :PSID, :PLSA_UNICODE_STRING, :PULONG ], :NTSTATUS + safe_attach_function :LsaEnumerateAccountRights, %i{LSA_HANDLE PSID PLSA_UNICODE_STRING PULONG}, :NTSTATUS safe_attach_function :LsaFreeMemory, [ :PVOID ], :NTSTATUS safe_attach_function :LsaNtStatusToWinError, [ :NTSTATUS ], :ULONG - safe_attach_function :LsaOpenPolicy, [ :PLSA_UNICODE_STRING, :PLSA_OBJECT_ATTRIBUTES, :DWORD, :PLSA_HANDLE ], :NTSTATUS - safe_attach_function :MakeAbsoluteSD, [ :pointer, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD, :pointer, :LPDWORD], :BOOL - safe_attach_function :MapGenericMask, [ :PDWORD, :PGENERICMAPPING ], :void - safe_attach_function :OpenProcessToken, [ :HANDLE, :DWORD, :PHANDLE ], :BOOL - safe_attach_function :QuerySecurityAccessMask, [ :DWORD, :LPDWORD ], :void - safe_attach_function :SetFileSecurityW, [ :LPWSTR, :DWORD, :pointer ], :BOOL - safe_attach_function :SetNamedSecurityInfoW, [ :LPWSTR, :SE_OBJECT_TYPE, :DWORD, :pointer, :pointer, :pointer, :pointer ], :DWORD - safe_attach_function :SetSecurityAccessMask, [ :DWORD, :LPDWORD ], :void - safe_attach_function :SetSecurityDescriptorDacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL - safe_attach_function :SetSecurityDescriptorGroup, [ :pointer, :pointer, :BOOL ], :BOOL - safe_attach_function :SetSecurityDescriptorOwner, [ :pointer, :pointer, :BOOL ], :BOOL - safe_attach_function :SetSecurityDescriptorSacl, [ :pointer, :BOOL, :pointer, :BOOL ], :BOOL - safe_attach_function :GetTokenInformation, [ :HANDLE, :TOKEN_INFORMATION_CLASS, :pointer, :DWORD, :PDWORD ], :BOOL - safe_attach_function :LogonUserW, [:LPTSTR, :LPTSTR, :LPTSTR, :DWORD, :DWORD, :PHANDLE], :BOOL + safe_attach_function :LsaOpenPolicy, %i{PLSA_UNICODE_STRING PLSA_OBJECT_ATTRIBUTES DWORD PLSA_HANDLE}, :NTSTATUS + safe_attach_function :MakeAbsoluteSD, %i{pointer pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD pointer LPDWORD}, :BOOL + safe_attach_function :MapGenericMask, %i{PDWORD PGENERICMAPPING}, :void + safe_attach_function :OpenProcessToken, %i{HANDLE DWORD PHANDLE}, :BOOL + safe_attach_function :QuerySecurityAccessMask, %i{DWORD LPDWORD}, :void + safe_attach_function :SetFileSecurityW, %i{LPWSTR DWORD pointer}, :BOOL + safe_attach_function :SetNamedSecurityInfoW, %i{LPWSTR SE_OBJECT_TYPE DWORD pointer pointer pointer pointer}, :DWORD + safe_attach_function :SetSecurityAccessMask, %i{DWORD LPDWORD}, :void + safe_attach_function :SetSecurityDescriptorDacl, %i{pointer BOOL pointer BOOL}, :BOOL + safe_attach_function :SetSecurityDescriptorGroup, %i{pointer pointer BOOL}, :BOOL + safe_attach_function :SetSecurityDescriptorOwner, %i{pointer pointer BOOL}, :BOOL + safe_attach_function :SetSecurityDescriptorSacl, %i{pointer BOOL pointer BOOL}, :BOOL + safe_attach_function :GetTokenInformation, %i{HANDLE TOKEN_INFORMATION_CLASS pointer DWORD PDWORD}, :BOOL + safe_attach_function :LogonUserW, %i{LPTSTR LPTSTR LPTSTR DWORD DWORD PHANDLE}, :BOOL safe_attach_function :ImpersonateLoggedOnUser, [:HANDLE], :BOOL safe_attach_function :RevertToSelf, [], :BOOL diff --git a/lib/chef/win32/api/synchronization.rb b/lib/chef/win32/api/synchronization.rb index 19ca24bf00..aaedf2dd89 100644 --- a/lib/chef/win32/api/synchronization.rb +++ b/lib/chef/win32/api/synchronization.rb @@ -56,8 +56,8 @@ HANDLE WINAPI CreateMutex( _In_opt_ LPCTSTR lpName ); =end - safe_attach_function :CreateMutexW, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE - safe_attach_function :CreateMutexA, [ :LPSECURITY_ATTRIBUTES, :BOOL, :LPCTSTR ], :HANDLE + safe_attach_function :CreateMutexW, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE + safe_attach_function :CreateMutexA, %i{LPSECURITY_ATTRIBUTES BOOL LPCTSTR}, :HANDLE =begin DWORD WINAPI WaitForSingleObject( @@ -65,7 +65,7 @@ DWORD WINAPI WaitForSingleObject( _In_ DWORD dwMilliseconds ); =end - safe_attach_function :WaitForSingleObject, [ :HANDLE, :DWORD ], :DWORD + safe_attach_function :WaitForSingleObject, %i{HANDLE DWORD}, :DWORD =begin BOOL WINAPI ReleaseMutex( @@ -81,8 +81,8 @@ HANDLE WINAPI OpenMutex( _In_ LPCTSTR lpName ); =end - safe_attach_function :OpenMutexW, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE - safe_attach_function :OpenMutexA, [ :DWORD, :BOOL, :LPCTSTR ], :HANDLE + safe_attach_function :OpenMutexW, %i{DWORD BOOL LPCTSTR}, :HANDLE + safe_attach_function :OpenMutexA, %i{DWORD BOOL LPCTSTR}, :HANDLE end end end diff --git a/lib/chef/win32/api/system.rb b/lib/chef/win32/api/system.rb index ebe89f357f..48054c0b4f 100644 --- a/lib/chef/win32/api/system.rb +++ b/lib/chef/win32/api/system.rb @@ -177,7 +177,7 @@ BOOL WINAPI GetProductInfo( __out PDWORD pdwReturnedProductType ); =end - safe_attach_function :GetProductInfo, [:DWORD, :DWORD, :DWORD, :DWORD, :PDWORD], :BOOL + safe_attach_function :GetProductInfo, %i{DWORD DWORD DWORD DWORD PDWORD}, :BOOL =begin int WINAPI GetSystemMetrics( @@ -192,8 +192,8 @@ UINT WINAPI GetSystemWow64Directory( _In_ UINT uSize ); =end - safe_attach_function :GetSystemWow64DirectoryW, [:LPTSTR, :UINT], :UINT - safe_attach_function :GetSystemWow64DirectoryA, [:LPTSTR, :UINT], :UINT + safe_attach_function :GetSystemWow64DirectoryW, %i{LPTSTR UINT}, :UINT + safe_attach_function :GetSystemWow64DirectoryA, %i{LPTSTR UINT}, :UINT =begin BOOL WINAPI Wow64DisableWow64FsRedirection( @@ -220,8 +220,8 @@ LRESULT WINAPI SendMessageTimeout( _Out_opt_ PDWORD_PTR lpdwResult ); =end - safe_attach_function :SendMessageTimeoutW, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT - safe_attach_function :SendMessageTimeoutA, [:HWND, :UINT, :WPARAM, :LPARAM, :UINT, :UINT, :PDWORD_PTR], :LRESULT + safe_attach_function :SendMessageTimeoutW, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT + safe_attach_function :SendMessageTimeoutA, %i{HWND UINT WPARAM LPARAM UINT UINT PDWORD_PTR}, :LRESULT =begin DWORD WINAPI ExpandEnvironmentStrings( @@ -230,8 +230,8 @@ DWORD WINAPI ExpandEnvironmentStrings( _In_ DWORD nSize ); =end - safe_attach_function :ExpandEnvironmentStringsW, [:pointer, :pointer, :DWORD], :DWORD - safe_attach_function :ExpandEnvironmentStringsA, [:pointer, :pointer, :DWORD], :DWORD + safe_attach_function :ExpandEnvironmentStringsW, %i{pointer pointer DWORD}, :DWORD + safe_attach_function :ExpandEnvironmentStringsA, %i{pointer pointer DWORD}, :DWORD end end end diff --git a/lib/chef/win32/api/unicode.rb b/lib/chef/win32/api/unicode.rb index 05c098fc62..70aee58df6 100644 --- a/lib/chef/win32/api/unicode.rb +++ b/lib/chef/win32/api/unicode.rb @@ -101,7 +101,7 @@ BOOL IsTextUnicode( __inout LPINT lpiResult ); =end - safe_attach_function :IsTextUnicode, [:pointer, :int, :LPINT], :BOOL + safe_attach_function :IsTextUnicode, %i{pointer int LPINT}, :BOOL =begin int MultiByteToWideChar( @@ -113,7 +113,7 @@ int MultiByteToWideChar( __in int cchWideChar ); =end - safe_attach_function :MultiByteToWideChar, [:UINT, :DWORD, :LPCSTR, :int, :LPWSTR, :int], :int + safe_attach_function :MultiByteToWideChar, %i{UINT DWORD LPCSTR int LPWSTR int}, :int =begin int WideCharToMultiByte( @@ -127,7 +127,7 @@ int WideCharToMultiByte( __out LPBOOL lpUsedDefaultChar ); =end - safe_attach_function :WideCharToMultiByte, [:UINT, :DWORD, :LPCWSTR, :int, :LPSTR, :int, :LPCSTR, :LPBOOL], :int + safe_attach_function :WideCharToMultiByte, %i{UINT DWORD LPCWSTR int LPSTR int LPCSTR LPBOOL}, :int end end diff --git a/lib/chef/win32/eventlog.rb b/lib/chef/win32/eventlog.rb index e8c63bf13a..4997c0c4c0 100644 --- a/lib/chef/win32/eventlog.rb +++ b/lib/chef/win32/eventlog.rb @@ -19,7 +19,7 @@ if Chef::Platform.windows? if !defined? Chef::Win32EventLogLoaded if defined? Windows::Constants - [:INFINITE, :WAIT_FAILED, :FORMAT_MESSAGE_IGNORE_INSERTS, :ERROR_INSUFFICIENT_BUFFER].each do |c| + %i{INFINITE WAIT_FAILED FORMAT_MESSAGE_IGNORE_INSERTS ERROR_INSUFFICIENT_BUFFER}.each do |c| # These are redefined in 'win32/eventlog' Windows::Constants.send(:remove_const, c) if Windows::Constants.const_defined? c end diff --git a/lib/chef/win32/file/version_info.rb b/lib/chef/win32/file/version_info.rb index 10337a409b..f74c98b86d 100644 --- a/lib/chef/win32/file/version_info.rb +++ b/lib/chef/win32/file/version_info.rb @@ -34,20 +34,20 @@ class Chef # defining method for each predefined version resource string # see https://msdn.microsoft.com/en-us/library/windows/desktop/ms647464(v=vs.85).aspx - [ - :Comments, - :CompanyName, - :FileDescription, - :FileVersion, - :InternalName, - :LegalCopyright, - :LegalTrademarks, - :OriginalFilename, - :ProductName, - :ProductVersion, - :PrivateBuild, - :SpecialBuild, - ].each do |method| + %i{ + Comments + CompanyName + FileDescription + FileVersion + InternalName + LegalCopyright + LegalTrademarks + OriginalFilename + ProductName + ProductVersion + PrivateBuild + SpecialBuild + }.each do |method| define_method method do begin get_version_info_string(method.to_s) |