[Bps-public-commit] rtir-extension-misp branch ajax-details-widget created. 674055616c77d439f4a49c9b3b297c3c3d1faad8

BPS Git Server git at git.bestpractical.com
Mon Oct 25 19:47:33 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, ajax-details-widget has been created
        at  674055616c77d439f4a49c9b3b297c3c3d1faad8 (commit)

- Log -----------------------------------------------------------------
commit 674055616c77d439f4a49c9b3b297c3c3d1faad8
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 26 03:18:59 2021 +0800

    Ajaxify MISP widget to speed up main page load

diff --git a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd b/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
index 9589372..675ea81 100644
--- a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
+++ b/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
@@ -1,42 +1,16 @@
-<&| /Widgets/TitleBox,
-        title      => loc("MISP Event Details"),
-        title_href => $event_link,
-        class      => 'ticket-info-misp',
-&>
+<div class="ticket-info-misp"><&|/l&>Loading...</&></div>
+
+<script type="text/javascript">
+jQuery( function() {
+    jQuery('.ticket-info-misp').load(RT.Config.WebPath + '/Helpers/MISPEventDetails?EventID=<% $event_id %> .titlebox');
+});
+</script>
 
-% for my $field ( sort keys %info ) {
-<div class="form-row">
-  <div class="col-3 label"><% loc($field) %></div>
-  <div class="col-9 value">
-    <span class="current-value">
-      <% $info{$field} // '' %>
-    </span>
-  </div>
-</div>
-% }
-</&>
 <%init>
 my $event_id = $Ticket->FirstCustomFieldValue('MISP Event ID');
 return unless $event_id;
-
-my $event_link = RTIR::Extension::MISP::GetMISPBaseURL() . "/events/view/$event_id";
-my $misp_json = RTIR::Extension::MISP::FetchEventDetails($event_id);
-
-my %info;
-my %threat_map = ( 1 => 'High', 2 => 'Medium', 3 => 'Low', 4 => 'Undefined' );
-$info{'Threat Level'} = $threat_map{ $misp_json->{Event}{threat_level_id} };
-
-my %analysis_map = ( 0 => 'Initial', 1 => 'Ongoing', 3 => 'Completed' );
-$info{'Analysis'} = $analysis_map{ $misp_json->{Event}{analysis} };
-
-$info{'Creator org'} = $misp_json->{Event}{Orgc}{name};
-$info{'Owner org'} = $misp_json->{Event}{Org}{name};
-$info{'Date'} = $misp_json->{Event}{date};
-$info{'Published'} = $misp_json->{Event}{published} ? 'Yes' : 'No';
-
-my $object_count = scalar @{$misp_json->{Event}{Object}};
-$info{'#Attribute'} = "$misp_json->{Event}{attribute_count}, ($object_count Objects)";
 </%init>
+
 <%args>
 $Ticket
 </%args>
diff --git a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd b/html/Helpers/MISPEventDetails
similarity index 86%
copy from html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
copy to html/Helpers/MISPEventDetails
index 9589372..fdba7ec 100644
--- a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
+++ b/html/Helpers/MISPEventDetails
@@ -15,12 +15,11 @@
 </div>
 % }
 </&>
-<%init>
-my $event_id = $Ticket->FirstCustomFieldValue('MISP Event ID');
-return unless $event_id;
 
-my $event_link = RTIR::Extension::MISP::GetMISPBaseURL() . "/events/view/$event_id";
-my $misp_json = RTIR::Extension::MISP::FetchEventDetails($event_id);
+% $m->abort();
+<%init>
+my $event_link = RTIR::Extension::MISP::GetMISPBaseURL() . "/events/view/$EventID";
+my $misp_json = RTIR::Extension::MISP::FetchEventDetails($EventID);
 
 my %info;
 my %threat_map = ( 1 => 'High', 2 => 'Medium', 3 => 'Low', 4 => 'Undefined' );
@@ -37,6 +36,7 @@ $info{'Published'} = $misp_json->{Event}{published} ? 'Yes' : 'No';
 my $object_count = scalar @{$misp_json->{Event}{Object}};
 $info{'#Attribute'} = "$misp_json->{Event}{attribute_count}, ($object_count Objects)";
 </%init>
+
 <%args>
-$Ticket
+$EventID
 </%args>
commit 800c0d6fc5dd0fbc4c6e07b431cebd31f04b4c72
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Oct 26 03:23:09 2021 +0800

    Use specific color for misp widget

diff --git a/META.yml b/META.yml
index fde7ce2..4e75968 100644
--- a/META.yml
+++ b/META.yml
@@ -19,6 +19,7 @@ no_index:
     - etc
     - html
     - inc
+    - static
 requires:
   UUID::Tiny: 0
   perl: 5.10.1
diff --git a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd b/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
index 9680520..9589372 100644
--- a/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
+++ b/html/Callbacks/RTIR-Extension-MISP/RTIR/Incident/Display.html/RightColumnEnd
@@ -1,7 +1,7 @@
 <&| /Widgets/TitleBox,
         title      => loc("MISP Event Details"),
         title_href => $event_link,
-        class      => 'ticket-info-cfs',
+        class      => 'ticket-info-misp',
 &>
 
 % for my $field ( sort keys %info ) {
diff --git a/lib/RTIR/Extension/MISP.pm b/lib/RTIR/Extension/MISP.pm
index cc621b5..dc7db4f 100644
--- a/lib/RTIR/Extension/MISP.pm
+++ b/lib/RTIR/Extension/MISP.pm
@@ -8,6 +8,8 @@ use UUID::Tiny ':std';
 
 our $VERSION = '0.01';
 
+RT->AddStyleSheets('rtir-extension-misp.css');
+
 =head1 NAME
 
 RTIR-Extension-MISP - Integrate RTIR with MISP
diff --git a/static/css/rtir-extension-misp.css b/static/css/rtir-extension-misp.css
new file mode 100644
index 0000000..c4af34e
--- /dev/null
+++ b/static/css/rtir-extension-misp.css
@@ -0,0 +1 @@
+body.rtir .titlebox.ticket-info-misp { border-top: 3px solid #37c0fb; } /* The color is from https://www.misp-project.org/ */
-----------------------------------------------------------------------


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


More information about the Bps-public-commit mailing list