From f0d79a4da58c5bd7427ffbf0cceed122c264511c Mon Sep 17 00:00:00 2001 From: rileyt Date: Mon, 20 Nov 2017 19:27:34 +0000 Subject: [PATCH 1/6] Increase rubocop version to 0.51+ & remove Ruby 2.0 testing --- .travis.yml | 2 -- CHANGELOG.md | 5 +++++ sensu-plugins-zookeeper.gemspec | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b2c977..fe1e82d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ cache: install: - bundle install rvm: -- 2.0 - 2.1 - 2.2 - 2.3.0 @@ -27,7 +26,6 @@ deploy: on: tags: true all_branches: true - rvm: 2.0 rvm: 2.1 rvm: 2.2 rvm: 2.3.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e7910e..5696bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ This CHANGELOG follows the format listed at [Our CHANGELOG Guidelines ](https:// Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] +### Security +- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@thomasriley) + +### Breaking Changes +- removed < ruby 2.1 support which was pulled as part of security updates (@thomasriley) ## [1.5.0] - 2017-12-06 ### Added diff --git a/sensu-plugins-zookeeper.gemspec b/sensu-plugins-zookeeper.gemspec index c201161..07930bc 100644 --- a/sensu-plugins-zookeeper.gemspec +++ b/sensu-plugins-zookeeper.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu' s.require_paths = ['lib'] - s.required_ruby_version = '>= 2.0.0' + s.required_ruby_version = '>= 2.1.0' s.summary = 'Sensu plugins for zookeeper' s.test_files = s.files.grep(%r{^(test|spec|features)/}) @@ -36,7 +36,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry', '~> 0.10' s.add_development_dependency 'rake', '~> 10.5' s.add_development_dependency 'redcarpet', '~> 3.2' - s.add_development_dependency 'rubocop', '~> 0.40.0' + s.add_development_dependency 'rubocop', '~> 0.51.0' s.add_development_dependency 'rspec', '~> 3.4' s.add_development_dependency 'yard', '~> 0.8' end From c5d6ff555cbad47391b5af77b33d6fe6a209787e Mon Sep 17 00:00:00 2001 From: thomasriley Date: Mon, 20 Nov 2017 21:25:48 +0000 Subject: [PATCH 2/6] Rubocop fixes --- .gitignore | 1 + CHANGELOG.md | 3 +++ Rakefile | 6 +++--- bin/check-znode.rb | 1 - bin/check-zookeeper-cluster.rb | 1 - bin/check-zookeeper-file-descriptors.rb | 1 - bin/check-zookeeper-latency.rb | 1 - bin/check-zookeeper-mode.rb | 1 - bin/check-zookeeper-reqs.rb | 1 - bin/check-zookeeper-ruok.rb | 1 - bin/metrics-zookeeper-cluster.rb | 4 ++++ sensu-plugins-zookeeper.gemspec | 6 +++--- 12 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index f92e714..712439a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ mkmf.log .DS_Store .idea/* *.gem +/vendor/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 5696bed..fed65c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) ### Breaking Changes - removed < ruby 2.1 support which was pulled as part of security updates (@thomasriley) +### Changed +- Various amendments to comply with Rubocop (@thomasriley) + ## [1.5.0] - 2017-12-06 ### Added - check-netty-zookeeper-cluster.rb: new script to check if a zookeeper v. 3.5 cluster is OK (@duncaan) diff --git a/Rakefile b/Rakefile index 1f88385..b43b0fa 100644 --- a/Rakefile +++ b/Rakefile @@ -7,9 +7,9 @@ require 'yard' require 'yard/rake/yardoc_task' YARD::Rake::YardocTask.new do |t| - OTHER_PATHS = %w().freeze + OTHER_PATHS = %w[].freeze t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS] - t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md) + t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md] end RuboCop::RakeTask.new @@ -35,4 +35,4 @@ task :check_binstubs do end end -task default: [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs] +task default: %i[spec make_bin_executable yard rubocop check_binstubs] diff --git a/bin/check-znode.rb b/bin/check-znode.rb index 26b7b89..c29dcff 100755 --- a/bin/check-znode.rb +++ b/bin/check-znode.rb @@ -1,5 +1,4 @@ #! /usr/bin/env ruby -# encoding: UTF-8 # # check-znode # diff --git a/bin/check-zookeeper-cluster.rb b/bin/check-zookeeper-cluster.rb index c98f47b..20d22f4 100755 --- a/bin/check-zookeeper-cluster.rb +++ b/bin/check-zookeeper-cluster.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-cluster # diff --git a/bin/check-zookeeper-file-descriptors.rb b/bin/check-zookeeper-file-descriptors.rb index d87f1e0..e3bd447 100755 --- a/bin/check-zookeeper-file-descriptors.rb +++ b/bin/check-zookeeper-file-descriptors.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-file-descriptors.rb # diff --git a/bin/check-zookeeper-latency.rb b/bin/check-zookeeper-latency.rb index 6817b4c..0269589 100755 --- a/bin/check-zookeeper-latency.rb +++ b/bin/check-zookeeper-latency.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-latency # diff --git a/bin/check-zookeeper-mode.rb b/bin/check-zookeeper-mode.rb index d892dfe..3e2b175 100755 --- a/bin/check-zookeeper-mode.rb +++ b/bin/check-zookeeper-mode.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-mode # diff --git a/bin/check-zookeeper-reqs.rb b/bin/check-zookeeper-reqs.rb index 6727ffd..b666f2e 100755 --- a/bin/check-zookeeper-reqs.rb +++ b/bin/check-zookeeper-reqs.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-reqs # diff --git a/bin/check-zookeeper-ruok.rb b/bin/check-zookeeper-ruok.rb index c2ea915..182a8fe 100755 --- a/bin/check-zookeeper-ruok.rb +++ b/bin/check-zookeeper-ruok.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # check-zookeeper-ruok # diff --git a/bin/metrics-zookeeper-cluster.rb b/bin/metrics-zookeeper-cluster.rb index 0ea2d7a..87e1cd1 100755 --- a/bin/metrics-zookeeper-cluster.rb +++ b/bin/metrics-zookeeper-cluster.rb @@ -49,6 +49,8 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite default: 2181, proc: proc(&:to_i) + # TODO: Remove below when Rubocop is updated (https://github.com/sensu-plugins/community/issues/77#issuecomment-345813238) + # rubocop:disable Style/CommentedKeyword def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", max_attempts = 10, timeout = 10) attempts = 0 cookie = nil @@ -119,6 +121,8 @@ def run timestamp = Time.now.to_i json = exhibitor_status + + # rubocop:disable Metrics/BlockLength json.each do |zk| hostname = zk['hostname'] response = zk_command(:mntr, hostname, config[:zk_port]) diff --git a/sensu-plugins-zookeeper.gemspec b/sensu-plugins-zookeeper.gemspec index 07930bc..eb63f42 100644 --- a/sensu-plugins-zookeeper.gemspec +++ b/sensu-plugins-zookeeper.gemspec @@ -4,14 +4,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'date' require_relative 'lib/sensu-plugins-zookeeper' -Gem::Specification.new do |s| +Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength s.authors = ['Sensu Plugins and contributors'] s.date = Date.today.to_s s.description = 'Zookeeper plugins for checks and metrics' s.email = '' s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) } - s.files = Dir.glob('{bin,lib}/**/*') + %w(LICENSE README.md CHANGELOG.md) + s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md] s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-zookeeper' s.license = 'MIT' s.metadata = { 'maintainer' => 'sensu-plugin', @@ -36,7 +36,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry', '~> 0.10' s.add_development_dependency 'rake', '~> 10.5' s.add_development_dependency 'redcarpet', '~> 3.2' - s.add_development_dependency 'rubocop', '~> 0.51.0' s.add_development_dependency 'rspec', '~> 3.4' + s.add_development_dependency 'rubocop', '~> 0.51.0' s.add_development_dependency 'yard', '~> 0.8' end From df1a70eab1390dfee391a4642760d630ab40ea78 Mon Sep 17 00:00:00 2001 From: thomasriley Date: Mon, 20 Nov 2017 21:49:54 +0000 Subject: [PATCH 3/6] TODO on the github comment: --- bin/metrics-zookeeper-cluster.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/metrics-zookeeper-cluster.rb b/bin/metrics-zookeeper-cluster.rb index 87e1cd1..0b0cee9 100755 --- a/bin/metrics-zookeeper-cluster.rb +++ b/bin/metrics-zookeeper-cluster.rb @@ -122,6 +122,7 @@ def run json = exhibitor_status + # TODO: Need to shortern this function # rubocop:disable Metrics/BlockLength json.each do |zk| hostname = zk['hostname'] From 95d65c0bc923e7e10aef4e3cc8c6450d6002c7d1 Mon Sep 17 00:00:00 2001 From: thomasriley Date: Mon, 20 Nov 2017 22:00:34 +0000 Subject: [PATCH 4/6] Better use of rubocop:disable --- bin/metrics-zookeeper-cluster.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/metrics-zookeeper-cluster.rb b/bin/metrics-zookeeper-cluster.rb index 0b0cee9..01bfaf4 100755 --- a/bin/metrics-zookeeper-cluster.rb +++ b/bin/metrics-zookeeper-cluster.rb @@ -49,7 +49,7 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite default: 2181, proc: proc(&:to_i) - # TODO: Remove below when Rubocop is updated (https://github.com/sensu-plugins/community/issues/77#issuecomment-345813238) + # TODO: Remove rubocop:disable Style/CommentedKeyword on this function when fixed (https://github.com/sensu-plugins/community/issues/77#issuecomment-345813238) # rubocop:disable Style/CommentedKeyword def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", max_attempts = 10, timeout = 10) attempts = 0 @@ -97,6 +97,7 @@ def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper response end + # rubocop:enable Style/CommentedKeyword def dotted(*args) args.join('.') @@ -123,8 +124,7 @@ def run json = exhibitor_status # TODO: Need to shortern this function - # rubocop:disable Metrics/BlockLength - json.each do |zk| + json.each do |zk| # rubocop:disable Metrics/BlockLength hostname = zk['hostname'] response = zk_command(:mntr, hostname, config[:zk_port]) metrics = {} From 326f95f1f954fc9f70aed691f853485cf8e62054 Mon Sep 17 00:00:00 2001 From: Ben Abrams Date: Thu, 28 Dec 2017 14:55:00 -0800 Subject: [PATCH 5/6] remove extra disabled and made easier to read --- bin/metrics-zookeeper-cluster.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/metrics-zookeeper-cluster.rb b/bin/metrics-zookeeper-cluster.rb index 01bfaf4..91a11c2 100755 --- a/bin/metrics-zookeeper-cluster.rb +++ b/bin/metrics-zookeeper-cluster.rb @@ -49,9 +49,10 @@ class ZookeeperMetrics < Sensu::Plugin::Metric::CLI::Graphite default: 2181, proc: proc(&:to_i) - # TODO: Remove rubocop:disable Style/CommentedKeyword on this function when fixed (https://github.com/sensu-plugins/community/issues/77#issuecomment-345813238) - # rubocop:disable Style/CommentedKeyword - def follow_url(uri_str, agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", max_attempts = 10, timeout = 10) + def follow_url(uri_str, + agent = "sensu-plugins-zookeeper/#{SensuPluginsZookeeper::Version::VER_STRING}", + max_attempts = 10, + timeout = 10) attempts = 0 cookie = nil From d19408dbc6026db5424318aaa8228d738d17881e Mon Sep 17 00:00:00 2001 From: Ben Abrams Date: Thu, 28 Dec 2017 15:09:17 -0800 Subject: [PATCH 6/6] appease cop about encoding on new check --- bin/check-netty-zookeeper-cluster.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/check-netty-zookeeper-cluster.rb b/bin/check-netty-zookeeper-cluster.rb index b7a581b..fdbdb61 100755 --- a/bin/check-netty-zookeeper-cluster.rb +++ b/bin/check-netty-zookeeper-cluster.rb @@ -1,5 +1,4 @@ #!/usr/bin/env ruby -# encoding: UTF-8 # # netty-check-zookeeper-cluster