Okay if anybody will be in the same spot as i am, i post the solution to my problem here, trusting that the community will correct and improve it. def getMailCredentials( sessionKey, namespace='<your_app_name>' 😞 splunkhome = os.environ.get('SPLUNK_HOME') if splunkhome == None: return None # [NOTE]: getting the password depends on your user permissions emailCredentialEntity = entity.getEntity( 'admin/alert_actions', 'email', namespace=namespace, owner='nobody', sessionKey=sessionKey ) if 'auth_username' in emailCredentialEntity and 'clear_password' in emailCredentialEntity: encrypted_password = emailCredentialEntity['clear_password'] # If SPLUNKHOME has white spaces in path splunkhome='\"' + splunkhome + '\"' # [NOTE]: following statements will decrypt the password using the CLI if sys.platform == "win32": encr_passwd_env = "\"set \"ENCRYPTED_PASSWORD=" + encrypted_password + "\" " commandparams = [ "cmd", "/C", encr_passwd_env, "&&", os.path.join( splunkhome, "bin", "splunk" ), "show-decrypted", "--value", "\"\"\"" ] else: encr_passwd_env = "ENCRYPTED_PASSWORD='" + encrypted_password + "'" commandparams = [ encr_passwd_env, os.path.join( splunkhome, "bin", "splunk" ), "show-decrypted", "--value", "''" ] command = ' '.join( commandparams ) stream = os.popen( command ) clear_password = stream.read() # [NOTE]: the decrypted password is appended with a '\n' if len( clear_password ) >= 1: clear_password = clear_password[:-1] credentials = { 'auth_username': emailCredentialEntity['auth_username'], 'clear_password': clear_password } return credentials else: return None It feels wrong. But it works for now.
... View more