splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
687 stars 369 forks source link

ValueError : StoragePasswords cannot have wildcards in namespace. #458

Closed lmnogues closed 2 years ago

lmnogues commented 2 years ago

Hi,

I know it's more likely a feature and not a bug. But I was wondering why is StoragePasswords is protected from access with wildcard apps or namespace, when the same action using rest is not protected ?

The first snippet will generate an error because app & owner are set to be wildcards

s = client.connect(username="<user>", password="<redacted>",host="<ip>",port="<port>",app="-",owner="-")

try:
    for pw in s.storage_passwords:
        print(pw.username)
except ValueError as ve:
    print(ve)

The following snippet will not generate an error with the wildcards :

req = requests.get(f"https://<host>:<port>/servicesNS/-/-/storage/passwords/", verify=False, headers={'Authorization': s.token},data={'output_mode':"json"})
req.raise_for_status()
for pw in req.json().get("entry"):
    print(pw.get("content").get("username"))

In our workflow with Splunk, we might not know where is stored the password so we need to be able to use wildcard on the app level of the namespace.

Is there any solution with splunklib or should we stick with our basic requests ?

ashah-splunk commented 2 years ago

Hi @Jalkar , thanks from bringing this to our knowledge. We are analysing on this and will be sharing an update soon.

ashah-splunk commented 2 years ago

@Jalkar we would request you to use the latest SDK release with the changes and let us know if it resolves the issue.