Skip to content

Commit 453a44a

Browse files
committed
some cleanaup work
CVES: - https://nvd.nist.gov/vuln/detail/CVE-2017-17042 - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418 Breaking Changes: - removing ruby `< 2.3` support Fixes: - backported a fix from the slack handler I made in sensu-plugins/sensu-plugins-slack#62 as I realized it shared the same code. I am thinking going forward it might be nice to have that be part of the `sensu-plugin` class so it could be available to all plugins without having a bunch of shared code. Misc Updates: - appeased the cops Signed-off-by: Ben Abrams <[email protected]>
1 parent 86ac43e commit 453a44a

9 files changed

+52
-8
lines changed

.rubocop.yml

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

2929
Style/Documentation:
3030
Enabled: false
31+
32+
AllCops:
33+
TargetRubyVersion: 2.3

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ before_install:
66
install:
77
- bundle install
88
rvm:
9-
- 2.0
10-
- 2.1
11-
- 2.2
129
- 2.3.0
1310
- 2.4.1
1411
notifications:

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
55

66
## [Unreleased]
77

8+
### Security
9+
- updated `yard` dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 which closes attacks against a yard server loading arbitrary files (@majormoses)
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 versions `< 2.3` support (@majormoses)
14+
- bumped `sensu-plugin` to `~> 2.7` which removes in handler event filtering you can read about it [here](https://github.com/sensu-plugins/sensu-plugin/blob/master/CHANGELOG.md#v145---2017-03-07)(@majormoses)
15+
16+
### Fixed
17+
- fix `handler-microsoft-teams.rb`: rescue any non sensu specification compliant status code passed to the microsoft-teams handler as the color matching `unknown` (@majormoses)
18+
19+
### Changed
20+
- appeased the cops (@majormoses)
21+
822
## [1.3.1] - 2018-09-12
923
### Fixed
1024
- Add erubis gem as a startup dependency (@asachs01)

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
gemspec

Rakefile

+2
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'

bin/handler-microsoft-teams.rb

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

34
# Copyright 2017 Jose Gaspar and contributors.
45
#
@@ -199,7 +200,21 @@ def color
199200
2 => '#FF0000',
200201
3 => '#6600CC'
201202
}
202-
color.fetch(check_status.to_i)
203+
# a script can return any error code it feels like we should not assume
204+
# that it will always be 0,1,2,3 even if that is the sensu (nagions)
205+
# specification. A couple common examples:
206+
# 1. A sensu server schedules a check on the instance but the command
207+
# executed does not exist in your `$PATH`. Shells will return a `127` status
208+
# code.
209+
# 2. Similarly a `126` is a permission denied or the command is not
210+
# executable.
211+
# Rather than adding every possible value we should just treat any non spec
212+
# designated status code as `unknown`s.
213+
begin
214+
color.fetch(check_status.to_i)
215+
rescue KeyError
216+
color.fetch(3)
217+
end
203218
end
204219

205220
def check_status
@@ -213,6 +228,11 @@ def translate_status
213228
2 => :CRITICAL,
214229
3 => :UNKNOWN
215230
}
216-
status[check_status.to_i]
231+
begin
232+
status[check_status.to_i]
233+
# handle any non standard check status as `unknown`
234+
rescue KeyError
235+
status.fetch(3)
236+
end
217237
end
218238
end

lib/sensu-plugins-microsoft-teams.rb

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

lib/sensu-plugins-microsoft-teams/version.rb

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

sensu-plugins-microsoft-teams.gemspec

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
lib = File.expand_path('lib', __dir__)
24
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
35

@@ -22,13 +24,13 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
2224
s.platform = Gem::Platform::RUBY
2325
s.post_install_message = 'You can use the embedded Ruby by setting EMBEDDED_RUBY=true in /etc/default/sensu'
2426
s.require_paths = ['lib']
25-
s.required_ruby_version = '>= 2.0.0'
27+
s.required_ruby_version = '>= 2.3.0'
2628
s.summary = 'Sensu plugins for interfacing with Microsoft Teams'
2729
s.test_files = s.files.grep(%r{^(test|spec|features)/})
2830
s.version = SensuPluginsMicrosoftTeams::Version::VER_STRING
2931

3032
s.add_runtime_dependency 'erubis', '~> 2.7'
31-
s.add_runtime_dependency 'sensu-plugin', '~> 1.2'
33+
s.add_runtime_dependency 'sensu-plugin', '~> 2.7'
3234

3335
s.add_development_dependency 'bundler', '~> 1.15'
3436
s.add_development_dependency 'github-markup', '~> 1.3'
@@ -37,5 +39,5 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
3739
s.add_development_dependency 'redcarpet', '~> 3.2'
3840
s.add_development_dependency 'rspec', '~> 3.4'
3941
s.add_development_dependency 'rubocop', '~> 0.49.0'
40-
s.add_development_dependency 'yard', '~> 0.8'
42+
s.add_development_dependency 'yard', '~> 0.9.11'
4143
end

0 commit comments

Comments
 (0)