[Rt-commit] rtir branch 4.0/improve-find-ip-logic created. 4.0.3-3-g76408cb5

BPS Git Server git at git.bestpractical.com
Wed Jan 11 19:04:17 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".

The branch, 4.0/improve-find-ip-logic has been created
        at  76408cb5b07c34f0f096bc2736766739ce277686 (commit)

- Log -----------------------------------------------------------------
commit 76408cb5b07c34f0f096bc2736766739ce277686
Author: Brad Embree <brad at bestpractical.com>
Date:   Wed Jan 11 10:59:09 2023 -0800

    Improve IPv4 with CIDR Regex
    
    Ensure that the IPv4 with CIDR Regex does not match 0.0.0.0/0

diff --git a/lib/RT/Action/RTIR_FindIP.pm b/lib/RT/Action/RTIR_FindIP.pm
index 11a9afab..06306899 100644
--- a/lib/RT/Action/RTIR_FindIP.pm
+++ b/lib/RT/Action/RTIR_FindIP.pm
@@ -61,6 +61,7 @@ my $IPv4_prefix_check_re = qr{(?<![0-9.])};
 my $IPv4_suffix_check_re = qr{(?!\.?[0-9])};
 my $IPv4_CIDR_re = qr{
     $IPv4_prefix_check_re
+    (?!0\.0\.0\.0)
     $RE{net}{CIDR}{IPv4}{-keep}
     $IPv4_suffix_check_re
 }x;

commit b79eadfcf7e7ecc0662ac9698358fe54749863d9
Author: Brad Embree <brad at bestpractical.com>
Date:   Wed Jan 11 10:53:28 2023 -0800

    Add tests for 0.0.0.0 and 0.0.0.0/0
    
    Add tests to ensure that 0.0.0.0 and 0.0.0.0/0 are not added as IPs when
    creating a ticket.

diff --git a/t/custom-fields/ip.t b/t/custom-fields/ip.t
index feea2125..e591ebb5 100644
--- a/t/custom-fields/ip.t
+++ b/t/custom-fields/ip.t
@@ -296,6 +296,22 @@ diag "check that we parse correct IPs only" if $ENV{'TEST_VERBOSE'};
     $ticket->Load( $id );
     is($ticket->id, $id, 'loaded ticket');
     is($ticket->CustomFieldValues('IP')->Count, 0, "IP wasn't added");
+
+    $id = $agent->create_ir( { Subject => "test ip", Content => '0.0.0.0' } );
+    ok($id, "created a ticket");
+
+    $ticket = RT::Ticket->new( $RT::SystemUser );
+    $ticket->Load( $id );
+    is($ticket->id, $id, 'loaded ticket');
+    is($ticket->CustomFieldValues('IP')->Count, 0, "IP wasn't added");
+
+    $id = $agent->create_ir( { Subject => "test ip", Content => '0.0.0.0/0' } );
+    ok($id, "created a ticket");
+
+    $ticket = RT::Ticket->new( $RT::SystemUser );
+    $ticket->Load( $id );
+    is($ticket->id, $id, 'loaded ticket');
+    is($ticket->CustomFieldValues('IP')->Count, 0, "IP wasn't added");
 }
 
 diag "check that IPs in messages don't add duplicates" if $ENV{'TEST_VERBOSE'};

-----------------------------------------------------------------------


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list