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. #52

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
5 changes: 5 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ RegexpLiteral:

Style/Documentation:
Enabled: false

# tests can be slow
Metrics/BlockLength:
Exclude:
- 'test/**/*'
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ before_install:
install:
- bundle install
rvm:
- 2.0
- 2.1
- 2.2
- 2.3.0
Expand All @@ -33,7 +32,6 @@ deploy:
on:
tags: true
all_branches: true
rvm: 2.0
rvm: 2.1
rvm: 2.2
rvm: 2.3.0
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ 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. (@majormoses)

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

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

## [2.4.0] - 2018-03-14
### Added
- check-redis-connections-available.rb: checks the number of connections available (@nishiki)

## [2.3.2] - 2017-12-21
### Fixed
- locked `development_dependency` of `mixlib-shellout` on to fix ruby 2.1 support (@majormoses)
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ require 'yard/rake/yardoc_task'
require 'kitchen/rake_tasks'

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 Expand Up @@ -57,6 +57,6 @@ task :integration do
threads.map(&:join)
end

task default: %i(make_bin_executable yard rubocop check_binstubs integration)
task default: %i[make_bin_executable yard rubocop check_binstubs integration]

task quick: %i(make_bin_executable yard rubocop check_binstubs unit)
task quick: %i[make_bin_executable yard rubocop check_binstubs unit]
3 changes: 1 addition & 2 deletions bin/check-redis-connections-available.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ def run
else
ok "There are #{conn_available} connections available (#{clients}/#{maxclients})"
end

rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/check-redis-info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def run
else
critical "Redis #{config[:redis_info_key]} is #{redis.info.fetch(config[:redis_info_key].to_s)}!"
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/check-redis-keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def run
else
ok "Redis list #{config[:pattern]} length is above thresholds"
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/check-redis-list-length.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def run
else
ok "Redis list #{config[:key]} length (#{length}) is below thresholds"
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
4 changes: 2 additions & 2 deletions bin/check-redis-memory-percentage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def run

redis_info = redis.info
max_memory = redis_info.fetch('maxmemory', 0).to_i
if max_memory == 0
if max_memory.zero?
max_memory = redis_info.fetch('total_system_memory', system_memory).to_i
end
memory_in_use = redis_info.fetch('used_memory').to_i.fdiv(1024) # used memory in KB (KiloBytes)
Expand All @@ -73,7 +73,7 @@ def run
else
ok "Redis memory usage: #{used_memory}% is below defined limits"
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/check-redis-memory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def run
else
ok "Redis memory usage: #{used_memory}KB is below defined limits"
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
4 changes: 2 additions & 2 deletions bin/check-redis-ping.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /usr/bin/env ruby
# encoding: UTF-8

# <script name>
#
# DESCRIPTION:
Expand Down Expand Up @@ -40,7 +40,7 @@ def run
else
critical 'Redis did not respond to the ping command'
end
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/check-redis-slave-status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def run
end
rescue KeyError
critical "Redis server on #{redis_endpoint} is not master and does not have master_link_status"
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
4 changes: 2 additions & 2 deletions bin/metrics-redis-graphite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ def run

# Loop thru commandstats entries for perf metrics
redis.info('commandstats').each do |k, v|
%w(calls usec_per_call usec).each do |x|
%w[calls usec_per_call usec].each do |x|
output "#{config[:scheme]}.commandstats.#{k}.#{x}", v[x]
end
end

ok
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion bin/metrics-redis-llen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def run
output "#{config[:scheme]}.#{key}.items", redis.llen(key)
end
ok
rescue
rescue StandardError
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
end
end
2 changes: 1 addition & 1 deletion lib/redis_client_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _configure_options
long: '--conn-failure-status EXIT_STATUS',
description: 'Returns the following exit status for Redis connection failures',
default: 'critical',
in: %w(unknown warning critical)
in: %w[unknown warning critical]

option :timeout,
short: '-t TIMEOUT',
Expand Down
8 changes: 4 additions & 4 deletions sensu-plugins-redis.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'date'

require_relative 'lib/sensu-plugins-redis'

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
Expand All @@ -15,7 +15,7 @@ Gem::Specification.new do |s|
status, `INFO` metrics, key counts, list lengths,
and more.'
s.email = '<[email protected]>'
s.files = Dir.glob('{bin,lib}/**/*.rb') + %w(LICENSE README.md CHANGELOG.md)
s.files = Dir.glob('{bin,lib}/**/*.rb') + %w[LICENSE README.md CHANGELOG.md]
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-redis'
s.license = 'MIT'
Expand All @@ -28,7 +28,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 working with redis'
s.test_files = s.files.grep(%r{^(test|spec|features)/})
Expand All @@ -49,7 +49,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'redcarpet', '~> 3.2'
s.add_development_dependency 'rspec', '~> 3.1'
s.add_development_dependency 'rubocop', '~> 0.40.0'
s.add_development_dependency 'rubocop', '~> 0.51.0'
s.add_development_dependency 'serverspec', '~> 2.36.1'
s.add_development_dependency 'test-kitchen', '~> 1.16.0'
s.add_development_dependency 'yard', '~> 0.8'
Expand Down
8 changes: 4 additions & 4 deletions test/bin/check-redis-connections-available_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
end

it 'accepts config' do
args = %w(--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1)
args = %w[--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1]
check = RedisConnectionsAvailable.new(args)
expect(check.default_redis_options[:password]).to eq 'foobar'
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
expect(check.default_redis_options[:port]).to eq 3456
end

it 'sets socket option accordingly' do
args = %w(--socket /some/path/redis.sock --warning 2 --critical 1)
args = %w[--socket /some/path/redis.sock --warning 2 --critical 1]
check = RedisConnectionsAvailable.new(args)
expect(check.default_redis_options[:path]).to eq '/some/path/redis.sock'
expect(check.default_redis_options[:host]).to be_nil
expect(check.default_redis_options[:port]).to be_nil
end

it 'returns warning' do
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1)
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1]
check = RedisConnectionsAvailable.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
end

it 'returns warning' do
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1)
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1]
check = RedisConnectionsAvailable.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
Expand Down
6 changes: 3 additions & 3 deletions test/bin/check-redis-info_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
end

it 'accepts config' do
args = %w(--host 10.0.0.1 --port 3456 --password foobar)
args = %w[--host 10.0.0.1 --port 3456 --password foobar]
check = RedisSlaveCheck.new(args)
expect(check.default_redis_options[:password]).to eq 'foobar'
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
expect(check.default_redis_options[:port]).to eq 3456
end

it 'sets socket option accordingly' do
args = %w(--socket /some/path/redis.sock)
args = %w[--socket /some/path/redis.sock]
check = RedisSlaveCheck.new(args)
expect(check.default_redis_options[:path]).to eq '/some/path/redis.sock'
expect(check.default_redis_options[:host]).to be_nil
expect(check.default_redis_options[:port]).to be_nil
end

it 'returns warning' do
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1)
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1)]
check = RedisSlaveCheck.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
Expand Down
8 changes: 4 additions & 4 deletions test/bin/check-redis-keys_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@
end

it 'accepts config' do
args = %w(--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1)
args = %w[--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1]
check = RedisKeysCheck.new(args)
expect(check.default_redis_options[:password]).to eq 'foobar'
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
expect(check.default_redis_options[:port]).to eq 3456
end

it 'sets socket option accordingly' do
args = %w(--socket /some/path/redis.sock --warning 2 --critical 1)
args = %w[--socket /some/path/redis.sock --warning 2 --critical 1]
check = RedisKeysCheck.new(args)
expect(check.default_redis_options[:path]).to eq '/some/path/redis.sock'
expect(check.default_redis_options[:host]).to be_nil
expect(check.default_redis_options[:port]).to be_nil
end

it 'returns warning' do
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1)
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1]
check = RedisKeysCheck.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
end

it 'returns warning' do
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1)
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1 --warning 2 --critical 1]
check = RedisKeysCheck.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
Expand Down
8 changes: 4 additions & 4 deletions test/bin/check-redis-list-length_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
end

it 'accepts config' do
args = %w(--host 127.0.0.1 --password foobar --warning 2 --critical 1 -k key1)
args = %w[--host 127.0.0.1 --password foobar --warning 2 --critical 1 -k key1]
check = RedisListLengthCheck.new(args)
expect(check.config[:password]).to eq 'foobar'
end

it 'sets socket option accordingly' do
args = %w(--socket /some/path/redis.sock --warning 2 --critical 1 -k key1)
args = %w[--socket /some/path/redis.sock --warning 2 --critical 1 -k key1]
check = RedisListLengthCheck.new(args)
expect(check.config[:socket]).to eq '/some/path/redis.sock'
end

it 'returns warning' do
args = %w(
args = %w[
--host 1.1.1.1
--port 1234
--conn-failure-status warning
--timeout 0.1
--warning 2
--critical 1
-k key1
)
]
check = RedisListLengthCheck.new(args)
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
expect { check.run }.to raise_error(SystemExit)
Expand Down
Loading