Skip to content

Commit ce9549e

Browse files
committed
This version includes a few changes, these include two new parameters on the version control backup:
`run_ko_query` - if enabled this runs a Splunk savedsearch and adds the additional information of tag=`git_tag_name` into the output of the modular input which is then indexed `run_ko_diff` - if enabled in combination with `run_ko_query` this additionally adds a diff=`git_difference_result` from comparing the new version with HEAD~1 To run the query the macro `splunk_vc_ko_query`, should be configured to point to an appname:searchname, the default is `splunk_kom:splunk_vc_kom_audit_summary` If you have the Knowledge Object Overview App for Splunk (https://splunkbase.splunk.com/app/5399/) installed then there is a savedsearch called `splunk_vc_kom_audit_summary` which can be moved or copied into the `splunk_kom` app for this new functionality to work as expected In addition the field qualifiedSearch is now longer backed up for savedsearches Boolean tickboxes are now used for options that should be true or false Also attempted to improve the error logging for failed OS process execution Fixed a few misc bugs related to setting email address/name in the git repo among others
1 parent 3a8cd7f commit ce9549e

18 files changed

+1221
-141
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ There are also many online resources to help with learning git
169169
- git_branch - optional, sets the git branch to use, defaults to master
170170
- git_proxy - optional, if supplied provides a proxy setting to use to access the git repository (https proxy). Use https://user:password:[email protected]:3128 and the application will obtain the password for the entry 'passwordinpasswordsconf'. If password: is not used the password is used as per a normal proxy setting, for example https://user:[email protected]:3128
171171
- file_per_ko - optional, do you want one file per knowledge object? Or a combined file? Defaults to false (i.e. 1 large file for global dashboards in an app). Note that if you change this setting you will need to re-create or wipe the repository as the files are stored differently...Note this setting should match in both backup and restore modular inputs for a particular repo
172+
- run_ko_query - optional, do you want to run a Splunk query to determine which knowledge objects changed? Uses macro `splunk_vc_ko_query` (defaults to false)
173+
- run_ko_diff - optional, should output of the modular input include diff information (requires `run_ko_query` to be true, defaults to false)
172174

173175
"More settings"
174176
- interval - how often the backup should run, if not set the backup will only run on restart of the Splunk instance or when you save this configuration...
@@ -206,6 +208,19 @@ The following macros exist and are relate to the `splunkversioncontrol_restore_d
206208
- `splunk_vc_timeout` - this is the time delay between triggering the remote command and waiting for the `_audit` index to catchup with a log entry to advise the command was run, if set too short the restore may fail because the `| postversioncontrolrestore` search has not appeared in the `_audit` index yet
207209
- `sslVerify` - defaults to "False", this can be set to the location of a CA file to be used by the python requests library to validate the SSL certificates in use
208210
- `requestingAddress` - by default the REST endpoint splunkversioncontrol_rest_restore will make a HTTPS call back to the calling IP address, this overrides the address to call back, the default of False results in a call back to the requesting IP address which is used in most use cases
211+
- `splunk_vc_ko_query`, should be configured to point to an appname:searchname, the default is `splunk_kom:splunk_vc_kom_audit_summary`
212+
213+
## Configuring the macro & savedsearch to work with the run_ko_query option
214+
If `run_ko_query` is configured, then the app will attempt to trigger the savedsearch configured by the macro `splunk_vc_ko_query`
215+
The macro should be in the format appcontext:savedsearchname
216+
217+
By default this is configured to `splunk_kom:splunk_vc_kom_audit_summary` and was tested against version 1.0.26 of the Knowledge Object Overview App for Splunk (kom) application (https://splunkbase.splunk.com/app/5399/)
218+
219+
Note that the savedsearch `splunk_vc_kom_audit_summary` is included in the Splunk version control application but will need to be moved into the `splunk_kom` app context to work as expected, or you can make your own search if preferred.
220+
221+
Since the output is from the modular input, the output will default to the sourctype `splunkversioncontrol_backup` and will appear in the main index (you can change this in more settings)
222+
223+
Finally, the `run_ko_diff` option if configured in addition to the `run_ko_query` will run a git diff of HEAD~1 and include that in the output of the modular input (and will therefore be indexed into Splunk)
209224

210225
## Troubleshooting
211226
In some Linux OS distributions an error similar to `OPENSSL_1.0.0 not found` may appear, `os.unsetenv('LD_LIBRARY_PATH')` appears to fix this however AppInspect does not allow modification of OS environment variables.
@@ -274,6 +289,22 @@ To do this you will need to install Version Control For SplunkCloud on your Splu
274289
[SplunkVersionControlCloud github](https://github.com/gjanders/SplunkVersionControlCloud)
275290

276291
## Release Notes
292+
### 1.2.2
293+
This version includes a few changes, these include two new parameters on the version control backup:
294+
`run_ko_query` - if enabled this runs a Splunk savedsearch and adds the additional information of tag=`git_tag_name` into the output of the modular input which is then indexed
295+
`run_ko_diff` - if enabled in combination with `run_ko_query` this additionally adds a diff=`git_difference_result` from comparing the new version with HEAD~1
296+
297+
To run the query the macro `splunk_vc_ko_query`, should be configured to point to an appname:searchname, the default is `splunk_kom:splunk_vc_kom_audit_summary`
298+
If you have the Knowledge Object Overview App for Splunk (https://splunkbase.splunk.com/app/5399/) installed then there is a savedsearch called `splunk_vc_kom_audit_summary` which can be moved or copied into the `splunk_kom` app for this new functionality to work as expected
299+
300+
In addition the field qualifiedSearch is now longer backed up for savedsearches
301+
302+
Boolean tickboxes are now used for options that should be true or false
303+
304+
Also attempted to improve the error logging for failed OS process execution
305+
306+
Fixed a few misc bugs related to setting email address/name in the git repo among others
307+
277308
### 1.2.1
278309
This version includes some changes that should reduce the storage size of savedsearches, in particular:
279310
- listDefaultActionArgs=false is now used on the savedsearches REST endpoint

README/inputs.conf.spec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ git_proxy = <value>
4747
* If supplied provides a proxy setting to use to access the git repository (https proxy). Use https://user:password:[email protected]:3128 and the application will obtain the password for the entry 'passwordinpasswordsconf'. If password: is not used the password is used as per a normal proxy setting, for example https://user:[email protected]:3128</description>
4848
file_per_ko = <boolean>
4949
* Do you want one file per knowledge object? Or a combined file? Defaults to false (i.e. 1 large file for global dashboards in an app). Note that if you change this you will need to re-create or wipe the repository as the files are stored differently...Note this setting should match in both backup and restore modular inputs for a particular repo
50+
run_ko_query = <boolean>
51+
* Do you want to run a Splunk query to determine which knowledge objects changed? macro 'splunk_vc_ko_query' (defaults to false)
52+
run_ko_diff = <boolean>
53+
* Should output of the modular input include diff information (requires run_ko_query to be true, defaults to false)
5054

5155
[splunkversioncontrol_restore://<name>]
5256
destURL = <value>

bin/splunkversioncontrol_backup.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@
5858
<description>disable the backup of user level / private objects (true/false), default false</description>
5959
<validation>is_bool('noPrivate')</validation>
6060
<required_on_create>false</required_on_create>
61+
<data_type>boolean</data_type>
6162
</arg>
6263
<arg name="noDisabled">
6364
<title>noDisabled</title>
6465
<description>disable the backup of objects with a disabled status in Splunk (true/false), default false</description>
6566
<validation>is_bool('noDisabled')</validation>
6667
<required_on_create>false</required_on_create>
68+
<data_type>boolean</data_type>
6769
</arg>
6870
<arg name="includeEntities">
6971
<title>includeEntities</title>
@@ -90,12 +92,14 @@
9092
<description>turn on DEBUG level logging (defaults to INFO) (true/false), default false</description>
9193
<validation>is_bool('debugMode')</validation>
9294
<required_on_create>false</required_on_create>
95+
<data_type>boolean</data_type>
9396
</arg>
9497
<arg name="useLocalAuth">
9598
<title>useLocalAuth</title>
9699
<description>Instead of using the srcUsername/srcPassword, use the session_key of the user running the modular input instead (works on localhost only) (true/false), default false</description>
97100
<validation>is_bool('useLocalAuth')</validation>
98101
<required_on_create>false</required_on_create>
102+
<data_type>boolean</data_type>
99103
</arg>
100104
<arg name="remoteAppName">
101105
<title>remoteAppName</title>
@@ -146,6 +150,22 @@
146150
<title>file_per_ko</title>
147151
<description>Do you want one file per knowledge object? Or a combined file? Defaults to false (i.e. 1 large file for global dashboards in an app)</description>
148152
<required_on_create>false</required_on_create>
153+
<data_type>boolean</data_type>
154+
<validation>is_bool('file_per_ko')</validation>
155+
</arg>
156+
<arg name="run_ko_query">
157+
<title>run_ko_query</title>
158+
<description>Do you want to run a Splunk query to determine which knowledge objects changed? macro 'splunk_vc_ko_query' (defaults to false)</description>
159+
<required_on_create>false</required_on_create>
160+
<data_type>boolean</data_type>
161+
<validation>is_bool('run_ko_query')</validation>
162+
</arg>
163+
<arg name="run_ko_diff">
164+
<title>run_ko_diff</title>
165+
<description>Should output of the modular input include diff information (requires run_ko_query to be true, defaults to false)</description>
166+
<required_on_create>false</required_on_create>
167+
<data_type>boolean</data_type>
168+
<validation>is_bool('run_ko_diff')</validation>
149169
</arg>
150170
</args>
151171
</endpoint>
@@ -194,21 +214,21 @@ def validate_arguments():
194214

195215
if 'debugMode' in val_data:
196216
debugMode = val_data['debugMode'].lower()
197-
if debugMode == "true" or debugMode == "t":
217+
if debugMode == "true" or debugMode == "t" or debugMode == "1":
198218
logging.getLogger().setLevel(logging.DEBUG)
199219

200220
session_key = val_data['session_key']
201221

202222
useLocalAuth = False
203223
if 'useLocalAuth' in val_data:
204224
useLocalAuth = val_data['useLocalAuth'].lower()
205-
if useLocalAuth == "true" or useLocalAuth == "t":
225+
if useLocalAuth == "true" or useLocalAuth == "t" or useLocalAuth == "1":
206226
useLocalAuth = True
207227
logger.debug("useLocalAuth enabled")
208228
if val_data['srcURL'] != "https://localhost:8089":
209229
print_error("Expected srcURL of https://localhost:8089 since useLocalAuth=True")
210230
sys.exit(1)
211-
elif useLocalAuth == "false" or useLocalAuth == "f":
231+
elif useLocalAuth == "false" or useLocalAuth == "f" or useLocalAuth == "0":
212232
useLocalAuth = False
213233
else:
214234
print_error("useLocalAuth argument should be true or false, invalid config")
@@ -225,21 +245,23 @@ def validate_arguments():
225245

226246
if 'git_command' in val_data:
227247
git_command = val_data['git_command'].strip()
248+
git_command = git_command.replace("\\","/")
228249
logger.debug("Overriding git command to %s" % (git_command))
229250
else:
230251
git_command = "git"
231252
if 'ssh_command' in val_data:
232253
ssh_command = val_data['ssh_command'].strip()
254+
ssh_command = ssh_command.replace("\\","/")
233255
logger.debug("Overriding ssh command to %s" % (ssh_command))
234256
else:
235257
ssh_command = "ssh"
236258

237259
sslVerify = False
238260
if 'sslVerify' in val_data:
239-
if val_data['sslVerify'].lower() == 'true':
261+
if val_data['sslVerify'].lower() == 'true' or val_data['sslVerify'] == "1":
240262
sslVerify = True
241263
logger.debug('sslverify set to boolean True from: ' + val_data['sslVerify'])
242-
elif val_data['sslVerify'].lower() == 'false':
264+
elif val_data['sslVerify'].lower() == 'false' or val_data['sslVerify'] == "0":
243265
sslVerify = False
244266
logger.debug('sslverify set to boolean False from: ' + val_data['sslVerify'])
245267
else:
@@ -301,14 +323,16 @@ def validate_arguments():
301323
else:
302324
proxy_command = "export " + proxy_command + " ; "
303325

304-
(stdout, stderr, res) = runOSProcess("%s %s ls-remote %s" % (proxy_command, git_command, gitRepoURL), logger)
326+
(stdout, stderr, res) = runOSProcess("%s %s ls-remote %s" % (proxy_command, git_command, gitRepoURL), logger, shell=True)
305327
#If we didn't manage to ls-remote perhaps we just need to trust the fingerprint / this is the first run?
306328
if res == False and not gitRepoHTTP:
329+
logger.error("Possible first run trying again" % (stdout, stderr))
307330
(stdout, stderrout, res) = runOSProcess(ssh_command + " -n -o \"BatchMode yes\" -o StrictHostKeyChecking=no " + gitRepoURL[:gitRepoURL.find(":")], logger)
308331
(stdout, stderr, res) = runOSProcess("%s ls-remote %s" % (git_command, gitRepoURL), logger)
309332

310333
if res == False:
311334
print_error("Failed to validate the git repo URL, stdout of '%s', stderr of '%s'" % (stdout, stderr))
335+
logger.error("Failed to validate the git repo URL, stdout of '%s', stderr of '%s'" % (stdout, stderr))
312336
sys.exit(6)
313337

314338

0 commit comments

Comments
 (0)