Skip to content

Commit e5f3dc1

Browse files
committed
remove files changed in PR #70, unrelated to this new feature
1 parent af1c8d6 commit e5f3dc1

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

bin/check-ssl-anchor.rb

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,6 @@ class CheckSSLAnchor < Sensu::Plugin::Check::CLI
5757
long: '--anchor ANCHOR_VAL',
5858
required: true
5959

60-
option :regexp,
61-
description: 'Treat the anchor as a regexp',
62-
short: '-r',
63-
long: '--regexp',
64-
default: false,
65-
boolean: true,
66-
required: false
67-
6860
option :servername,
6961
description: 'Set the TLS SNI (Server Name Indication) extension',
7062
short: '-s',
@@ -87,7 +79,7 @@ def anchor_information
8779
-servername #{config[:servername]} < /dev/null 2>&1`.match(/Certificate chain(.*)---\nServer certificate/m)[1].split(/$/).map(&:strip)
8880
data = data.reject(&:empty?)
8981

90-
unless data[0] =~ /0 s:\/?CN ?=.*/m
82+
unless data[0] =~ /0 s:\/CN=.*/m
9183
data = 'NOTOK'
9284
end
9385
data
@@ -99,22 +91,11 @@ def run
9991
if data == 'NOTOK'
10092
critical 'An error was encountered while trying to retrieve the certificate chain.'
10193
end
102-
puts config[:regexp]
103-
# rubocop:disable Style/IfInsideElse
104-
if config[:regexp]
105-
ra = Regexp.new(config[:anchor].to_s)
106-
if data[-1] =~ ra
107-
ok 'Root anchor has been found.'
108-
else
109-
critical 'Root anchor did not match regexp /' + config[:anchor].to_s + "/\nFound \"" + data[-1] + '" instead.'
110-
end
94+
95+
if data[-1] == config[:anchor].to_s
96+
ok 'Root anchor has been found.'
11197
else
112-
if data[-1] == config[:anchor].to_s
113-
ok 'Root anchor has been found.'
114-
else
115-
critical 'Root anchor did not match string "' + config[:anchor].to_s + "\"\nFound \"" + data[-1] + '" instead.'
116-
end
98+
critical 'Root anchor did not match. Found "' + data[-1] + '" instead.'
11799
end
118-
# rubocop:enable Style/IfInsideElse
119100
end
120101
end

test/check-ssl-anchor_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
end
88

99
let(:check) do
10-
CheckSSLAnchor.new ['-h', 'philporada.com', '-a', 'i:\/?O ?= ?Digital Signature Trust Co.,? ?\/?CN ?= ?DST Root CA X3', '-r']
10+
CheckSSLAnchor.new ['-h', 'philporada.com', '-a', 'i:/O=Digital Signature Trust Co./CN=DST Root CA X3']
1111
end
1212

1313
it 'should pass check if the root anchor matches what the users -a flag' do
@@ -17,7 +17,6 @@
1717

1818
it 'should pass check if the root anchor matches what the users -a flag' do
1919
check.config[:anchor] = 'testdata'
20-
check.config[:regexp] = false
2120
expect(check).to receive(:critical).and_raise SystemExit
2221
expect { check.run }.to raise_error SystemExit
2322
end

0 commit comments

Comments
 (0)