[Rt-commit] rtir branch, master, updated. 4.0.1rc1-232-gaf575227
? sunnavy
sunnavy at bestpractical.com
Tue Jun 16 09:56:23 EDT 2020
The branch, master has been updated
via af575227f582bed32742cfb1cd888fb371df7083 (commit)
via bb0c93a06100d64adfed331eb2b8898ed2327451 (commit)
from 4bae87f5fb526b94267b3c327cb93b9ab00bd3f7 (commit)
Summary of changes:
html/RTIR/Tools/Elements/GetEmailFromIP | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
- Log -----------------------------------------------------------------
commit bb0c93a06100d64adfed331eb2b8898ed2327451
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Jun 15 17:34:53 2020 -0400
Catch parse failures from Net::Whois::Object
Following the update of Net::Whois::RIPE in 1ffa0fb951,
creating a new object can error. The module dies, so
as a first step in handling these errors, add an eval
to catch the failure and provide a message to the user.
diff --git a/html/RTIR/Tools/Elements/GetEmailFromIP b/html/RTIR/Tools/Elements/GetEmailFromIP
index 0d768be7..f6ea3b96 100644
--- a/html/RTIR/Tools/Elements/GetEmailFromIP
+++ b/html/RTIR/Tools/Elements/GetEmailFromIP
@@ -62,16 +62,29 @@ unless ( $iterator ) {
$field ||= 'notify';
-my @objects = Net::Whois::Object->new($iterator);
+# Trap possible failures when parsing results
+# Net::Whois currently dies in some cases, so we need to eval
+my @objects;
+eval {
+ @objects = Net::Whois::Object->new($iterator);
+};
+
my @res;
-foreach my $obj (@objects) {
- foreach my $attr ( grep lc $_ eq lc $field, $obj->attributes ) {
- push @res, $obj->$attr();
- }
+if ( $@ ) {
+ RT->Logger->warn('Unable to parse WHOIS results for query ' . $q);
+ RT->Logger->debug($@);
+ $$error = loc('Unable to parse results from WHOIS lookup');
}
-unless ( @res ) {
- $$error = loc("Whois server response did not include field '[_1]'", $field);
- return;
+else {
+ foreach my $obj (@objects) {
+ foreach my $attr ( grep lc $_ eq lc $field, $obj->attributes ) {
+ push @res, $obj->$attr();
+ }
+ }
+ unless ( @res ) {
+ $$error = loc("Whois server response did not include field '[_1]'", $field);
+ return;
+ }
}
($$address) = grep defined && length, @res;
commit af575227f582bed32742cfb1cd888fb371df7083
Merge: 4bae87f5 bb0c93a0
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jun 16 21:35:42 2020 +0800
Merge branch '5.0/trap-whois-errors'
-----------------------------------------------------------------------
More information about the rt-commit
mailing list