<?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 SOAR access environment variables in Splunk SOAR</title>
    <link>https://community.splunk.com/t5/Splunk-SOAR/Splunk-SOAR-access-environment-variables/m-p/741231#M1693</link>
    <description>&lt;P&gt;We have a playbook which is making calls to SOAR REST API artifacts endpoint.&lt;BR /&gt;&lt;BR /&gt;We are having to pass the auth token for the REST API call in the script as plain text which isn't ideal.&lt;BR /&gt;&lt;BR /&gt;Given we haven't configured a vault/vault like solution (CA,Vault etc.) ,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1)We set a SOAR global environment variable and stored the value as a secret but how do we call this in our script?&lt;BR /&gt;&lt;BR /&gt;Have tried looking at all possible attributes in the phantom library - Documentation is next to none for this - I also tried os.environ.get but custom variables are not going to be present in it. I am able to access value of variables like NO_PROXY and it returns the respective value.&lt;BR /&gt;&lt;BR /&gt;Any ideas around this will help.&lt;BR /&gt;&lt;BR /&gt;2)I am also trying to get the base URL for constructing the REST call&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Using build_phantom_rest_url or get_base_url is&amp;nbsp; returning the URL as local address 127.0.0.1 and not our specific URL.&lt;BR /&gt;&lt;BR /&gt;In short, trying to access the values in the image within our custom function and haven't found a solution&lt;BR /&gt;&lt;BR /&gt;Making a REST API call requires auth and that option is ruled out for getting the API token.&lt;BR /&gt;&lt;BR /&gt;Any inputs will help. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_SOAR.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/38056iFE0E35E2EAB27FFE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_SOAR.png" alt="Splunk_SOAR.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 09 Mar 2025 12:55:54 GMT</pubDate>
    <dc:creator>JustntherSplker</dc:creator>
    <dc:date>2025-03-09T12:55:54Z</dc:date>
    <item>
      <title>Splunk SOAR access environment variables</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Splunk-SOAR-access-environment-variables/m-p/741231#M1693</link>
      <description>&lt;P&gt;We have a playbook which is making calls to SOAR REST API artifacts endpoint.&lt;BR /&gt;&lt;BR /&gt;We are having to pass the auth token for the REST API call in the script as plain text which isn't ideal.&lt;BR /&gt;&lt;BR /&gt;Given we haven't configured a vault/vault like solution (CA,Vault etc.) ,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1)We set a SOAR global environment variable and stored the value as a secret but how do we call this in our script?&lt;BR /&gt;&lt;BR /&gt;Have tried looking at all possible attributes in the phantom library - Documentation is next to none for this - I also tried os.environ.get but custom variables are not going to be present in it. I am able to access value of variables like NO_PROXY and it returns the respective value.&lt;BR /&gt;&lt;BR /&gt;Any ideas around this will help.&lt;BR /&gt;&lt;BR /&gt;2)I am also trying to get the base URL for constructing the REST call&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Using build_phantom_rest_url or get_base_url is&amp;nbsp; returning the URL as local address 127.0.0.1 and not our specific URL.&lt;BR /&gt;&lt;BR /&gt;In short, trying to access the values in the image within our custom function and haven't found a solution&lt;BR /&gt;&lt;BR /&gt;Making a REST API call requires auth and that option is ruled out for getting the API token.&lt;BR /&gt;&lt;BR /&gt;Any inputs will help. Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Splunk_SOAR.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/38056iFE0E35E2EAB27FFE/image-size/large?v=v2&amp;amp;px=999" role="button" title="Splunk_SOAR.png" alt="Splunk_SOAR.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Mar 2025 12:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Splunk-SOAR-access-environment-variables/m-p/741231#M1693</guid>
      <dc:creator>JustntherSplker</dc:creator>
      <dc:date>2025-03-09T12:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk SOAR access environment variables</title>
      <link>https://community.splunk.com/t5/Splunk-SOAR/Splunk-SOAR-access-environment-variables/m-p/742163#M1696</link>
      <description>&lt;P&gt;We worked with Splunk support to solve this. Recording the response since others might find it useful&lt;BR /&gt;&lt;BR /&gt;1)phantom.get_base_url() helps access the URL set in the above screenshot (Base URL for Splunk SOAR) - Previous attempts did not work which is bizarre&lt;BR /&gt;&lt;BR /&gt;2)Accessing environment variables&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; import os&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; import django&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; import sys&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp; os.environ.setdefault("DJANGO_SETTINGS_MODULE", "phantom_ui.settings")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; django.setup()&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; from phantom_ui.ui.models import SystemSettings&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; s = SystemSettings.get_settings()&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; envVars = s.environment_variables&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; phantom.debug(envVars)&lt;BR /&gt;&lt;BR /&gt;If your variable is called abc, you can now access its value in a variable by&lt;BR /&gt;&lt;BR /&gt;abcvalue = envVars['abc']['value']&lt;BR /&gt;&lt;BR /&gt;3) If your environment variable is stored as a secret , step 2 returns a salted variable which is no good for the authentication. Use the below to decrypt it before usage.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;import&amp;nbsp;encryption_helper&lt;/P&gt;&lt;P&gt;clear_text_password = encryption_helper.decrypt(abcvalue, 'Splunk&amp;gt;Phantom')&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;By using 2 and 3, you can programmatically access environment variables including secret tokens and avoid specifying plaintext auth creds in your code block / custom functions!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 07:01:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-SOAR/Splunk-SOAR-access-environment-variables/m-p/742163#M1696</guid>
      <dc:creator>JustntherSplker</dc:creator>
      <dc:date>2025-03-19T07:01:14Z</dc:date>
    </item>
  </channel>
</rss>

