Skip to content

Commit e14a062

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

33 files changed

+115
-34
lines changed

.rubocop.yml

+20
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,23 @@ Style/Next:
3434

3535
Style/MultilineTernaryOperator:
3636
Enabled: false
37+
38+
# safe navigation was introduced in ruby 2.3
39+
Style/SafeNavigation:
40+
Enabled: false
41+
42+
# match?() was added in ruby 2.4
43+
Performance/RegexpMatch:
44+
Enabled: false
45+
46+
47+
# TODO: figure out which to use `Date` or `Time`
48+
Style/DateTime:
49+
Enabled: false
50+
51+
52+
# testing can be slow
53+
Metrics/BlockLength:
54+
Enabled: true
55+
Exclude:
56+
- 'test/**/*.rb'

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ cache:
44
install:
55
- bundle install
66
rvm:
7-
- 2.0
87
- 2.1
98
- 2.2
109
- 2.3.0
@@ -27,7 +26,6 @@ deploy:
2726
on:
2827
tags: true
2928
all_branches: true
30-
rvm: 2.0
3129
rvm: 2.1
3230
rvm: 2.2
3331
rvm: 2.3.0

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugin
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+
### Changed
15+
- appeased the cops and updated cop config (@majormoses)
16+
817
## [2.3.1] - 2018-02-28
918
### Changed
1019
- update whois-parser gem dependency to version 1.0.1 (@amdprophet)

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
# Specify your gem's dependencies in sensu-plugins-network-checks.gemspec

Rakefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bundler/gem_tasks'
24
require 'github/markup'
35
require 'redcarpet'
@@ -7,12 +9,12 @@ require 'yard'
79
require 'yard/rake/yardoc_task'
810

911
desc 'Don\'t run Rubocop for unsupported versions'
10-
args = [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
12+
args = %i[spec make_bin_executable yard rubocop check_binstubs]
1113

1214
YARD::Rake::YardocTask.new do |t|
13-
OTHER_PATHS = %w().freeze
15+
OTHER_PATHS = %w[].freeze
1416
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
15-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
17+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
1618
end
1719

1820
RuboCop::RakeTask.new

bin/check-banner.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
3-
# encoding: UTF-8
45
# check-banner
56
#
67
# DESCRIPTION:

bin/check-jsonwhois-domain-expiration.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env ruby
2-
# encoding: utf-8
2+
# frozen_string_literal: false
3+
34
#
45
# check-jsonwhois-domain-expiration
56
#
@@ -72,7 +73,7 @@ class JSONWhoisDomainExpirationCheck < Sensu::Plugin::Check::CLI
7273
short: '-r LEVEL',
7374
long: '--report-errors LEVEL',
7475
proc: proc(&:to_sym),
75-
in: %i(unknown warning critical),
76+
in: %i[unknown warning critical],
7677
default: :unknown,
7778
description: 'Level for reporting connection or parsing errors'
7879

@@ -110,7 +111,7 @@ def expiration_results
110111
else
111112
results[:ok][domain] = domain_result
112113
end
113-
rescue
114+
rescue StandardError
114115
results[:unknown][domain] = 'Connection or parsing error' unless config[:'ignore-errors']
115116
end
116117
end

bin/check-mtu.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# check-mtu.rb
46
#

bin/check-multicast-groups.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-multicast-groups
46
#
@@ -66,7 +68,7 @@ def run
6668
critical "#{diff.size} missing multicast group(s):\n#{diff_output}"
6769
end
6870
ok
69-
rescue => ex
71+
rescue StandardError => ex
7072
critical "Failed to check multicast groups: #{ex}"
7173
end
7274
end

bin/check-netfilter-conntrack.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
23

3-
bin_dir = File.expand_path(File.dirname(__FILE__))
4+
bin_dir = File.expand_path(__dir__)
45
shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.sh')
56

67
exec shell_script_path, *ARGV

bin/check-netstat-tcp.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# check-netstat-tcp
46
#
@@ -102,7 +104,7 @@ def netstat(protocols = ['tcp'])
102104
end
103105

104106
def run
105-
state_counts = netstat(%w(tcp tcp6))
107+
state_counts = netstat(%w[tcp tcp6])
106108
is_critical = false
107109
is_warning = false
108110
message = ''

bin/check-ping.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# check-ping
46
#
@@ -83,7 +85,7 @@ def run
8385
pt = Net::Ping::External.new(config[:host], nil, config[:timeout])
8486

8587
config[:count].times do |i|
86-
sleep(config[:interval]) unless i == 0
88+
sleep(config[:interval]) unless i.zero?
8789
result[i] = config[:ipv6] ? pt.ping6 : pt.ping
8890
end
8991

bin/check-ports-bind.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
3-
# encoding: UTF-8
45
# check-ports-bind
56
#
67
# DESCRIPTION:

bin/check-ports-nmap.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# check-ports-nmap
46
#

bin/check-ports.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
3-
# encoding: UTF-8
45
# check-ports
56
#
67
# DESCRIPTION:

bin/check-rbl.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# check-rbl
46
#
@@ -89,7 +91,7 @@ def run
8991

9092
# YELLOW
9193
unless msg_string.empty? # rubocop:disable UnlessElse
92-
if criticality > 0
94+
if criticality.positive?
9395
critical "#{ip_add} Blacklisted in#{msg_string}"
9496
else
9597
warning "#{ip_add} Blacklisted in#{msg_string}"

bin/check-socat.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: false
3+
24
#
35
# check-socat
46
#

bin/check-whois-domain-expiration-multi.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env ruby
2-
# encoding: utf-8
2+
# frozen_string_literal: false
3+
34
#
45
# check-whois-domain-expiration-multi
56
#
@@ -66,7 +67,7 @@ class WhoisDomainExpirationCheck < Sensu::Plugin::Check::CLI
6667
short: '-r LEVEL',
6768
long: '--report-errors LEVEL',
6869
proc: proc(&:to_sym),
69-
in: %i(unknown warning critical),
70+
in: %i[unknown warning critical],
7071
default: :unknown,
7172
description: 'Level for reporting connection or parsing errors'
7273

@@ -126,7 +127,7 @@ def expiration_results
126127
else
127128
results[:ok][domain] = domain_result
128129
end
129-
rescue
130+
rescue StandardError
130131
results[:unknown][domain] = 'Parsing error' unless config[:'ignore-errors']
131132
end
132133
end

bin/check-whois-domain-expiration.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env ruby
2-
# encoding: utf-8
2+
# frozen_string_literal: false
3+
34
#
45
# check-whois-domain-expiration
56
#
@@ -63,6 +64,7 @@ class WhoisDomainExpirationCheck < Sensu::Plugin::Check::CLI
6364
def run
6465
whois = Whois.whois(config[:domain])
6566

67+
# TODO: figure out which to use `Date` or `Time`
6668
expires_on = DateTime.parse(whois.parser.expires_on.to_s)
6769
num_days = (expires_on - DateTime.now).to_i
6870

@@ -75,7 +77,7 @@ def run
7577
else
7678
ok
7779
end
78-
rescue
80+
rescue StandardError
7981
unknown "#{config[:domain]} can't be checked"
8082
end
8183
end

bin/metrics-interface.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env ruby
2-
# encoding: UTF-8
2+
# frozen_string_literal: true
3+
34
#
45
# interface-metrics
56
#
@@ -52,7 +53,7 @@ class InterfaceGraphite < Sensu::Plugin::Metric::CLI::Graphite
5253
def run
5354
# Metrics borrowed from hoardd: https://github.com/coredump/hoardd
5455

55-
metrics = %w(rxBytes
56+
metrics = %w[rxBytes
5657
rxPackets
5758
rxErrors
5859
rxDrops
@@ -67,7 +68,7 @@ def run
6768
txFifo
6869
txColls
6970
txCarrier
70-
txCompressed)
71+
txCompressed]
7172

7273
File.open('/proc/net/dev', 'r').each_line do |line|
7374
interface, stats_string = line.scan(/^\s*([^:]+):\s*(.*)$/).first

bin/metrics-net.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# metrics-net
46
#
@@ -91,7 +93,7 @@ def run
9193

9294
begin
9395
if_speed = File.open(iface_path + '/speed').read.strip
94-
rescue
96+
rescue StandardError
9597
if_speed = 0
9698
end
9799

bin/metrics-netif.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# netif-metrics
46
#

bin/metrics-netstat-tcp.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# metrics-netstat-tcp
46
#

bin/metrics-ping.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#! /usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# metrics-ping
46
#
@@ -69,8 +71,8 @@ class PingMetrics < Sensu::Plugin::Metric::CLI::Graphite
6971
long: '--timeout TIMEOUT',
7072
default: 5
7173

72-
OVERVIEW_METRICS = [:packets_transmitted, :packets_received, :packet_loss, :time].freeze
73-
STATISTIC_METRICS = [:min, :avg, :max, :mdev].freeze
74+
OVERVIEW_METRICS = %i[packets_transmitted packets_received packet_loss time].freeze
75+
STATISTIC_METRICS = %i[min avg max mdev].freeze
7476
FLOAT = '(\d+\.\d+)'.freeze
7577

7678
def overview

bin/metrics-sockstat.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
24
#
35
# metrics-sockstat
46
#
@@ -54,7 +56,7 @@ def generic_metrics(fields)
5456

5557
def read_sockstat
5658
return IO.read('/proc/net/sockstat')
57-
rescue => e
59+
rescue StandardError => e
5860
unknown "Failed to read /proc/net/sockstat: #{e}"
5961
end
6062

lib/sensu-plugins-network-checks.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# frozen_string_literal: true
2+
13
require 'sensu-plugins-network-checks/version'

lib/sensu-plugins-network-checks/version.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module SensuPluginsNetworkChecks
24
module Version
35
MAJOR = 2

0 commit comments

Comments
 (0)