Repository navigation
Mask sensitive values in airflow config update dry-run output - #73265
Conversation
|
Human review note from @keith991001: CI is green and this PR is ready for review.
Drafted-by: Codex (GPT-5); reviewed by @keith991001 before posting |
Eason09053360
left a comment
There was a problem hiding this comment.
Thanks for the patch!
Tried this on an Airflow 2-style airflow.cfg: [smtp] smtp_password, [core] internal_api_secret_key and [core] dataset_manager_kwargs still print in clear in the default dry-run — they were sensitive in Airflow 2, but Airflow 3 no longer registers them. Could these legacy options be masked too? Otherwise LGTM :)
|
Thanks for catching this. I updated the dry-run masking to cover
|
namanjain24-sudo
left a comment
There was a problem hiding this comment.
Independently traced the underlying bug (before finding this PR) — write_custom_config had no equivalent to write()'s hide_sensitive/is_sensitive_option handling, so update_config's dry-run always wrote raw values. This PR's fix mirrors write()'s existing masking approach correctly.
Verified two things empirically:
- The
_AIRFLOW_V2_SENSITIVE_OPTIONShardcoding (added after @Eason09053360's review) is necessary, not redundant:is_sensitive_optionreturnsFalsefor all three legacy options (smtp.smtp_password,core.internal_api_secret_key,core.dataset_manager_kwargs) since Airflow 3 no longer registers them. - Renamed currently-sensitive options are also masked correctly:
is_sensitive_optionreturnsTruefor both the old and new spelling ofsql_alchemy_conn(core/database), so checking both(section, option)and(effective_section, effective_option)inwrite_custom_configcovers the rename case. No dedicated test exercises this specific rename+masking path, though — might be worth adding one (e.g. an option present under its pre-3.0 section name that's still sensitive today), non-blocking.
Confirmed the --fix path is unaffected — hide_sensitive isn't passed there, so real values are always written to airflow.cfg, matching the test that asserts this.
Drafted-by: Claude Code (Sonnet 5); reviewed by @namanjain24-sudo before posting
The dry run, the default mode of airflow config update, printed the regenerated airflow.cfg with real values of sql_alchemy_conn, fernet_key and other sensitive options, and that preview output easily ends up in CI logs and bug reports. closes: apache#73255 Generated-by: Claude Opus 5
2536e45 to
aa1c1ad
Compare
potiuk
left a comment
There was a problem hiding this comment.
Thanks — config update defaulting to dry-run made this an easy leak, and masking by default with an explicit --show-sensitive opt-out is the right trade-off; good that --fix is pinned to real values by a test, and that the Airflow 2-only sensitive options are covered. I rebased onto main and dropped the bugfix newsfragment (AGENTS.md: airflow-core only takes significant ones). Approving with auto-merge on.
Drafted-by: Claude Code (Claude Opus 5); reviewed by @potiuk before posting
The dry-run mode of
airflow config update(the default mode) printed the full regeneratedairflow.cfgto stdout with real values —sql_alchemy_conn,fernet_key, SMTP credentials and every other sensitive option. Since the command is documented as a preview tool for the Airflow 3 config migration, its output easily lands in CI logs, bug reports and support channels, leaking those credentials.closes: #73255
What changed
AirflowConfigParser.write_custom_configgains ahide_sensitiveparameter: options registered as sensitive (viais_sensitive_option, the same registryairflow config list --hide-sensitiveuses) are written as< hidden >. Sensitivity is checked against both the original and the post-rename option name, so a renamed sensitive option stays masked.airflow config updatedry-run now masks sensitive values by default and prints a hint; a new--show-sensitiveflag opts back into real values.--fixpath is unchanged: it always writes real values toairflow.cfg, since a masked value would corrupt the config file. This is asserted by a test.Behavior
Verified against a real
AIRFLOW_HOMEwith an embedded DB password, plus three new unit tests (masked by default /--show-sensitivereveals /--fixwrites real values).Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Fable 5) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.