<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Render base64 image in dashboard in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430826#M41273</link>
    <description>&lt;P&gt;Yea. I'm wondering more for myself/an "in theory" question. Thanks for following up!&lt;/P&gt;</description>
    <pubDate>Fri, 28 Dec 2018 03:15:33 GMT</pubDate>
    <dc:creator>jgf5013</dc:creator>
    <dc:date>2018-12-28T03:15:33Z</dc:date>
    <item>
      <title>Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430821#M41268</link>
      <description>&lt;P&gt;There's an active directory attribute that holds a base64 encoded thumbnail of users. We have this data in Splunk already through LDAP lookups, it would be great if I could integrate this into a dashboard, but I'm having problems rendering an image in a dashboard.&lt;/P&gt;

&lt;P&gt;This code works when it's just loaded as an html document in my browser, but it's not rendering the image in a Splunk dashboard. Has anyone else had any luck with this? I've not got much experience with xml or html, am I missing something here? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;dashboard&amp;gt;
  &amp;lt;label&amp;gt;&amp;lt;/label&amp;gt;
  &amp;lt;description&amp;gt;&amp;lt;/description&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;      
      &amp;lt;h1&amp;gt;test&amp;lt;/h1&amp;gt;    
      &amp;lt;img src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="/&amp;gt;
      &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jul 2018 12:50:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430821#M41268</guid>
      <dc:creator>jallen02</dc:creator>
      <dc:date>2018-07-10T12:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430822#M41269</link>
      <description>&lt;P&gt;I recently wanted to render base64 images dynamically in a dashboard, and got this to work...&lt;/P&gt;

&lt;P&gt;1) Create Javascript file "dynamicImage.js" that monitors value changes of token "tokBASE64", then injects value into src attribute of img tag "imgDynamic".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery',
    'splunkjs/mvc',
    'splunkjs/mvc/simplexml/ready!'
 ], function ($, mvc,) {
         var submittedTokens = mvc.Components.get('submitted');
         submittedTokens.on("change:tokBASE64", function(model, tokBASE64, options) {
            var tokHTMLJS=submittedTokens.get("tokBASE64");
            if(tokHTMLJS!==undefined) {
              document.getElementById("imgDynamic").src = "data:image/jpeg;base64," + tokHTMLJS;
            }
         });
});
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;2) Place dynamicImage.js in your Splunk Searchhead&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$SPLUNK_HOME/etc/apps/&amp;lt;your app&amp;gt;/appserver/static
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;3) Restart Searchhead so the new static content will be picked up.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;In your XML dashboard source:&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;4) Reference the JS in the initial form/dashboard tag&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="dynamicImage.js"&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;5) Assign base64 content to tokBASE64 when search is completed. I used Fields to suppress displaying base64 in table.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;index=peoples personID=12345 | table personID, Firstname, Lastname, PhotoBase64&amp;lt;/query&amp;gt;
        &amp;lt;finalized&amp;gt;
            &amp;lt;set token="tokBASE64"&amp;gt;$result.PhotoBase64$&amp;lt;/set&amp;gt;
        &amp;lt;/finalized&amp;gt;
        &amp;lt;fields&amp;gt;["personID","Firstname","Lastname"]&amp;lt;/fields&amp;gt;
&amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;6) Add a HTML panel in your XML dashboard source, consisting of img tag&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
         &amp;lt;div&amp;gt;
           &amp;lt;img id="imgDynamic" src=""/&amp;gt;
         &amp;lt;/div&amp;gt;
       &amp;lt;/html&amp;gt;
&amp;lt;/panel&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Done !&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 04:40:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430822#M41269</guid>
      <dc:creator>bradensmith</dc:creator>
      <dc:date>2018-12-04T04:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430823#M41270</link>
      <description>&lt;P&gt;Perfect! Exactly what I needed, I hadn't thought of doing it through javascript but it looks like if it's hardcoded like I was trying originally the value gets removed when the page is being loaded.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 16:35:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430823#M41270</guid>
      <dc:creator>jallen02</dc:creator>
      <dc:date>2018-12-04T16:35:19Z</dc:date>
    </item>
    <item>
      <title>Re: Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430824#M41271</link>
      <description>&lt;P&gt;If the base64 string comes from an untrusted source (user logs,) couldn't this be exploited as a xss attack by adding in encoded js to the bytestring?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Dec 2018 14:28:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430824#M41271</guid>
      <dc:creator>jgf5013</dc:creator>
      <dc:date>2018-12-22T14:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430825#M41272</link>
      <description>&lt;P&gt;Fair point, but in this case the logs are based on LDAP queries that are run from a scripted input. I suppose an Active Directory administrator could change the value on a user's thumbnail attribute, but anyone who's administering AD could easily cause a lot more damage in other ways. The same goes for a Splunk administrator who could change the scripted input or add custom data to this index.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Dec 2018 09:49:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430825#M41272</guid>
      <dc:creator>jallen02</dc:creator>
      <dc:date>2018-12-27T09:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Render base64 image in dashboard</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430826#M41273</link>
      <description>&lt;P&gt;Yea. I'm wondering more for myself/an "in theory" question. Thanks for following up!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Dec 2018 03:15:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Render-base64-image-in-dashboard/m-p/430826#M41273</guid>
      <dc:creator>jgf5013</dc:creator>
      <dc:date>2018-12-28T03:15:33Z</dc:date>
    </item>
  </channel>
</rss>

