Navigation Menu

Skip to content

Commit

Permalink
[CVE-2017-8418] - updating rubocop dependency.
Browse files Browse the repository at this point in the history
Breaking Changes:
- removed ruby `< 2.1` support

Misc:
- appeased the cops

Signed-off-by: Ben Abrams <me@benabrams.it>
  • Loading branch information
majormoses committed Mar 2, 2018
1 parent 85a6b3a commit a44c90f
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Expand Up @@ -28,3 +28,7 @@ RegexpLiteral:

Style/Documentation:
Enabled: false

# .match?() only exists in ruby 2.4+
Performance/RegexpMatch:
Enabled: false
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -4,7 +4,6 @@ cache:
install:
- bundle install
rvm:
- 2.0
- 2.1
- 2.2
- 2.3.0
Expand All @@ -27,7 +26,6 @@ deploy:
on:
tags: true
all_branches: true
rvm: 2.0
rvm: 2.1
rvm: 2.2
rvm: 2.3.0
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,15 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins

## [Unreleased]

### Security
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)

### Breaking Changes
- removed ruby `< 2.1` support (@majormoses)

### Changed
- appeased the cops (@majormoses)

## [1.6.1] - 2018-03-02
### Fixed
- Bug fix for `check-consul-servers` so timeout option works (@joshbenner)
Expand Down
8 changes: 5 additions & 3 deletions Rakefile
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'github/markup'
require 'redcarpet'
Expand All @@ -6,12 +8,12 @@ require 'rubocop/rake_task'
require 'yard'
require 'yard/rake/yardoc_task'

args = [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
args = %i[spec make_bin_executable yard rubocop check_binstubs]

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
Expand Down
2 changes: 2 additions & 0 deletions bin/check-consul-failures.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# OUTPUT:
# plain text
Expand Down
8 changes: 5 additions & 3 deletions bin/check-consul-kv-ttl.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-kv-ttl
#
Expand Down Expand Up @@ -126,8 +128,8 @@ def run
kv_status = kv_status.downcase

# Flag based off of status
warning 'Warning status detected!' if %w(warning).include? kv_status
critical 'Critical status detected!' if %w(critical unknown).include? kv_status
warning 'Warning status detected!' if %w[warning].include? kv_status
critical 'Critical status detected!' if %w[critical unknown].include? kv_status
end

# Dig to the time
Expand Down Expand Up @@ -157,7 +159,7 @@ def run
critical "TTL Expired! Elapsed Time: #{elapsed_seconds}" if elapsed_seconds > config[:critical]
warning "TTL Expiration Approaching! Elapsed Time: #{elapsed_seconds}" if elapsed_seconds > config[:warning]
ok
rescue
rescue StandardError
critical 'Unable to process DateTime objects!'
end
end
Expand Down
8 changes: 5 additions & 3 deletions bin/check-consul-leader.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-leader
#
Expand Down Expand Up @@ -74,11 +76,11 @@ class ConsulStatus < Sensu::Plugin::Check::CLI
def valid_ip(ip)
case ip.to_s
when Resolv::IPv4::Regex
return true
true
when Resolv::IPv6::Regex
return true
true
else
return false
false
end
end

Expand Down
2 changes: 2 additions & 0 deletions bin/check-consul-maintenance.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-maintenance
#
Expand Down
2 changes: 2 additions & 0 deletions bin/check-consul-members.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-members
#
Expand Down
2 changes: 2 additions & 0 deletions bin/check-consul-servers.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-servers
#
Expand Down
14 changes: 8 additions & 6 deletions bin/check-consul-service-health.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-consul-service-health
#
Expand Down Expand Up @@ -78,20 +80,20 @@ def acquire_service_data
services.push(*s['Checks'])
end
end
return services
services
elsif config[:nodename]
data = []
begin
services = Diplomat::Node.get(config[:nodename]).Services
rescue
rescue StandardError
services = {}
end
services.values.each do |service|
services.each_value do |service|
Diplomat::Health.checks(service['Service']).each do |check|
data.push(check) if check.Node == config[:nodename]
end
end
return data
data
elsif config[:all]
Diplomat::Health.state('any')
else
Expand Down Expand Up @@ -128,8 +130,8 @@ def run
'Status' => checkStatus
)

warnings = true if %w(warning).include? checkStatus
criticals = true if %w(critical unknown).include? checkStatus
warnings = true if %w[warning].include? checkStatus
criticals = true if %w[critical unknown].include? checkStatus
end

if config[:fail_if_not_found] && !found
Expand Down
29 changes: 17 additions & 12 deletions bin/check-service-consul.rb
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-service-consul
#
Expand Down Expand Up @@ -99,18 +101,21 @@ def run
passing = []
failing = []
data.each do |d|
passing << {
'node' => d['Node'],
'service' => d['ServiceName'],
'service_id' => d['ServiceID'],
'notes' => d['Notes']
} if d['Status'] == 'passing'
failing << {
'node' => d['Node'],
'service' => d['ServiceName'],
'service_id' => d['ServiceID'],
'notes' => d['Notes']
} if d['Status'] == 'critical'
if d['Status'] == 'passing'
passing << {
'node' => d['Node'],
'service' => d['ServiceName'],
'service_id' => d['ServiceID'],
'notes' => d['Notes']
}
elsif d['Status'] == 'critical'
failing << {
'node' => d['Node'],
'service' => d['ServiceName'],
'service_id' => d['ServiceID'],
'notes' => d['Notes']
}
end
end

if failing.empty? && passing.empty?
Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-consul.rb
@@ -1 +1,3 @@
# frozen_string_literal: true

require 'sensu-plugins-consul/version'
2 changes: 2 additions & 0 deletions lib/sensu-plugins-consul/version.rb
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SensuPluginsConsul
module Version
MAJOR = 1
Expand Down
11 changes: 7 additions & 4 deletions sensu-plugins-consul.gemspec
@@ -1,18 +1,20 @@
# frozen_string_literal: true

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require 'date'
require_relative 'lib/sensu-plugins-consul'

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 = 'This plugin provides native instrumentation for monitoring Consul, including:
Consul server service and cluster health, and querying the Consul API to check
for passing/critical services.'
s.email = '<sensu-users@googlegroups.com>'
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-consul'
s.license = 'MIT'
s.metadata = { 'maintainer' => 'sensu-plugin',
Expand All @@ -24,12 +26,13 @@ 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'
s.summary = 'Sensu plugins for Consul'
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.version = SensuPluginsConsul::Version::VER_STRING

s.add_runtime_dependency 'sensu-plugin', '~> 1.2'

s.add_runtime_dependency 'diplomat', '0.14.0'
s.add_runtime_dependency 'rest-client', '1.8.0'

Expand All @@ -39,7 +42,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 'rspec', '~> 3.4'
s.add_development_dependency 'rubocop', '~> 0.51.0'
s.add_development_dependency 'yard', '~> 0.8'
end

0 comments on commit a44c90f

Please sign in to comment.