Add "sanitize config" section

This commit is contained in:
Matthias 2024-03-19 19:30:35 +01:00
parent 3059d66ece
commit 38ae3ac03c
3 changed files with 38 additions and 1 deletions

View File

@ -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)

View File

@ -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

View 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