<?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 How do I use Secret storage and api call? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642366#M11039</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I developed an &lt;STRONG&gt;external lookup&lt;/STRONG&gt; script in Python which makes an https API call using a password authentication. The lookup script read the password from a custom conf file.&lt;/P&gt;
&lt;P&gt;When I submitted my app to Splunkbase the result was:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; check_for_secret_disclosure

    Password is being stored in plain text. Client's secret must be stored in encrypted format. You can use this reference for manage secret storage
    https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/
    File: appserver/static/javascript/views/app.js Line: 95&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no problem to write the password in passwords.conf. I followed the example in &lt;A href="https://github.com/splunk/splunk-app-examples/tree/master/setup_pages/weather_app_example" target="_blank" rel="noopener"&gt;Weather App Example&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The problem starts when I need to &lt;STRONG&gt;read &lt;/STRONG&gt;the password from the Python external lookup script. Splunk &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/secretstoragepython" target="_blank" rel="noopener"&gt;general documentation&lt;/A&gt; suggests to use a &lt;A href="https://haydz.github.io/2021/01/02/Python-Connect-Splunk.html" target="_blank" rel="noopener"&gt;client.connect&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Client.connect&lt;/EM&gt; need a Splunk user authentication, so another secret! I can find a method to read the secret as the &lt;EM&gt;&lt;SPAN class=""&gt;splunklib&lt;/SPAN&gt;.&lt;SPAN class=""&gt;searchcommands&lt;/SPAN&gt;&lt;/EM&gt; allows, for example.&lt;/P&gt;
&lt;P&gt;I have Splunk Enterprise, so I could leave the API password clear, but I would like to use the &lt;EM&gt;secretstorage&lt;/EM&gt; as suggested.&lt;/P&gt;
&lt;P&gt;How can I fix this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Marco&lt;/P&gt;</description>
    <pubDate>Wed, 10 May 2023 14:47:13 GMT</pubDate>
    <dc:creator>sistemistiposta</dc:creator>
    <dc:date>2023-05-10T14:47:13Z</dc:date>
    <item>
      <title>How do I use Secret storage and api call?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642366#M11039</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I developed an &lt;STRONG&gt;external lookup&lt;/STRONG&gt; script in Python which makes an https API call using a password authentication. The lookup script read the password from a custom conf file.&lt;/P&gt;
&lt;P&gt;When I submitted my app to Splunkbase the result was:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; check_for_secret_disclosure

    Password is being stored in plain text. Client's secret must be stored in encrypted format. You can use this reference for manage secret storage
    https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/
    File: appserver/static/javascript/views/app.js Line: 95&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is no problem to write the password in passwords.conf. I followed the example in &lt;A href="https://github.com/splunk/splunk-app-examples/tree/master/setup_pages/weather_app_example" target="_blank" rel="noopener"&gt;Weather App Example&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The problem starts when I need to &lt;STRONG&gt;read &lt;/STRONG&gt;the password from the Python external lookup script. Splunk &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/secretstoragepython" target="_blank" rel="noopener"&gt;general documentation&lt;/A&gt; suggests to use a &lt;A href="https://haydz.github.io/2021/01/02/Python-Connect-Splunk.html" target="_blank" rel="noopener"&gt;client.connect&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Client.connect&lt;/EM&gt; need a Splunk user authentication, so another secret! I can find a method to read the secret as the &lt;EM&gt;&lt;SPAN class=""&gt;splunklib&lt;/SPAN&gt;.&lt;SPAN class=""&gt;searchcommands&lt;/SPAN&gt;&lt;/EM&gt; allows, for example.&lt;/P&gt;
&lt;P&gt;I have Splunk Enterprise, so I could leave the API password clear, but I would like to use the &lt;EM&gt;secretstorage&lt;/EM&gt; as suggested.&lt;/P&gt;
&lt;P&gt;How can I fix this problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 14:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642366#M11039</guid>
      <dc:creator>sistemistiposta</dc:creator>
      <dc:date>2023-05-10T14:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Secret storage and api call</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642768#M11041</link>
      <description>&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;As per my understanding you are looking to access storage_passwords from within the App(ie. external lookup script) without requiring to use client.connect(), which is possible using the already available service instance to communicate with the Splunk Enterprise.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Ref - in&amp;nbsp;&lt;A href="https://github.com/splunk/splunk-app-examples/blob/master/setup_pages/weather_app_example/bin/weather.py#L31" target="_self"&gt;Weather App Example&lt;/A&gt;&amp;nbsp;, below code snippet is used to access the storage_passwords using the already available service instance&lt;/P&gt;&lt;LI-CODE lang="python"&gt;secrets = search_command.service.storage_passwords&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;Also check the &lt;A href="https://github.com/splunk/splunk-sdk-python#access-service-object-in-custom-search-command--modular-input-apps" target="_self"&gt;documentation&lt;/A&gt; on how to access the service instance within an App&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 06:35:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642768#M11041</guid>
      <dc:creator>abhis</dc:creator>
      <dc:date>2023-05-10T06:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Secret storage and api call</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642786#M11042</link>
      <description>&lt;P&gt;Hello Abhis,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I don't implement a search command. I have an external lookup like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    INPUT
    '''
    anamefield = sys.argv[1]
    aidfield = sys.argv[2]

    '''
    MAIN PROCESS
    '''
    infile = sys.stdin
    outfile = sys.stdout

    r = csv.DictReader(infile)
    header = r.fieldnames

    w = csv.DictWriter(outfile, fieldnames=r.fieldnames)
    w.writeheader()

    for result in r:
        # Perform the lookup or reverse lookup if necessary
        if result[anamefield] and result[aidfield]:
            # All fields were provided, just pass it along
            w.writerow(result)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand how can I read the &lt;EM&gt;session key&lt;/EM&gt; here. I read about &lt;STRONG&gt;splunk.Intersplunk&lt;/STRONG&gt;, but it seems deprecated. The &lt;STRONG&gt;service&lt;/STRONG&gt; instance seems to work only in command libraries or &lt;STRONG&gt;Script.stream_events&lt;/STRONG&gt; library, which I can't understand how to adopt in &lt;EM&gt;external lookup script&lt;/EM&gt;. I really appreciate if I could read some examples as weather app does for external commands.&lt;/P&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;P&gt;Kind Regards&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 10:42:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/How-do-I-use-Secret-storage-and-api-call/m-p/642786#M11042</guid>
      <dc:creator>sistemistiposta</dc:creator>
      <dc:date>2023-05-10T10:42:41Z</dc:date>
    </item>
  </channel>
</rss>

