Fix Secrets Masker for non-string values - #71685
Open
pulaksaha143 wants to merge 1 commit into
Open
Conversation
Fixes apache#71275 The SecretsMasker previously only redacted `str` scalar values, allowing non-string scalars like `int`, `float`, `bool`, and `None` to pass through in cleartext even when their keys matched sensitive keywords (e.g. `test-password`). This updates `_redact_all` to invert the type check: it now masks any value that is not explicitly traversed as a collection (`dict`, `tuple`, `set`, `list`).
pulaksaha143
requested review from
amoghrajesh,
ashb and
potiuk
as code owners
August 16, 2026 17:18
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.
Fixes #71275
Description
The
SecretsMaskerpreviously only redactedstrscalar values. This meant that non-string scalars likeint,float,bool, andNonepassed through in cleartext via the REST API even when their keys matched sensitive keywords (e.g.test-password).This PR updates
_redact_allto invert the type check: it now masks any value that is not explicitly traversed as a collection (dict,tuple,set,list), ensuring that numeric API keys and PINs are securely masked.Note that
merge()seamlessly restores the original non-string scalar without issues because it only checks if the incoming payload contains the string"***"before discarding it in favor of the original value.Testing
test_redact_all_directly. Allairflow_shared/secrets_maskertests pass successfully.