Skip to content

Commit 8bab8ba

Browse files
authored
Merge pull request #113 from sensu-plugins/fix/CVE-2017-8418
[CVE-2017-8418] - updating rubocop dependency.
2 parents 16a31a9 + 3b8591e commit 8bab8ba

10 files changed

+41
-19
lines changed

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,11 @@ Style/GuardClause:
4444
Metrics/ModuleLength:
4545
Exclude:
4646
- 'lib/sensu-plugins-elasticsearch/elasticsearch-query.rb'
47+
48+
# TODO: come cleanup the code that uses this once we figure out what we want to use
49+
Lint/UriEscapeUnescape:
50+
Enabled: false
51+
52+
# TODO: switch from `DateTime` to `Time` or `Date`
53+
Style/DateTime:
54+
Enabled: false

.travis.yml

Lines changed: 0 additions & 1 deletion
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

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
55

66
## [Unreleased]
77

8+
### Security
9+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
10+
11+
### Breaking Changes
12+
- removed ruby `< 2.1` support @majormoses
13+
14+
### Changes
15+
- added explicit dependency on `mixlib-shellout` to keep compatibility with ruby `2.1` (@majormoses)
16+
- appeased the cops and created TODOs (@majormoses)
17+
818
## [1.12.0] - 2018-03-01
919
### Added
1020
- check-es-indices-field-number.rb: check if the number of fields in index(es) is approaching limit (default to 1000 in ES) (@huynt1979)

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ require 'English'
99
require 'kitchen/rake_tasks'
1010

1111
YARD::Rake::YardocTask.new do |t|
12-
OTHER_PATHS = %w().freeze
12+
OTHER_PATHS = %w[].freeze
1313
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
14-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
14+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
1515
end
1616

1717
RuboCop::RakeTask.new
@@ -42,5 +42,5 @@ Kitchen::RakeTasks.new
4242
desc 'Alias for kitchen:all'
4343
task integration: 'kitchen:all'
4444

45-
task default: %i(make_bin_executable yard rubocop check_binstubs integration)
46-
task quick: %i(make_bin_executable yard rubocop check_binstubs)
45+
task default: %i[make_bin_executable yard rubocop check_binstubs integration]
46+
task quick: %i[make_bin_executable yard rubocop check_binstubs]

bin/check-es-heap.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def acquire_stats
142142

143143
def acquire_heap_data(node)
144144
return node['jvm']['mem']['heap_used_in_bytes'], node['jvm']['mem']['heap_max_in_bytes']
145-
rescue
145+
rescue StandardError
146146
warning 'Failed to obtain heap used in bytes'
147147
end
148148

@@ -166,7 +166,7 @@ def run
166166
status = { crit: '', warn: '', ok: '' }
167167

168168
# Check all the nodes in the cluster, alert if any of the nodes have heap usage above thresholds
169-
stats['nodes'].each do |_, node|
169+
stats['nodes'].each_value do |node|
170170
heap_used, heap_max = acquire_heap_data(node)
171171
heap_usage, output = acquire_heap_usage(heap_used, heap_max, node['name'])
172172
if heap_usage >= config[:crit]

bin/check-es-indices-sizes.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class ESCheckIndicesSizes < Sensu::Plugin::Check::CLI
108108

109109
def get_indices_to_delete(starting_date, total_bytes_to_delete, indices_with_sizes)
110110
total_bytes_deleted = 0
111+
112+
# TODO: switch from `DateTime` to `Time` or `Date`
111113
curr_date = DateTime.now
112114

113115
indices_to_delete = []
@@ -161,10 +163,10 @@ def run
161163
nodes_being_used = node_fs_stats['nodes'].values.select { |node| node['indices']['store']['size_in_bytes'] > 0 }
162164

163165
# TODO: come back and cleanup all these rubocop disables with a little refactor
164-
# rubocop:disable Style/SingleLineBlockParams,Metrics/LineLength
166+
# rubocop:disable Metrics/LineLength
165167
used_in_bytes = nodes_being_used.map { |node| node['fs']['data'].map { |data| data['total_in_bytes'] - data['available_in_bytes'] }.flatten }.flatten.inject { |sum, x| sum + x }
166168
total_in_bytes = nodes_being_used.map { |node| node['fs']['data'].map { |data| data['total_in_bytes'] }.flatten }.flatten.inject { |sum, x| sum + x }
167-
# rubocop:enable Style/SingleLineBlockParams,Metrics/LineLength
169+
# rubocop:enable Metrics/LineLength
168170

169171
if config[:maximum_megabytes] > 0
170172
target_bytes_used = config[:maximum_megabytes] * 1_000_000

bin/check-es-shard-allocation-status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_status(type)
107107
# which is the ES default
108108
begin
109109
settings[type]['cluster']['routing']['allocation']['enable'].downcase
110-
rescue
110+
rescue StandardError
111111
'all'
112112
end
113113
end

bin/metrics-es-cluster.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ def master?
144144
end
145145

146146
def acquire_health
147-
health = get_es_resource('/_cluster/health').reject { |k, _v| %w(cluster_name timed_out).include?(k) }
148-
health['status'] = %w(red yellow green).index(health['status'])
147+
health = get_es_resource('/_cluster/health').reject { |k, _v| %w[cluster_name timed_out].include?(k) }
148+
health['status'] = %w[red yellow green].index(health['status'])
149149
health
150150
end
151151

@@ -191,7 +191,7 @@ def acquire_allocation_status
191191
cluster_config = get_es_resource('/_cluster/settings')
192192
transient_settings = cluster_config['transient']
193193
if transient_settings.key?('cluster')
194-
return %w(none new_primaries primaries all).index(transient_settings['cluster']['routing']['allocation']['enable'])
194+
return %w[none new_primaries primaries all].index(transient_settings['cluster']['routing']['allocation']['enable'])
195195
else
196196
return nil
197197
end

bin/metrics-es-node-graphite.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ def run
165165
es_version = Gem::Version.new(acquire_es_version)
166166

167167
if es_version >= Gem::Version.new('3.0.0')
168-
stats_query_array = %w(indices http transport)
168+
stats_query_array = %w[indices http transport]
169169
stats_query_array.push('jvm') if jvm_stats == true
170170
stats_query_array.push('os') if os_stat == true
171171
stats_query_array.push('process') if process_stats == true
172172
stats_query_array.push('thread_pool') if tp_stats == true
173173
stats_query_array.push('fs') if fs_stats == true
174174
stats_query_string = stats_query_array.join(',')
175175
elsif es_version >= Gem::Version.new('1.0.0')
176-
stats_query_array = %w(indices http network transport thread_pool)
176+
stats_query_array = %w[indices http network transport thread_pool]
177177
stats_query_array.push('jvm') if jvm_stats == true
178178
stats_query_array.push('os') if os_stat == true
179179
stats_query_array.push('process') if process_stats == true

sensu-plugins-elasticsearch.gemspec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'date'
55
require_relative 'lib/sensu-plugins-elasticsearch'
66

77
# pvt_key = '~/.ssh/gem-private_key.pem'
8-
Gem::Specification.new do |s|
8+
Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
99
s.authors = ['Sensu Plugins and contributors']
1010
# s.cert_chain = ['certs/sensu-plugins.pem']
1111
s.date = Date.today.to_s
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
1414
service health and metrics for cluster, node, and more.'
1515
s.email = '<sensu-users@googlegroups.com>'
1616
s.executables = Dir.glob('bin/**/*.rb').map { |file| File.basename(file) }
17-
s.files = Dir.glob('{bin,lib}/**/*') + %w(LICENSE README.md CHANGELOG.md)
17+
s.files = Dir.glob('{bin,lib}/**/*') + %w[LICENSE README.md CHANGELOG.md]
1818
s.homepage = 'https://github.com/sensu-plugins/sensu-plugins-elasticsearch'
1919
s.license = 'MIT'
2020
s.metadata = { 'maintainer' => 'sensu-plugin',
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
2626
s.platform = Gem::Platform::RUBY
2727
s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu'
2828
s.require_paths = ['lib']
29-
s.required_ruby_version = '>= 2.0.0'
29+
s.required_ruby_version = '>= 2.1.0'
3030
# s.signing_key = File.expand_path(pvt_key) if $PROGRAM_NAME =~ /gem\z/
3131
s.summary = 'Sensu plugins for elasticsearch'
3232
s.test_files = s.files.grep(%r{^(test|spec|features)/})
@@ -42,11 +42,14 @@ Gem::Specification.new do |s|
4242
s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
4343
s.add_development_dependency 'github-markup', '~> 1.3'
4444
s.add_development_dependency 'kitchen-docker', '~> 2.6'
45+
# locked to keep ruby 2.1 support, this is pulled in by test-kitchen
46+
s.add_development_dependency 'mixlib-shellout', ['< 2.3.0', '~> 2.2']
4547
s.add_development_dependency 'pry', '~> 0.10'
4648
s.add_development_dependency 'rake', '~> 10.0'
4749
s.add_development_dependency 'redcarpet', '~> 3.2'
4850
s.add_development_dependency 'rspec', '~> 3.1'
49-
s.add_development_dependency 'rubocop', '~> 0.40.0'
51+
s.add_development_dependency 'rubocop', '~> 0.51.0'
52+
# 0.17 requires ruby 2.3+
5053
s.add_development_dependency 'test-kitchen', '~> 1.16.0'
5154
s.add_development_dependency 'yard', '~> 0.8'
5255
end

0 commit comments

Comments
 (0)