Skip to content

Commit f8e6937

Browse files
committed
password: syntax did not work if using a dynamic/REST based restore, now supported
1 parent dc8ad59 commit f8e6937

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ To do this you will need to install Version Control For SplunkCloud on your Splu
260260
[SplunkVersionControlCloud github](https://github.com/gjanders/SplunkVersionControlCloud)
261261

262262
## Release Notes
263+
### 1.1.3
264+
password: syntax did not work if using a dynamic/REST based restore, now supported
265+
263266
### 1.1.2
264267
Found a bug that stops this running on Splunk 8 / python 3
265268

SplunkVersionControl.tgz

182 Bytes
Binary file not shown.

bin/splunkversioncontrol_rest_restore.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "bin"))
1919
from splunkversioncontrol_restore_class import SplunkVersionControlRestore
20+
from splunkversioncontrol_utility import get_password
2021

2122
splunkLogsDir = os.environ['SPLUNK_HOME'] + "/var/log/splunk"
2223
#Setup the logging
@@ -123,6 +124,8 @@ def handle_POST(self):
123124
return
124125
destUsername = json_dict['destUsername']
125126
destPassword = json_dict['destPassword']
127+
if destPassword.find("password:") == 0:
128+
destPassword = get_password(destPassword[9:], self.request['systemAuth'], logger)
126129
else:
127130
if not 'destURL' in json_dict:
128131
logger.error("Missing one of destURL from the splunk version control restore stanza, invalid configuration")

bin/splunkversioncontrol_utility.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ def runOSProcess(command, logger, timeout=10, shell=False):
3939
def get_password(password, session_key, logger):
4040
#TODO move this into shared function to obtain passwords:
4141
context = os.path.dirname(os.path.dirname(__file__))
42-
42+
43+
if context.find("/bin/") != -1 or context.find("\\bin\\") != -1:
44+
if context.find("/bin/") != -1:
45+
context = context[:context.find("/bin/")]
46+
else:
47+
context = context[:context.find("\\bin\\")]
48+
4349
if platform.system() == "Windows":
4450
start = context.rfind("\\")
4551
else:
@@ -52,6 +58,9 @@ def get_password(password, session_key, logger):
5258
res = requests.get(url, headers=headers, verify=False)
5359
dict = json.loads(res.text)
5460
clear_password = False
61+
if not 'entry' in dict:
62+
logger.warn("dict=%s did not contain the entries expected on url=%s while looking for password=%s" % (dict, url, password))
63+
raise Exception('Error while finding password')
5564
for entry in dict['entry']:
5665
logger.debug("found=%s looking for :%s:" % (entry['name'], password))
5766
if entry['name'].find(":" + password + ":") != -1:
@@ -66,6 +75,9 @@ def get_password(password, session_key, logger):
6675
logger.debug("Trying url=%s with session_key to obtain name=%s" % (url, password))
6776
res = requests.get(url, headers=headers, verify=False)
6877
dict = json.loads(res.text)
78+
if not 'entry' in dict:
79+
logger.warn("dict=%s did not contain the entries expected on url=%s while looking for password=%s" % (dict, url, password))
80+
raise Exception('Error while finding password')
6981
for entry in dict['entry']:
7082
logger.debug("found=%s looking for :%s:" % (entry['name'], password))
7183
if entry['name'].find(":" + password + ":") != -1:

default/app.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ label = SplunkVersionControl
1212
[launcher]
1313
author = Gareth Anderson
1414
description = Version Control software for Splunk instances (backup/restore from git)
15-
version = 1.1.2
15+
version = 1.1.3
1616

1717
[package]
1818
id = SplunkVersionControl

0 commit comments

Comments
 (0)