Skip to content

Commit e350602

Browse files
committed
[CVE-2017-8418] - updating rubocop dependency.
Breaking Changes: - removed ruby `< 2.1` support Misc: - appeased the cops Signed-off-by: Ben Abrams <[email protected]>
1 parent eef189e commit e350602

27 files changed

+80
-70
lines changed

.rubocop.yml

+5
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,8 @@ RegexpLiteral:
2828

2929
Style/Documentation:
3030
Enabled: false
31+
32+
# tests can be slow
33+
Metrics/BlockLength:
34+
Exclude:
35+
- 'test/**/*'

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ before_install:
99
install:
1010
- bundle install
1111
rvm:
12-
- 2.0
1312
- 2.1
1413
- 2.2
1514
- 2.3.0
@@ -33,7 +32,6 @@ deploy:
3332
on:
3433
tags: true
3534
all_branches: true
36-
rvm: 2.0
3735
rvm: 2.1
3836
rvm: 2.2
3937
rvm: 2.3.0

CHANGELOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
66

77
## [Unreleased]
88

9+
### Security
10+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
11+
12+
### Breaking Changes
13+
- removed ruby `< 2.1` support (@majormoses)
14+
15+
### Changed
16+
- appeased the cops (@majormoses)
17+
918
## [2.4.0] - 2018-03-14
1019
### Added
1120
- check-redis-connections-available.rb: checks the number of connections available (@nishiki)
12-
1321
## [2.3.2] - 2017-12-21
1422
### Fixed
1523
- locked `development_dependency` of `mixlib-shellout` on to fix ruby 2.1 support (@majormoses)

Rakefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ require 'yard/rake/yardoc_task'
88
require 'kitchen/rake_tasks'
99

1010
YARD::Rake::YardocTask.new do |t|
11-
OTHER_PATHS = %w().freeze
11+
OTHER_PATHS = %w[].freeze
1212
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
13-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
13+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
1414
end
1515

1616
RuboCop::RakeTask.new
@@ -57,6 +57,6 @@ task :integration do
5757
threads.map(&:join)
5858
end
5959

60-
task default: %i(make_bin_executable yard rubocop check_binstubs integration)
60+
task default: %i[make_bin_executable yard rubocop check_binstubs integration]
6161

62-
task quick: %i(make_bin_executable yard rubocop check_binstubs unit)
62+
task quick: %i[make_bin_executable yard rubocop check_binstubs unit]

bin/check-redis-connections-available.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def run
5757
else
5858
ok "There are #{conn_available} connections available (#{clients}/#{maxclients})"
5959
end
60-
61-
rescue
60+
rescue StandardError
6261
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
6362
end
6463
end

bin/check-redis-info.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def run
4545
else
4646
critical "Redis #{config[:redis_info_key]} is #{redis.info.fetch(config[:redis_info_key].to_s)}!"
4747
end
48-
rescue
48+
rescue StandardError
4949
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
5050
end
5151
end

bin/check-redis-keys.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def run
4949
else
5050
ok "Redis list #{config[:pattern]} length is above thresholds"
5151
end
52-
rescue
52+
rescue StandardError
5353
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
5454
end
5555
end

bin/check-redis-list-length.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run
5757
else
5858
ok "Redis list #{config[:key]} length (#{length}) is below thresholds"
5959
end
60-
rescue
60+
rescue StandardError
6161
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
6262
end
6363
end

bin/check-redis-memory-percentage.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run
5757

5858
redis_info = redis.info
5959
max_memory = redis_info.fetch('maxmemory', 0).to_i
60-
if max_memory == 0
60+
if max_memory.zero?
6161
max_memory = redis_info.fetch('total_system_memory', system_memory).to_i
6262
end
6363
memory_in_use = redis_info.fetch('used_memory').to_i.fdiv(1024) # used memory in KB (KiloBytes)
@@ -73,7 +73,7 @@ def run
7373
else
7474
ok "Redis memory usage: #{used_memory}% is below defined limits"
7575
end
76-
rescue
76+
rescue StandardError
7777
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
7878
end
7979
end

bin/check-redis-memory.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run
4242
else
4343
ok "Redis memory usage: #{used_memory}KB is below defined limits"
4444
end
45-
rescue
45+
rescue StandardError
4646
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
4747
end
4848
end

bin/check-redis-ping.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/env ruby
2-
# encoding: UTF-8
2+
33
# <script name>
44
#
55
# DESCRIPTION:
@@ -40,7 +40,7 @@ def run
4040
else
4141
critical 'Redis did not respond to the ping command'
4242
end
43-
rescue
43+
rescue StandardError
4444
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
4545
end
4646
end

bin/check-redis-slave-status.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run
2424
end
2525
rescue KeyError
2626
critical "Redis server on #{redis_endpoint} is not master and does not have master_link_status"
27-
rescue
27+
rescue StandardError
2828
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
2929
end
3030
end

bin/metrics-redis-graphite.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ def run
8888

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

9696
ok
97-
rescue
97+
rescue StandardError
9898
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
9999
end
100100
end

bin/metrics-redis-llen.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def run
3434
output "#{config[:scheme]}.#{key}.items", redis.llen(key)
3535
end
3636
ok
37-
rescue
37+
rescue StandardError
3838
send(config[:conn_failure_status], "Could not connect to Redis server on #{redis_endpoint}")
3939
end
4040
end

lib/redis_client_options.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _configure_options
7272
long: '--conn-failure-status EXIT_STATUS',
7373
description: 'Returns the following exit status for Redis connection failures',
7474
default: 'critical',
75-
in: %w(unknown warning critical)
75+
in: %w[unknown warning critical]
7676

7777
option :timeout,
7878
short: '-t TIMEOUT',

sensu-plugins-redis.gemspec

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'date'
55

66
require_relative 'lib/sensu-plugins-redis'
77

8-
Gem::Specification.new do |s|
8+
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
99
s.authors = ['Sensu-Plugins and contributors']
1010

1111
s.date = Date.today.to_s
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
1515
status, `INFO` metrics, key counts, list lengths,
1616
and more.'
1717
s.email = '<[email protected]>'
18-
s.files = Dir.glob('{bin,lib}/**/*.rb') + %w(LICENSE README.md CHANGELOG.md)
18+
s.files = Dir.glob('{bin,lib}/**/*.rb') + %w[LICENSE README.md CHANGELOG.md]
1919
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
2020
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-redis'
2121
s.license = 'MIT'
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
2828
s.platform = Gem::Platform::RUBY
2929
s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu'
3030
s.require_paths = ['lib']
31-
s.required_ruby_version = '>= 2.0.0'
31+
s.required_ruby_version = '>= 2.1.0'
3232

3333
s.summary = 'Sensu plugins for working with redis'
3434
s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
4949
s.add_development_dependency 'rake', '~> 10.0'
5050
s.add_development_dependency 'redcarpet', '~> 3.2'
5151
s.add_development_dependency 'rspec', '~> 3.1'
52-
s.add_development_dependency 'rubocop', '~> 0.40.0'
52+
s.add_development_dependency 'rubocop', '~> 0.51.0'
5353
s.add_development_dependency 'serverspec', '~> 2.36.1'
5454
s.add_development_dependency 'test-kitchen', '~> 1.16.0'
5555
s.add_development_dependency 'yard', '~> 0.8'

test/bin/check-redis-connections-available_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@
77
end
88

99
it 'accepts config' do
10-
args = %w(--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1)
10+
args = %w[--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1]
1111
check = RedisConnectionsAvailable.new(args)
1212
expect(check.default_redis_options[:password]).to eq 'foobar'
1313
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
1414
expect(check.default_redis_options[:port]).to eq 3456
1515
end
1616

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

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

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

test/bin/check-redis-info_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
end
88

99
it 'accepts config' do
10-
args = %w(--host 10.0.0.1 --port 3456 --password foobar)
10+
args = %w[--host 10.0.0.1 --port 3456 --password foobar]
1111
check = RedisSlaveCheck.new(args)
1212
expect(check.default_redis_options[:password]).to eq 'foobar'
1313
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
1414
expect(check.default_redis_options[:port]).to eq 3456
1515
end
1616

1717
it 'sets socket option accordingly' do
18-
args = %w(--socket /some/path/redis.sock)
18+
args = %w[--socket /some/path/redis.sock]
1919
check = RedisSlaveCheck.new(args)
2020
expect(check.default_redis_options[:path]).to eq '/some/path/redis.sock'
2121
expect(check.default_redis_options[:host]).to be_nil
2222
expect(check.default_redis_options[:port]).to be_nil
2323
end
2424

2525
it 'returns warning' do
26-
args = %w(--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1)
26+
args = %w[--host 1.1.1.1 --port 1234 --conn-failure-status warning --timeout 0.1)]
2727
check = RedisSlaveCheck.new(args)
2828
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
2929
expect { check.run }.to raise_error(SystemExit)

test/bin/check-redis-keys_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,30 @@
77
end
88

99
it 'accepts config' do
10-
args = %w(--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1)
10+
args = %w[--host 10.0.0.1 --port 3456 --password foobar --warning 2 --critical 1]
1111
check = RedisKeysCheck.new(args)
1212
expect(check.default_redis_options[:password]).to eq 'foobar'
1313
expect(check.default_redis_options[:host]).to eq '10.0.0.1'
1414
expect(check.default_redis_options[:port]).to eq 3456
1515
end
1616

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

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

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

test/bin/check-redis-list-length_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77
end
88

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

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

2121
it 'returns warning' do
22-
args = %w(
22+
args = %w[
2323
--host 1.1.1.1
2424
--port 1234
2525
--conn-failure-status warning
2626
--timeout 0.1
2727
--warning 2
2828
--critical 1
2929
-k key1
30-
)
30+
]
3131
check = RedisListLengthCheck.new(args)
3232
expect(check).to receive(:warning).with('Could not connect to Redis server on 1.1.1.1:1234').and_raise(SystemExit)
3333
expect { check.run }.to raise_error(SystemExit)

0 commit comments

Comments
 (0)