mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add "sanitize config" section
This commit is contained in:
parent
3059d66ece
commit
38ae3ac03c
|
@ -5,6 +5,7 @@ from typing import Any, Dict, List
|
|||
|
||||
from questionary import Separator, prompt
|
||||
|
||||
from freqtrade.configuration import sanitize_config
|
||||
from freqtrade.configuration.config_setup import setup_utils_configuration
|
||||
from freqtrade.configuration.detect_environment import running_in_docker
|
||||
from freqtrade.configuration.directory_operations import chown_user_directory
|
||||
|
@ -276,5 +277,7 @@ def start_show_config(args: Dict[str, Any]) -> None:
|
|||
|
||||
print("Your combined configuration is:")
|
||||
|
||||
config_sanitized = sanitize_config(config['original_config'])
|
||||
|
||||
from rich import print_json
|
||||
print_json(data=config['original_config'])
|
||||
print_json(data=config_sanitized)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# flake8: noqa: F401
|
||||
|
||||
from freqtrade.configuration.config_secrets import sanitize_config
|
||||
from freqtrade.configuration.config_setup import setup_utils_configuration
|
||||
from freqtrade.configuration.config_validation import validate_config_consistency
|
||||
from freqtrade.configuration.configuration import Configuration
|
||||
|
|
33
freqtrade/configuration/config_secrets.py
Normal file
33
freqtrade/configuration/config_secrets.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
|
||||
|
||||
from freqtrade.constants import Config
|
||||
|
||||
|
||||
def sanitize_config(config: Config) -> Config:
|
||||
"""
|
||||
Remove sensitive information from the config.
|
||||
:param config: Configuration
|
||||
:return: Configuration
|
||||
"""
|
||||
keys_to_remove = [
|
||||
"exchange.key",
|
||||
"exchange.secret",
|
||||
"exchange.password",
|
||||
"exchange.uid",
|
||||
"telegram.token",
|
||||
"telegram.chat_id",
|
||||
"discord.webhook_url",
|
||||
"api_server.password",
|
||||
]
|
||||
|
||||
for key in keys_to_remove:
|
||||
if '.' in key:
|
||||
nested_keys = key.split('.')
|
||||
nested_config = config
|
||||
for nested_key in nested_keys[:-1]:
|
||||
nested_config = nested_config.get(nested_key, {})
|
||||
nested_config[nested_keys[-1]] = 'REDACTED'
|
||||
else:
|
||||
config[key] = 'REDACTED'
|
||||
|
||||
return config
|
Loading…
Reference in New Issue
Block a user