Skip to content

Commit 769bb5a

Browse files
committed
Updated splunk_vc_kom_audit_summary report
Added i=StanzaName to the indexed data when running the audit query Now attempting to hide (most) passwords from the logs by default (for example when an OS error occurs don't print the stdout including the password in use) git diff now uses --no-pager to prevent trucation of the diff command with -U0 (no context) New options: `disable_file_deletion` - do not delete files in remote git repo that are not found during backup, useful for testing `use_wdiff` - sends the output of the diff command to Unix command wdiff to provide a nicer diff output Updated report: `SplunkVersionControl ChangeDetector Non-Directory` now excludes the CIM Risk and Incident_Management datamodels as they update very frequently with close to zero changes (calculationId changes only)
1 parent 6aabb8b commit 769bb5a

10 files changed

+312
-53
lines changed

README.md

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

291291
## Release Notes
292+
### 1.2.4
293+
Updated `splunk_vc_kom_audit_summary` report
294+
295+
Added i=StanzaName to the indexed data when running the audit query
296+
297+
Now attempting to hide (most) passwords from the logs by default (for example when an OS error occurs don't print the stdout including the password in use)
298+
299+
git diff now uses --no-pager to prevent trucation of the diff command with -U0 (no context)
300+
301+
New options:
302+
`disable_file_deletion` - do not delete files in remote git repo that are not found during backup, useful for testing
303+
304+
`use_wdiff` - sends the output of the diff command to Unix command wdiff to provide a nicer diff output
305+
306+
Updated report:
307+
`SplunkVersionControl ChangeDetector Non-Directory` now excludes the CIM Risk and Incident_Management datamodels as they update very frequently with close to zero changes (calculationId changes only)
308+
292309
### 1.2.3
293310
New option `disable_git_ssl_verify`
294311

README/inputs.conf.spec

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ excludeOwner = <value>
2525
* comma separated list of owners objects that should be transferred
2626
debugMode = <boolean>
2727
* turn on DEBUG level logging (defaults to INFO) (true/false), default false
28+
show_passwords = <boolean>
29+
* Show passwords in the DEBUG/ERROR logs (hidden by default)
2830
useLocalAuth = <boolean>
2931
* do not use the srcUsername/srcPassword, use the session_key of the user running the modular input instead (works on localhost only) (true/false), default false
3032
remoteAppName = <value>
@@ -33,7 +35,7 @@ appsList = <value>
3335
* Comma separated list of apps, this changes Splunk Version Control to not list all applications and instead only runs a backup on the specified apps
3436
git_command = <value>
3537
* defaults to 'git', can be overriden (for example on a Windows server) to use a full path to the git command
36-
ssh_command = <value>
38+
ssh_command = <value>
3739
* defaults to 'ssh', can be overriden (for example on a Windows server) to use a full path to the ssh command
3840
proxy = <value>
3941
* If supplied provides a proxy setting to use to access the srcURL (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
@@ -53,6 +55,10 @@ run_ko_diff = <boolean>
5355
* Should output of the modular input include diff information (requires run_ko_query to be true, defaults to false)
5456
disable_git_ssl_verify = <boolean>
5557
* Use GIT_SSL_NO_VERIFY=true on all git commands
58+
use_wdiff = <boolean>
59+
* Enables the diff HEAD~1 to be passed to wdiff for improved formatting if run_ko_diff is enabled
60+
disable_file_deletion = <boolean>
61+
* By default if the app or file no longer exists than it is deleted from the git repo, this stops the deletion from occurring
5662

5763
[splunkversioncontrol_restore://<name>]
5864
destURL = <value>
@@ -71,6 +77,8 @@ auditLogsLookupBackTime = <value>
7177
* This is how far back the audit logs will be checked to ensure that a restore entry is valid, this should be set to your interval time or slightly more, defaults to -1h (use Splunk format)
7278
debugMode = <boolean>
7379
* turn on DEBUG level logging (defaults to INFO) (true/false), default false
80+
show_passwords = <boolean>
81+
* Show passwords in the DEBUG/ERROR logs (hidden by default)
7482
useLocalAuth = <boolean>
7583
* do not use the srcUsername/srcPassword, use the session_key of the user running the modular input instead (works on localhost only) (true/false), default false
7684
remoteAppName = <value>
@@ -91,4 +99,3 @@ file_per_ko = <boolean>
9199
* 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
92100
disable_git_ssl_verify = <boolean>
93101
* Use GIT_SSL_NO_VERIFY=true on all git commands
94-

bin/splunkversioncontrol_backup.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Store Knowledge Objects
1616
Attempt to run against the Splunk REST API to obtain various knowledge objects, then persist the knowledge object information required
1717
to restore the knowledge object if it was deleted/changed to the filesystem
18-
18+
1919
"""
2020

2121
#Define the XML scheme for the inputs page
@@ -94,6 +94,13 @@
9494
<required_on_create>false</required_on_create>
9595
<data_type>boolean</data_type>
9696
</arg>
97+
<arg name="show_passwords">
98+
<title>show_passwords</title>
99+
<description>Show passwords in the DEBUG/ERROR logs (hidden by default)</description>
100+
<validation>is_bool('show_passwords')</validation>
101+
<required_on_create>false</required_on_create>
102+
<data_type>boolean</data_type>
103+
</arg>
97104
<arg name="useLocalAuth">
98105
<title>useLocalAuth</title>
99106
<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>
@@ -174,6 +181,20 @@
174181
<data_type>boolean</data_type>
175182
<validation>is_bool('disable_git_ssl_verify')</validation>
176183
</arg>
184+
<arg name="use_wdiff">
185+
<title>use_wdiff</title>
186+
<description>Enables the diff HEAD~1 to be passed to wdiff for improved formatting if run_ko_diff is enabled</description>
187+
<required_on_create>false</required_on_create>
188+
<data_type>boolean</data_type>
189+
<validation>is_bool('use_wdiff')</validation>
190+
</arg>
191+
<arg name="disable_file_deletion">
192+
<title>disable_file_deletion</title>
193+
<description>By default if the app or file no longer exists than it is deleted from the git repo, this stops the deletion from occurring</description>
194+
<required_on_create>false</required_on_create>
195+
<data_type>boolean</data_type>
196+
<validation>is_bool('disable_file_deletion')</validation>
197+
</arg>
177198
</args>
178199
</endpoint>
179200
</scheme>
@@ -218,7 +239,7 @@ def print_error(s):
218239
#Validate the arguments to the app to ensure this will work...
219240
def validate_arguments():
220241
val_data = get_validation_data()
221-
242+
222243
if 'debugMode' in val_data:
223244
debugMode = val_data['debugMode'].lower()
224245
if debugMode == "true" or debugMode == "t" or debugMode == "1":
@@ -240,7 +261,7 @@ def validate_arguments():
240261
else:
241262
print_error("useLocalAuth argument should be true or false, invalid config")
242263
sys.exit(2)
243-
264+
244265
#If we're not using the useLocalAuth we must have a username/password to work with
245266
if not useLocalAuth and ('srcUsername' not in val_data or 'srcPassword' not in val_data):
246267
print_error("useLocalAuth is not set to true and srcUsername/srcPassword not set, invalid config")
@@ -318,14 +339,15 @@ def validate_arguments():
318339

319340
gitRepoURL = val_data['gitRepoURL']
320341
proxy_command = ""
342+
git_password = False
321343
if gitRepoURL.find("http") == 0:
322344
gitRepoHTTP = True
323345
if gitRepoURL.find("password:") != -1:
324346
start = gitRepoURL.find("password:") + 9
325347
end = gitRepoURL.find("@")
326348
logger.debug("Attempting to replace gitRepoURL=%s by subsituting=%s with a password" % (gitRepoURL, gitRepoURL[start:end]))
327-
temp_password = get_password(gitRepoURL[start:end], session_key, logger)
328-
gitRepoURL = gitRepoURL[0:start-9] + temp_password + gitRepoURL[end:]
349+
git_password = get_password(gitRepoURL[start:end], session_key, logger)
350+
gitRepoURL = gitRepoURL[0:start-9] + git_password + gitRepoURL[end:]
329351
else:
330352
gitRepoHTTP = False
331353

@@ -347,21 +369,33 @@ def validate_arguments():
347369
else:
348370
proxy_command = "export " + proxy_command + " ; "
349371

372+
show_passwords = False
373+
if 'show_passwords' in val_data:
374+
if val_data['show_passwords'].lower() == 'true' or val_data['show_passwords'] == "1":
375+
show_passwords = True
376+
logger.debug('show_passwords is now true due to show_passwords: ' + val_data['show_passwords'])
377+
350378
(stdout, stderr, res) = runOSProcess("%s %s ls-remote %s" % (proxy_command, git_command, gitRepoURL), logger, shell=True)
351379
#If we didn't manage to ls-remote perhaps we just need to trust the fingerprint / this is the first run?
352380
if res == False and not gitRepoHTTP:
381+
if not show_passwords and git_password:
382+
stdout = stdout.replace(git_password, "password_removed")
383+
stderr = stderr.replace(git_password, "password_removed")
353384
logger.error("Possible first run trying again" % (stdout, stderr))
354385
(stdout, stderrout, res) = runOSProcess(ssh_command + " -n -o \"BatchMode yes\" -o StrictHostKeyChecking=no " + gitRepoURL[:gitRepoURL.find(":")], logger)
355386
(stdout, stderr, res) = runOSProcess("%s ls-remote %s" % (git_command, gitRepoURL), logger)
356387

357388
if res == False:
389+
if not show_passwords and git_password:
390+
stdout = stdout.replace(git_password, "password_removed")
391+
stderr = stderr.replace(git_password, "password_removed")
358392
print_error("Failed to validate the git repo URL, stdout of '%s', stderr of '%s'" % (stdout, stderr))
359393
logger.error("Failed to validate the git repo URL, stdout of '%s', stderr of '%s'" % (stdout, stderr))
360394
sys.exit(6)
361395

362396
#Print the scheme
363397
def do_scheme():
364-
print(SCHEME)
398+
print(SCHEME)
365399

366400
splunkLogsDir = os.environ['SPLUNK_HOME'] + "/var/log/splunk"
367401
#Setup the logging
@@ -381,7 +415,7 @@ def do_scheme():
381415
'maxBytes' : 2097152,
382416
'level': logging.DEBUG,
383417
'backupCount' : 5 }
384-
},
418+
},
385419
root = {
386420
'handlers': ['h','file'],
387421
'level': logging.DEBUG,

0 commit comments

Comments
 (0)