Closed DrMurx closed 6 years ago
@DrMurx thanks for the contribution! Let me know if you need any help getting through the CI issues.
Fixed.
I forgot to mention that this solves #67 (like #70 does too) and at least assures that the check doesn't crash, so it would partially solve #61 too.
@DrMurx thanks for fixing this up overall it looks good (as no one got to my review we will probably close that in favor of this one). Any chance I could get you to provide a testing artifact? It can be manual or automated just something that let's me know it fixes the issue. If manual it is best to include a before and after.
@majormoses Sure :)
Here's a manual check on a German TLD (the DeNIC doesn't report any expiration timestamps):
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ ./bin/check-whois-domain-expiration.rb -d google.de
Check failed to run: Whois::AttributeNotSupported, ["/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:130:in `_property_expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:393:in `handle_property'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:240:in `expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:348:in `delegate_property_to_parsers'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:312:in `expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:333:in `method_missing'", "./bin/check-whois-domain-expiration.rb:78:in `initialize'", "/usr/local/lib/ruby/gems/2.5.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in `new'", "/usr/local/lib/ruby/gems/2.5.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:57:in `block in <class:CLI>'"]
$ ./bin/check-whois-domain-expiration-multi.rb -d google.de
Check failed to run: Whois::AttributeNotSupported, ["/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:130:in `_property_expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:393:in `handle_property'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parsers/base.rb:240:in `expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:348:in `delegate_property_to_parsers'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:312:in `expires_on'", "/usr/local/lib/ruby/gems/2.5.0/gems/whois-parser-1.0.0/lib/whois/parser.rb:333:in `method_missing'", "./bin/check-whois-domain-expiration-multi.rb:96:in `block in expiration_results'", "./bin/check-whois-domain-expiration-multi.rb:86:in `each'", "./bin/check-whois-domain-expiration-multi.rb:86:in `expiration_results'", "./bin/check-whois-domain-expiration-multi.rb:113:in `run'", "/usr/local/lib/ruby/gems/2.5.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]
$ ./bin/check-jsonwhois-domain-expiration.rb -a xxxxxxx -d google.de
Check failed to run: no implicit conversion of nil into String, ["./bin/check-jsonwhois-domain-expiration.rb:112:in `parse'", "./bin/check-jsonwhois-domain-expiration.rb:112:in `get_domain_expiration'", "./bin/check-jsonwhois-domain-expiration.rb:86:in `block in expiration_results'", "./bin/check-jsonwhois-domain-expiration.rb:85:in `each'", "./bin/check-jsonwhois-domain-expiration.rb:85:in `expiration_results'", "./bin/check-jsonwhois-domain-expiration.rb:116:in `run'", "/usr/local/lib/ruby/gems/2.5.0/gems/sensu-plugin-1.4.5/lib/sensu-plugin/cli.rb:58:in `block in <class:CLI>'"]
$ git checkout rework_whois_checks
Switched to branch 'rework_whois_checks'
Your branch is up to date with 'origin/rework_whois_checks'.
$ ./bin/check-whois-domain-expiration.rb -d google.de
WhoisDomainExpirationCheck UNKNOWN: google.de can't be checked
$ ./bin/check-whois-domain-expiration-multi.rb -d google.de
WhoisDomainExpirationCheck UNKNOWN: google.de (Parsing error)
$ ./bin/check-jsonwhois-domain-expiration.rb -a xxxxxxx -d google.de
JSONWhoisDomainExpirationCheck UNKNOWN: google.de (Connection or parsing error)
And that's for the new flags I introduced to change the test's criticality in those cases:
$ ./bin/check-whois-domain-expiration-multi.rb -i -d google.de
WhoisDomainExpirationCheck OK: No domains expire in the near term
$ ./bin/check-whois-domain-expiration-multi.rb -r warning -d google.de
WhoisDomainExpirationCheck WARNING: google.de (Parsing error)
$ ./bin/check-whois-domain-expiration-multi.rb -r critical -d google.de
WhoisDomainExpirationCheck CRITICAL: google.de (Parsing error)
Thanks for that, I will get this released shortly.
As I just merged and released another PR I rebased on your behalf, as soon as CI passes again I will merge and release.
Pull Request Checklist
General
[x] Update Changelog following the conventions laid out on Keep A Changelog
[x] ~Update README with any necessary configuration snippets~
[x] ~Binstubs are created if needed~
[x] RuboCop passes (at least I didn't make it worse)
[x] ~Existing tests pass~
Purpose
Improved exception resilience and error reporting of the various
whois
checks. Also added options to either ignore errors, or report them as warning/critical.Known Compatibility Issues
The textual output of
check-whois-domain-expiration-multi.rb
andcheck-jsonwhois-domain-expiration.rb
has slightly changed