<?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: custom command secret in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707065#M11765</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/268899"&gt;@user487596&lt;/a&gt;,&amp;nbsp;how are you?&lt;BR /&gt;&lt;BR /&gt;You can use REST API endpoints, like this example using curl locally on your Splunk instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -k -u &amp;lt;username&amp;gt;:&amp;lt;password&amp;gt; \
	https://localhost:8089/servicesNS/nobody/&amp;lt;app&amp;gt;/storage/passwords \
	-d name=user1 -d realm=realm1 -d password=password1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your code, use a &lt;STRONG&gt;prepare&lt;/STRONG&gt; method to retrieve your key:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def prepare(self):
        global API_KEY

        for passwd in self.service.storage_passwords:
            if passwd.realm == "&amp;lt;you_realm_key&amp;gt;":
                API_KEY = passwd.clear_password

        if API_KEY is None or API_KEY == "defaults_empty":
            self.error_exit(None, "No API key found.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Documentation can be found&amp;nbsp;&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/secretstoragerest/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Dec 2024 17:35:49 GMT</pubDate>
    <dc:creator>luizlimapg</dc:creator>
    <dc:date>2024-12-17T17:35:49Z</dc:date>
    <item>
      <title>custom command secret</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707064#M11764</link>
      <description>&lt;P&gt;Hi folks! I want to create a custom&amp;nbsp;GeneratingCommand that makes a simple API request, but how do I save the API key in passwords.conf?&lt;/P&gt;&lt;P&gt;I have a default/setup.xml file with the following content:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;&amp;lt;setup&amp;gt;
  &amp;lt;block title="Add API key(s)" endpoint="storage/passwords" entity="_new"&amp;gt;
    &amp;lt;input field="password"&amp;gt;
      &amp;lt;label&amp;gt;API key&amp;lt;/label&amp;gt;
      &amp;lt;type&amp;gt;password&amp;lt;/type&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/block&amp;gt;
&amp;lt;/setup&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I configure the app, the password (API key) is not saved in the app folder (passwords.conf).&lt;BR /&gt;And if I need to add several api keys, how can I assign names to them and get information from the storage? I doubt this code will work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;try:
            app = "app-name"
            settings = json.loads(sys.stdin.read())
            config = settings['configuration']
            entities = entity.getEntities(['admin', 'passwords'], namespace=app, owner='nobody', sessionKey=settings['session_key'])
            i, c = entities.items()[0]
            api_key = c['clear_password']
            #user,  = c['username'], c['clear_password']
        except Exception as e:
            yield {"_time": time.time(), "_raw": str(e)}
            self.logger.fatal("ERROR Unexpected error: %s" % e)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 16:53:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707064#M11764</guid>
      <dc:creator>user487596</dc:creator>
      <dc:date>2024-12-17T16:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: custom command secret</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707065#M11765</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/268899"&gt;@user487596&lt;/a&gt;,&amp;nbsp;how are you?&lt;BR /&gt;&lt;BR /&gt;You can use REST API endpoints, like this example using curl locally on your Splunk instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -k -u &amp;lt;username&amp;gt;:&amp;lt;password&amp;gt; \
	https://localhost:8089/servicesNS/nobody/&amp;lt;app&amp;gt;/storage/passwords \
	-d name=user1 -d realm=realm1 -d password=password1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your code, use a &lt;STRONG&gt;prepare&lt;/STRONG&gt; method to retrieve your key:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;def prepare(self):
        global API_KEY

        for passwd in self.service.storage_passwords:
            if passwd.realm == "&amp;lt;you_realm_key&amp;gt;":
                API_KEY = passwd.clear_password

        if API_KEY is None or API_KEY == "defaults_empty":
            self.error_exit(None, "No API key found.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Documentation can be found&amp;nbsp;&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/manageknowledge/secretstorage/secretstoragerest/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 17:35:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707065#M11765</guid>
      <dc:creator>luizlimapg</dc:creator>
      <dc:date>2024-12-17T17:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: custom command secret</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707133#M11766</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/267805"&gt;@luizlimapg&lt;/a&gt;&amp;nbsp;, thanks for your reply. Is there any confirmation after curl or ways to check if password is added successfully, is there any other way to add a password?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Enter host password for user 'user':
curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that this is possible using the same curl, but i got an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -k -u user https://localhost:8089/servicesNS/nobody/app/storage/passwords/

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 10:02:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707133#M11766</guid>
      <dc:creator>user487596</dc:creator>
      <dc:date>2024-12-18T10:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: custom command secret</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707159#M11767</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/268899"&gt;@user487596&lt;/a&gt;,&amp;nbsp;an easier way to manipulate passwords is by using the Splunkbase app: &lt;A href="https://splunkbase.splunk.com/app/4013" target="_self"&gt;https://splunkbase.splunk.com/app/4013&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 14:24:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707159#M11767</guid>
      <dc:creator>luizlimapg</dc:creator>
      <dc:date>2024-12-18T14:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: custom command secret</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707199#M11769</link>
      <description>&lt;P&gt;Thanks, interesting app.&lt;/P&gt;&lt;P&gt;If anyone knows how to fix the curl issue or maybe use search for creation secrets, please share.&lt;/P&gt;&lt;P&gt;By the way, the function you suggest implementing doesn't work for me, I used the code from that function inside generate() and it works, at least I can extract the API key, but for some reason I can't make a request...&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 18:10:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/custom-command-secret/m-p/707199#M11769</guid>
      <dc:creator>user487596</dc:creator>
      <dc:date>2024-12-18T18:10:24Z</dc:date>
    </item>
  </channel>
</rss>

