Skip to content

[v3-2-test] Check sensitive key names before applying recursion-depth cutoff in secrets masker (#65912)#66748

Draft
github-actions[bot] wants to merge 1 commit into
v3-2-testfrom
backport-354391b-v3-2-test
Draft

[v3-2-test] Check sensitive key names before applying recursion-depth cutoff in secrets masker (#65912)#66748
github-actions[bot] wants to merge 1 commit into
v3-2-testfrom
backport-354391b-v3-2-test

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

SecretsMasker._redact short-circuited on depth > max_depth before
checking whether the current key name was sensitive
(should_hide_value_for_key(name)). For sensitive keys nested beyond
the recursion depth (default 5), the original value was returned
unchanged instead of being replaced with ***.

Move the depth cutoff inside the try: block, after the
sensitive-key check, and let dict traversal continue past the cutoff
so deeper sensitive keys are still caught. Non-dict containers and
the string-pattern masker keep the depth-bounded behavior the cutoff
was added for. JSON-loaded payloads cannot be self-referential, and
any in-memory cycle hits Python's own recursion limit and falls
through the existing exception handler to "",
which preserves the fail-closed property.
(cherry picked from commit 354391b)

Co-authored-by: Jarek Potiuk jarek@potiuk.com
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at
https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions

… cutoff in secrets masker (#65912)

`SecretsMasker._redact` short-circuited on `depth > max_depth` before
checking whether the current key name was sensitive
(`should_hide_value_for_key(name)`). For sensitive keys nested beyond
the recursion depth (default 5), the original value was returned
unchanged instead of being replaced with `***`.

Move the depth cutoff inside the `try:` block, after the
sensitive-key check, and let dict traversal continue past the cutoff
so deeper sensitive keys are still caught. Non-dict containers and
the string-pattern masker keep the depth-bounded behavior the cutoff
was added for. JSON-loaded payloads cannot be self-referential, and
any in-memory cycle hits Python's own recursion limit and falls
through the existing exception handler to "<redaction-failed>",
which preserves the fail-closed property.
(cherry picked from commit 354391b)

Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at
https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant