[Rt-commit] rtir branch, 4.0/parse-attachments-for-ip, created. 4.0.1rc1-87-g8c39d2af
Craig Kaiser
craig at bestpractical.com
Mon Nov 19 17:13:04 EST 2018
The branch, 4.0/parse-attachments-for-ip has been created
at 8c39d2af35399cf0c6862fc5b87111934f83348b (commit)
- Log -----------------------------------------------------------------
commit 8c39d2af35399cf0c6862fc5b87111934f83348b
Author: Craig Kaiser <craig at bestpractical.com>
Date: Mon Nov 19 17:11:42 2018 -0500
Use attachments instead of transactions for IP parse
You cannot grab the attached files domains and the content of the email's
domains unless you check attachments in place of the transations content.
If both an attachment and email content are present with IP values then
only the email content's IP addresses will be parsed.
diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index 6d2be824..554c4b79 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -99,8 +99,8 @@ sub Commit {
my $how_many_can = $cf->MaxValues;
- my $attach = $self->TransactionObj->ContentObj;
- return 1 unless $attach && $attach->id;
+ my $attachments = $ticket->Attachments;
+ return 1 unless $attachments && $attachments->Count;
my %existing;
for( @{$cf->ValuesForObject( $ticket )->ItemsArrayRef} ) {
@@ -114,33 +114,35 @@ sub Commit {
my $spots_left = $how_many_can - keys %existing;
- my $content = $attach->Content || '';
- while ( $content =~ m/$IP_re/go ) {
- if ( $1 && defined $2 ) { # IPv6/mask
- my $range = $2 == 128 ? $1 : (Net::CIDR::cidr2range( "$1/$2" ))[0]
- or next;
- $spots_left -= $self->AddIP(
- IP => $range, CustomField => $cf, Skip => \%existing
- );
+ while ( my $attach = $attachments->Next ) {
+ my $content = $attach->Content || '';
+ while ( $content =~ m/$IP_re/go ) {
+ if ( $1 && defined $2 ) { # IPv6/mask
+ my $range = $2 == 128 ? $1 : (Net::CIDR::cidr2range( "$1/$2" ))[0]
+ or next;
+ $spots_left -= $self->AddIP(
+ IP => $range, CustomField => $cf, Skip => \%existing
+ );
+ }
+ elsif ( $1 ) { # IPv6
+ $spots_left -= $self->AddIP(
+ IP => $1, CustomField => $cf, Skip => \%existing
+ );
+ }
+ elsif ( $3 ) { # IPv4
+ $spots_left -= $self->AddIP(
+ IP => $3, CustomField => $cf, Skip => \%existing
+ );
+ }
+ elsif ( $4 && defined $5 ) { # IPv4/mask
+ my $cidr = join( '.', map { $_||0 } (split /\./, $4)[0..3] ) ."/$5";
+ my $range = (Net::CIDR::cidr2range( $cidr ))[0] or next;
+ $spots_left -= $self->AddIP(
+ IP => $range, CustomField => $cf, Skip => \%existing
+ );
+ }
+ return 1 unless $spots_left;
}
- elsif ( $1 ) { # IPv6
- $spots_left -= $self->AddIP(
- IP => $1, CustomField => $cf, Skip => \%existing
- );
- }
- elsif ( $3 ) { # IPv4
- $spots_left -= $self->AddIP(
- IP => $3, CustomField => $cf, Skip => \%existing
- );
- }
- elsif ( $4 && defined $5 ) { # IPv4/mask
- my $cidr = join( '.', map { $_||0 } (split /\./, $4)[0..3] ) ."/$5";
- my $range = (Net::CIDR::cidr2range( $cidr ))[0] or next;
- $spots_left -= $self->AddIP(
- IP => $range, CustomField => $cf, Skip => \%existing
- );
- }
- return 1 unless $spots_left;
}
return 1;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list