Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All Airflow Configurations set via Environment Variable are masked when expose_config is set as non-sensitive-only #28756

Closed
2 tasks done
wolfier opened this issue Jan 5, 2023 · 4 comments · Fixed by #28802
Labels
area:webserver Webserver related Issues good first issue kind:bug This is a clearly a bug

Comments

@wolfier
Copy link
Contributor

wolfier commented Jan 5, 2023

Apache Airflow version

2.5.0

What happened

In Airflow 2.4.0, a new feature was added that added an option to mask sensitive data in UI configuration page (PR). I have set AIRFLOW__WEBSERVER__EXPOSE_CONFIG as NON-SENSITIVE-ONLY.

The feature is working partially as the airflow.cfg file display only has sensitive configurations marked as < hidden >. However, the Running Configuration table below the file display has all configuration set via environment variables marked as < hidden > which I believe is unintended.

I did not change airflow.cfg so the value here is displaying the default value of False as expected.

Screen Shot 2023-01-05 at 1 39 11 PM

The value for expose_config I expect to be shown as NON-SENSITIVE-ONLY but it shown as < hidden >.

Screen Shot 2023-01-05 at 1 39 27 PM

What you think should happen instead

As mentioned previously, the value for expose_config I expect to be shown as NON-SENSITIVE-ONLY.

Only the sensitive variables should be set as < hidden >.

How to reproduce

Set an Airflow configuration through the environment variable and check on the Configuration page.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@wolfier wolfier added area:core kind:bug This is a clearly a bug labels Jan 5, 2023
@wolfier wolfier changed the title All Airflow Configurations set via Environment Variable are masked when expose_config is set as non-sensitive-only` All Airflow Configurations set via Environment Variable are masked when expose_config is set as non-sensitive-only Jan 5, 2023
@wolfier
Copy link
Contributor Author

wolfier commented Jan 5, 2023

I believe the issue is because when the configuration is fetched as a dictionary, the values have already been hidden because display_sensitive is passed as False. The dictionary is built by calling _include_envs which hides any configuration that does not end with _cmd and _secret.

Instead, conf.as_dict should be passed with display_sensitive as True. That way, all configurations are not hidden and can be selectively hidden with SENSITIVE_CONFIG_VALUES.

conf_dict = conf.as_dict(True, True)

for sect, key in SENSITIVE_CONFIG_VALUES:
    if sect in conf_dict and key in conf_dict[sect]:
        value, source = conf_dict[sect][key]
        conf_dict[sect][key] = ("< hidden >", source)

table = [
    (section, key, str(value), source)
    for section, parameters in conf_dict.items()
    for key, (value, source) in parameters.items()
]

@potiuk
Copy link
Member

potiuk commented Jan 6, 2023

Would you like to take a stab on it @wolfier ?

@uranusjr uranusjr added area:webserver Webserver related Issues and removed area:core labels Jan 6, 2023
@ephraimbuddy
Copy link
Contributor

I think we should hide this in _include_envs so it's same as _include_cmds & _include_secrets:

diff --git a/airflow/configuration.py b/airflow/configuration.py
index 41778fe374..df393da6e6 100644
--- a/airflow/configuration.py
+++ b/airflow/configuration.py
@@ -1149,7 +1149,8 @@ class AirflowConfigParser(ConfigParser):
             if not display_sensitive and env_var != self._env_var_name("core", "unit_test_mode"):
                 # Don't hide cmd/secret values here
                 if not env_var.lower().endswith("cmd") and not env_var.lower().endswith("secret"):
-                    opt = "< hidden >"
+                    if (section, key) in self.sensitive_config_values:
+                        opt = "< hidden >"
 
             elif raw:
                 opt = opt.replace("%", "%%")
(END)

@uranusjr
Copy link
Member

uranusjr commented Jan 6, 2023

I searched for as_dict usages and this is the only place where display_sensitive is False, so I think we should simply incorporate SENSITIVE_CONFIG_VALUES as Ephraim said. Otherwise the flag is basically useless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:webserver Webserver related Issues good first issue kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants