Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CVE-2017-8418] - updating rubocop dependency. #80

Merged
merged 1 commit into from
Mar 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ RegexpLiteral:

Style/Documentation:
Enabled: false

# .match?() was added in ruby 2.4
Performance/RegexpMatch:
Enabled: false

## slow testing is oK
Metrics/BlockLength:
Exclude:
- 'test/**/*'
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cache:
install:
- bundle install
rvm:
- 2.0
- 2.1
- 2.2
- 2.3.0
Expand All @@ -28,7 +27,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
Original file line number Diff line number Diff line change
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)

## [3.6.0] - 2017-10-04
### Added
- check-rabbitmq-queues-synchronised.rb: added new check if all mirrored queues are synchronised (@cyrilgdn)
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in sensu-plugins-rabbitmq.gemspec
Expand Down
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'github/markup'
require 'redcarpet'
Expand All @@ -7,9 +9,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
Expand All @@ -35,4 +37,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]
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-alive.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check alive plugin
# ===
Expand Down Expand Up @@ -115,7 +116,7 @@ def vhost_alive?
{ 'status' => 'ok', 'message' => 'RabbitMQ server is alive' }
rescue Errno::ECONNREFUSED => e
{ 'status' => 'critical', 'message' => e.message }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => e.message }
end
end
Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-amqp-alive.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check amqp alive plugin
# ===
Expand Down Expand Up @@ -142,7 +143,7 @@ def vhost_alive?
{ 'status' => 'critical', 'message' => 'Possible authentication failure' }
rescue Bunny::TCPConnectionFailed
{ 'status' => 'critical', 'message' => 'TCP connection refused' }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => e.message }
end
end
Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-cluster-health.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check cluster nodes health plugin
# ===
Expand Down Expand Up @@ -161,7 +162,7 @@ def cluster_healthy?
{ 'status' => status, 'message' => message }
rescue Errno::ECONNREFUSED => e
{ 'status' => 'critical', 'message' => e.message }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => e.message }
end
end
Expand Down
14 changes: 7 additions & 7 deletions bin/check-rabbitmq-consumers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

# Check RabbitMQ consumers
# ===
Expand Down Expand Up @@ -109,19 +109,19 @@ def rabbit
password: password,
ssl: config[:ssl]
)
rescue
rescue StandardError
warning 'could not connect to rabbitmq'
end
connection
end

def return_condition(missing, critical, warning)
if critical.count > 0 || missing.count > 0
if critical.count.positive? || missing.count.positive?
message = ''
message << "Queues in critical state: #{critical.join(', ')}. " if critical.count > 0
message << "Queues missing: #{missing.join(', ')}" if missing.count > 0
message << "Queues in critical state: #{critical.join(', ')}. " if critical.count.positive?
message << "Queues missing: #{missing.join(', ')}" if missing.count.positive?
critical(message)
elsif warning.count > 0
elsif warning.count.positive?
warning("Queues in warning state: #{warning.join(', ')}")
else
ok
Expand Down Expand Up @@ -154,7 +154,7 @@ def run
critical.push(queue['name']) if consumers <= config[:critical]
warn.push(queue['name']) if consumers <= config[:warn]
end
rescue
rescue StandardError
critical 'Could not find any queue, check rabbitmq server'
end
return_condition(missing, critical, warn)
Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-messages.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# Check RabbitMQ Messages
# ===
Expand Down Expand Up @@ -112,7 +113,7 @@ def acquire_rabbitmq_info
password: password,
ssl: config[:ssl]
)
rescue
rescue StandardError
warning 'Could not connect to rabbitmq'
end
rabbitmq_info
Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-network-partitions.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ Network Partitions Check
# ===
Expand Down Expand Up @@ -68,7 +69,7 @@ def run
ok 'no network partition detected'
rescue Errno::ECONNREFUSED => e
critical e.message
rescue => e
rescue StandardError => e
unknown e.message
end

Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-node-health.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check node health plugin
# ===
Expand Down Expand Up @@ -215,7 +216,7 @@ def node_healthy?
{ 'status' => status, 'message' => message }
rescue Errno::ECONNREFUSED => e
{ 'status' => 'critical', 'message' => e.message }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => e.message }
end
end
Expand Down
7 changes: 4 additions & 3 deletions bin/check-rabbitmq-node-usage.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby -W0
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check node health plugin
# ===
Expand Down Expand Up @@ -72,7 +73,7 @@ class CheckRabbitMQNodeUsage < Sensu::Plugin::Check::CLI
description: 'Resource type',
required: true,
long: '--type TYPE',
in: %w(mem socket fd proc disk)
in: %w[mem socket fd proc disk]

option :memwarn,
description: 'Warning % of mem usage vs high watermark',
Expand Down Expand Up @@ -179,7 +180,7 @@ def node_healthy?
end

{ 'status' => output[:status], 'message' => output[:message] }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => e.message }
end

Expand Down
9 changes: 5 additions & 4 deletions bin/check-rabbitmq-queue-drain-time.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ Queue Drain Time
# ===
Expand Down Expand Up @@ -106,7 +107,7 @@ def acquire_rabbitmq_queues
password: password,
ssl: config[:ssl]
)
rescue
rescue StandardError
warning 'could not get rabbitmq queue info'
end

Expand All @@ -125,10 +126,10 @@ def run

acquire_rabbitmq_queues.each do |queue|
# we don't care about empty queues and they'll have an infinite drain time so skip them
next if queue['messages'] == 0 || queue['messages'].nil?
next if queue['messages'].zero? || queue['messages'].nil?

# handle rate of zero which is an infinite time until empty
if queue['backing_queue_status']['avg_egress_rate'].to_f == 0
if queue['backing_queue_status']['avg_egress_rate'].to_f.zero?
crit_queues[queue['name']] = 'Infinite (drain rate = 0)'
next
end
Expand Down
8 changes: 6 additions & 2 deletions bin/check-rabbitmq-queue.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: false

#
# Check RabbitMQ Queue Messages
# ===
Expand All @@ -22,13 +23,16 @@
# for details.

require 'sensu-plugins-rabbitmq'
require 'sensu-plugins-rabbitmq/check'
require 'sensu-plugin/check/cli'

# main plugin class
class CheckRabbitMQMessages < Sensu::Plugin::RabbitMQ::Check
class CheckRabbitMQQueue < Sensu::Plugin::RabbitMQ::Check
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace conflict.

option :queue,
description: 'RabbitMQ queue to monitor',
long: '--queue queue_names',
required: true,
# not sure if there is a better way to handle frozen strings
proc: proc { |a| a.split(',') }

option :warn,
Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-queues-synchronised.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# Check RabbitMQ Queues Synchronised
# ===
Expand Down Expand Up @@ -55,7 +56,7 @@ def run
end
rescue Errno::ECONNREFUSED => e
critical e.message
rescue => e
rescue StandardError => e
unknown e.message
end

Expand Down
5 changes: 3 additions & 2 deletions bin/check-rabbitmq-stomp-alive.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ check alive plugin
# ===
Expand Down Expand Up @@ -118,7 +119,7 @@ def vhost_alive?
{ 'status' => 'critical', 'message' => 'TCP connection refused' }
rescue Stomp::Error::BrokerException => e
{ 'status' => 'critical', 'message' => "Error from broker. Check auth details? #{e.message}" }
rescue => e
rescue StandardError => e
{ 'status' => 'unknown', 'message' => "#{e.class}: #{e.message}" }
end
end
Expand Down
3 changes: 2 additions & 1 deletion bin/metrics-rabbitmq-exchange.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ Exchange Metrics
# ===
Expand Down
5 changes: 3 additions & 2 deletions bin/metrics-rabbitmq-overview.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ Overview Metrics
# ===
Expand Down Expand Up @@ -99,7 +100,7 @@ def acquire_rabbitmq_info
password: password,
ssl: config[:ssl]
)
rescue
rescue StandardError
warning 'could not get rabbitmq info'
end
rabbitmq_info
Expand Down
3 changes: 2 additions & 1 deletion bin/metrics-rabbitmq-queue.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
# encoding: UTF-8
# frozen_string_literal: true

#
# RabbitMQ Queue Metrics
# ===
Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-rabbitmq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'ruby_dig'

require 'sensu-plugins-rabbitmq/version'
Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-rabbitmq/check.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

require 'sensu-plugin/check/cli'
require 'sensu-plugins-rabbitmq/rabbitmq'

Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-rabbitmq/metrics.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'sensu-plugin/metric/cli'
require 'socket'
require 'sensu-plugins-rabbitmq/rabbitmq'
Expand Down
4 changes: 3 additions & 1 deletion lib/sensu-plugins-rabbitmq/rabbitmq.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

require 'carrot-top'
require 'inifile'

Expand Down Expand Up @@ -66,7 +68,7 @@ def acquire_rabbitmq_info(property = nil)
password: password,
ssl: config[:ssl]
)
rescue
rescue StandardError
warning 'could not get rabbitmq info'
end

Expand Down
Loading