<?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 Splunk Application cannot load script with Splunk Enterprise Security enabled in Splunk Enterprise Security</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711324#M12335</link>
    <description>&lt;P&gt;I maintain&amp;nbsp;&lt;A href="https://ipinfo.io" target="_self"&gt;IPinfo&lt;/A&gt;'s Splunk App:&amp;nbsp;&lt;A href="https://splunkbase.splunk.com/app/4070" target="_self"&gt;https://splunkbase.splunk.com/app/4070&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Our customers have recently reported that our application doesn't work when Splunk Enterprise Security is enabled.&lt;/P&gt;&lt;P&gt;For context, our application uses one of two modes to interact with our data:&lt;BR /&gt;1) queries our API directly&lt;BR /&gt;2) downloads our datasets locally using a public HTTPS endpoint&lt;/P&gt;&lt;P&gt;The failure only happens in the second mode, when we have to make REST calls to coordinate the download of our data.&lt;/P&gt;&lt;P&gt;One key finding in my early investigation is that our Splunk application communicates using raw non-SSL-verified HTTPS requests (i.e. using the &lt;FONT face="courier new,courier"&gt;requests&lt;/FONT&gt; Python library with &lt;FONT face="courier new,courier"&gt;verify=False&lt;/FONT&gt;), authenticated by session keys.&lt;/P&gt;&lt;P&gt;Splunk Entreprise Security seems to prevent these types of communication. To bypass this restriction, I converted everything over to the Splunk Python SDK, which bypasses all of these SSL issues.&lt;/P&gt;&lt;P&gt;I quickly realized that, to leverage the Splunk Python SDK in all scenarios and with consistency, it would just be easier to use bearer tokens throughout, so the second change I made was leveraging bearer tokens for REST communications.&lt;/P&gt;&lt;P&gt;Despite these two changes, the application still doesn't work with&amp;nbsp;Splunk Entreprise Security enabled. It works without a problem when it is disabled (for example, when testing in the Docker Splunk dev environment).&lt;/P&gt;&lt;P&gt;I've also tried to build a simple debug handler based on &lt;FONT face="courier new,courier"&gt;splunk.rest.BaseRestHandler&lt;/FONT&gt;. When I try to call it directly with&amp;nbsp;Splunk Entreprise Security enabled, I get the following error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR - HTTP 500 Error starting: Can't load script "/opt/splunk/etc/apps/ipinfo_app/bin/debug_endpoint.py" -- Error starting: Can't load script "/opt/splunk/etc/apps/ipinfo_app/bin/debug_endpoint.py" &lt;/LI-CODE&gt;&lt;P&gt;I haven't been able to track this particular error in Splunk forums or other forums on the Internet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has insight on this problem, I would appreciate any help. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2025 02:27:24 GMT</pubDate>
    <dc:creator>max-ipinfo</dc:creator>
    <dc:date>2025-02-12T02:27:24Z</dc:date>
    <item>
      <title>Splunk Application cannot load script with Splunk Enterprise Security enabled</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711324#M12335</link>
      <description>&lt;P&gt;I maintain&amp;nbsp;&lt;A href="https://ipinfo.io" target="_self"&gt;IPinfo&lt;/A&gt;'s Splunk App:&amp;nbsp;&lt;A href="https://splunkbase.splunk.com/app/4070" target="_self"&gt;https://splunkbase.splunk.com/app/4070&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Our customers have recently reported that our application doesn't work when Splunk Enterprise Security is enabled.&lt;/P&gt;&lt;P&gt;For context, our application uses one of two modes to interact with our data:&lt;BR /&gt;1) queries our API directly&lt;BR /&gt;2) downloads our datasets locally using a public HTTPS endpoint&lt;/P&gt;&lt;P&gt;The failure only happens in the second mode, when we have to make REST calls to coordinate the download of our data.&lt;/P&gt;&lt;P&gt;One key finding in my early investigation is that our Splunk application communicates using raw non-SSL-verified HTTPS requests (i.e. using the &lt;FONT face="courier new,courier"&gt;requests&lt;/FONT&gt; Python library with &lt;FONT face="courier new,courier"&gt;verify=False&lt;/FONT&gt;), authenticated by session keys.&lt;/P&gt;&lt;P&gt;Splunk Entreprise Security seems to prevent these types of communication. To bypass this restriction, I converted everything over to the Splunk Python SDK, which bypasses all of these SSL issues.&lt;/P&gt;&lt;P&gt;I quickly realized that, to leverage the Splunk Python SDK in all scenarios and with consistency, it would just be easier to use bearer tokens throughout, so the second change I made was leveraging bearer tokens for REST communications.&lt;/P&gt;&lt;P&gt;Despite these two changes, the application still doesn't work with&amp;nbsp;Splunk Entreprise Security enabled. It works without a problem when it is disabled (for example, when testing in the Docker Splunk dev environment).&lt;/P&gt;&lt;P&gt;I've also tried to build a simple debug handler based on &lt;FONT face="courier new,courier"&gt;splunk.rest.BaseRestHandler&lt;/FONT&gt;. When I try to call it directly with&amp;nbsp;Splunk Entreprise Security enabled, I get the following error:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ERROR - HTTP 500 Error starting: Can't load script "/opt/splunk/etc/apps/ipinfo_app/bin/debug_endpoint.py" -- Error starting: Can't load script "/opt/splunk/etc/apps/ipinfo_app/bin/debug_endpoint.py" &lt;/LI-CODE&gt;&lt;P&gt;I haven't been able to track this particular error in Splunk forums or other forums on the Internet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone has insight on this problem, I would appreciate any help. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 02:27:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711324#M12335</guid>
      <dc:creator>max-ipinfo</dc:creator>
      <dc:date>2025-02-12T02:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Application cannot load script with Splunk Enterprise Security enabled</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711331#M12336</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/276397"&gt;@max-ipinfo&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Were you able to find anything in $SPLUNK_HOME/var/log/splunkd.log relating to this file and the 500 error?&lt;/P&gt;&lt;P&gt;You could also try running&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$SPLUNK_HOME/bin/splunk cmd python3 /opt/splunk/etc/apps/ipinfo_app/bin/debug_endpoint.py&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;to check that the python file has no syntax errors - you might not get an output if it works, but you may well get an error if there is an issue..&lt;/P&gt;&lt;P&gt;Its also worth checking the ownership and permissions on this file on the filesystem.&lt;/P&gt;&lt;P&gt;If you still have no success feel free to share the python file contents and we can continue to debug with you.&lt;/P&gt;&lt;P&gt;Please let me know how you get on and consider accepting this answer or adding karma this answer if it has helped.&lt;BR /&gt;Regards&lt;/P&gt;&lt;P&gt;Will&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 06:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711331#M12336</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-02-12T06:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Application cannot load script with Splunk Enterprise Security enabled</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711396#M12342</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;&amp;nbsp;. I'll ask our customers to try out your suggestions and will report back.&lt;BR /&gt;&lt;BR /&gt;I really appreciate your help!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 17:07:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/711396#M12342</guid>
      <dc:creator>max-ipinfo</dc:creator>
      <dc:date>2025-02-12T17:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Application cannot load script with Splunk Enterprise Security enabled</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/712657#M12385</link>
      <description>&lt;P&gt;Sorry for the delay&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/170906"&gt;@livehybrid&lt;/a&gt;.&lt;/P&gt;&lt;P&gt;We just managed to get access to a customer's Splunk environment this week and it was very productive!&lt;BR /&gt;&lt;BR /&gt;Here are our findings:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;P class=""&gt;we validated that our Splunk app works with Splunk Enterprise Security, on a standalone node&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;we were able to recreate the bug in their clustering setup:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;P class=""&gt;we found out that not all of our Python scripts were executable, preventing execution in that context (&lt;FONT face="courier new,courier"&gt;Can't load script&lt;/FONT&gt; error)&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;the source of the download errors was finally root-caused: Splunk Enterprise Security hijacks the Python module path order. So when we were trying to import our application's &lt;FONT face="courier new,courier"&gt;bin/utils.py&lt;/FONT&gt; in our own code, it was trying to import &lt;FONT face="courier new,courier"&gt;/opt/splunk/etc/apps/SA-ThreatIntelligence/bin/utils.py&lt;/FONT&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;When we overrode &lt;FONT face="courier new,courier"&gt;sys.path&lt;/FONT&gt; in our script in the customer environment, the application worked again. The simplest work-around is to prefix all of our script files with &lt;FONT face="courier new,courier"&gt;ipinfo_&lt;/FONT&gt; to prevent module name collision.&lt;BR /&gt;&lt;BR /&gt;We still feel that the Python module path hijacking should not be happening. Not sure if this is a bug that Splunk Platform teams should fix. If I need to file a bug somewhere, let me know!&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P class=""&gt;we noticed that we don't have to assign a bearer token to the Splunk admin user for our REST API calls to work with the Python SDK. We can use another user (e.g. &lt;FONT face="courier new,courier"&gt;ipinfo_admin&lt;/FONT&gt;) with a restricted set of permissions. We are still trying to figure out what the smallest amount of permissions are required for things to work.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Next step is applying all of the fixes above and see if it resolves our customers' problems. I'll reach out in this thread if new issues pop up.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2025 00:31:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise-Security/Splunk-Application-cannot-load-script-with-Splunk-Enterprise/m-p/712657#M12385</guid>
      <dc:creator>max-ipinfo</dc:creator>
      <dc:date>2025-02-28T00:31:25Z</dc:date>
    </item>
  </channel>
</rss>

