[Bps-public-commit] rtir-extension-misp branch master updated. 0.02-3-g8123256

BPS Git Server git at git.bestpractical.com
Wed Nov 3 14:42:06 UTC 2021


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-extension-misp".

The branch, master has been updated
       via  8123256f17bd8a809d242f584a4274adf74e0e01 (commit)
      from  6985100712db02a7b5479072552daebcdb0d4666 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8123256f17bd8a809d242f584a4274adf74e0e01
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Nov 3 22:36:29 2021 +0800

    Apply MISP custom fields to all incident queues
    
    Previously we hardcoded to "Incidents", which could cause issues if
    admin renamed the default "Incidents" queue. Here we check Lifecycle
    instead to find all of them.

diff --git a/etc/initialdata b/etc/initialdata
index 6436407..0835852 100644
--- a/etc/initialdata
+++ b/etc/initialdata
@@ -5,20 +5,39 @@ our @CustomFields = (
     {   Name        => 'MISP Event ID',
         Type        => 'FreeformSingle',
         Disabled    => 0,
-        Queue       => 'Incidents',
+        Queue       => [],
         LinkValueTo => '__MISPURL__/events/view/__CustomField__',
     },
     {   Name        => 'MISP Event UUID',
         Type        => 'FreeformSingle',
         Disabled    => 0,
-        Queue       => 'Incidents',
+        Queue       => [],
         LinkValueTo => '__MISPURL__/events/view/__CustomField__',
     },
     {   Name        => 'MISP RTIR Object ID',
         Type        => 'FreeformSingle',
         Disabled    => 0,
-        Queue       => 'Incidents',
+        Queue       => [],
     },
 );
 
+our @Final = (
+    sub {
+        my $incidents = RT::Queues->new( RT->SystemUser );
+        $incidents->Limit( FIELD => 'Lifecycle', VALUE => 'incidents' );
+        my @incidents = @{ $incidents->ItemsArrayRef };
+
+        for my $field ( 'MISP Event ID', 'MISP Event UUID', 'MISP RTIR Object ID' ) {
+            my $cf = RT::CustomField->new( RT->SystemUser );
+            $cf->LoadByName( Name => $field, LookupType => RT::Ticket->CustomFieldLookupType );
+            for my $incident (@incidents) {
+                my ( $ret, $msg ) = $cf->AddToObject($incident);
+                if ( !$ret ) {
+                    RT->Logger->error( "Couldn't apply $field to incident queue #" . $incident->Id . ": $msg" );
+                }
+            }
+        }
+    }
+);
+
 1;
-----------------------------------------------------------------------

Summary of changes:
 etc/initialdata | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
rtir-extension-misp


More information about the Bps-public-commit mailing list