[Rt-commit] rtir branch, 4.0/parse-attachments-for-ip, created. 4.0.1rc1-88-g1cd6ea10
Craig Kaiser
craig at bestpractical.com
Mon Nov 19 17:06:04 EST 2018
The branch, 4.0/parse-attachments-for-ip has been created
at 1cd6ea107f796e85275f59248e80a4b8a1324008 (commit)
- Log -----------------------------------------------------------------
commit c0c89fdd6d8b85f31605eb64dfdfabcfaf0ef8ed
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Nov 8 09:25:10 2018 -0500
Add callbacks to CreateInRTIRQueueModal
diff --git a/html/RTIR/Elements/CreateInRTIRQueueModal b/html/RTIR/Elements/CreateInRTIRQueueModal
index f0e643a0..51dde11e 100644
--- a/html/RTIR/Elements/CreateInRTIRQueueModal
+++ b/html/RTIR/Elements/CreateInRTIRQueueModal
@@ -46,6 +46,9 @@
%#
%# END BPS TAGGED BLOCK }}}
<form action="<% RT::IR->HREFTo('Create.html') %>" id="CreateInQueue">
+% $m->callback( CallbackName => 'FormStart', Lifecycle => $Lifecycle, LinkedConstituency => $linked_constituency,
+% LinkedTicket => $linked_ticket, Incident => $Incident, ARGSRef => \%ARGS );
+
% if ($Incident) {
<input type="hidden" name="Incident" value="<%$Incident%>"/>
% }
@@ -62,6 +65,9 @@
&>Create a new [_1] in the queue [_2]</&>
<& /Elements/Submit, Label => loc("Go"), Caption => loc("This will take you to a partially prefilled [_1] creation form.", $ticket_type) &>
+
+% $m->callback( CallbackName => 'FormEnd', Lifecycle => $Lifecycle, LinkedConstituency => $linked_constituency,
+% LinkedTicket => $linked_ticket, Incident => $Incident, ARGSRef => \%ARGS );
</form>
<%INIT>
$Lifecycle = $Lifecycle->[0] if (ref $Lifecycle eq 'ARRAY');
commit 1cd6ea107f796e85275f59248e80a4b8a1324008
Author: Craig Kaiser <craig at bestpractical.com>
Date: Mon Nov 19 17:03:56 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