fix(config): provide redacted config snapshots for safe diagnostic output#4115
Open
UGVicV wants to merge 14 commits into
Open
fix(config): provide redacted config snapshots for safe diagnostic output#4115UGVicV wants to merge 14 commits into
UGVicV wants to merge 14 commits into
Conversation
added 14 commits
May 22, 2026 11:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves the issue where
Config.to_dict()returns all config values in plain form, including sensitive credentials like passwords, tokens, and API keys. Operational logs or diagnostic output that serialize config snapshots can inadvertently expose credential material.Fix
SENSITIVE_KEY_PATTERNSregex matching:password,secret,token,key,credential,auth(case-insensitive).REDACTED_VALUE = "***REDACTED***"constant for consistent masking.Config._redact_dict()static method that recursively walks nested config dicts and masks sensitive keys.Config.to_redacted_dict()public method that returns a deep copy of config with sensitive values masked.to_dict()is preserved unchanged for trusted internal use.logger.error()for robust error logging.Verification (Proof)
Added 5 regression tests to
tests/test_config.py:test_redacted_masks_sensitive: Verifies password/token/auth keys are masked.test_redacted_preserves_safe: Verifies non-sensitive keys (app_name, port) remain visible.test_redacted_nested: Verifies nested dict keys likedatabase.passwordare masked.test_redacted_does_not_modify_orig: Verifiesto_redacted_dict()does not mutate the original config.test_to_dict_returns_full_data: Verifiesto_dict()still returns unredacted data.Test Execution Output
Lint & Formatting Output
flake8 src/common/config.py tests/test_config.py-> Passed (0 errors/warnings)git diff --check-> Passed (0 errors)No secrets, tokens, or hidden context are included in the code.
Closes #3015.