Skip to content

Commit

Permalink
Hide passwords in debug logs
Browse files Browse the repository at this point in the history
Add 6.6 branch to tests
Fix typo in test

fixes elastic#1336
  • Loading branch information
untergeek committed Feb 1, 2019
1 parent 8b95c2b commit f33c6f3
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ oneliners.py
.eggs
.idea
.vscode
venvs
Elastic.ico
Vagrant/centos/6/.vagrant
Vagrant/centos/7/.vagrant
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ env:
- ES_VERSION=6.2.4
- ES_VERSION=6.3.2
- ES_VERSION=6.4.3
- ES_VERSION=6.5.0
- ES_VERSION=6.5.4
- ES_VERSION=6.6.0

os: linux

Expand Down
6 changes: 3 additions & 3 deletions curator/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import click
from voluptuous import Schema
from curator import actions
from curator.config_utils import process_config
from curator.config_utils import process_config, password_filter
from curator.defaults import settings
from curator.exceptions import NoIndices, NoSnapshots
from curator.indexlist import IndexList
Expand Down Expand Up @@ -115,10 +115,10 @@ def run(config, action_file, dry_run=False):
#########################################
logger.debug('action_file: {0}'.format(action_file))
action_config = get_yaml(action_file)
logger.debug('action_config: {0}'.format(action_config))
logger.debug('action_config: {0}'.format(password_filter(action_config)))
action_dict = validate_actions(action_config)
actions = action_dict['actions']
logger.debug('Full list of actions: {0}'.format(actions))
logger.debug('Full list of actions: {0}'.format(password_filter(actions)))
action_keys = sorted(list(actions.keys()))
for idx in action_keys:
action = actions[idx]['action']
Expand Down
14 changes: 14 additions & 0 deletions curator/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from curator.validators import SchemaCheck, config_file
from curator.utils import ensure_list, get_yaml, prune_nones, test_client_options
from curator.logtools import LogInfo, Whitelist, Blacklist
from copy import deepcopy

def test_config(config):
# Get config from yaml file
Expand Down Expand Up @@ -38,3 +39,16 @@ def process_config(yaml_file):
set_logging(config['logging'])
test_client_options(config['client'])
return config['client']

def password_filter(data):
"""
Return a deepcopy of the dictionary with any password fields hidden
"""
def iterdict(mydict):
for key, value in mydict.items():
if isinstance(value, dict):
iterdict(value)
elif key == "password":
mydict.update({"password": "REDACTED"})
return mydict
return iterdict(deepcopy(data))
1 change: 1 addition & 0 deletions docs/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Changelog

* Report rollover results in both dry-run and regular runs. Requested
in #1313 (untergeek)
* Hide passwords in DEBUG logs. Requested in #1336 (untergeek)

5.6.0 (13 November 2018)
------------------------
Expand Down
2 changes: 1 addition & 1 deletion test/integration/testvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@
' description: "Delete indices as filtered"\n'
' action: delete_indices\n'
' options:\n'
' alllow_ilm_indices: {9}\n'
' allow_ilm_indices: {9}\n'
' filters:\n'
' - filtertype: {0}\n'
' source: {1}\n'
Expand Down

0 comments on commit f33c6f3

Please sign in to comment.