github-advanced-security[bot] commented on code in PR #56821:
URL: https://github.com/apache/airflow/pull/56821#discussion_r2452444947
##########
airflow-core/src/airflow/configuration.py:
##########
@@ -1248,6 +1249,48 @@
f'Current value: "{val}".'
)
+ E = TypeVar("E", bound=Enum)
+
+ def getenum(self, section: str, key: str, enum_class: type[E], **kwargs)
-> E:
+ val = self.get(section, key, **kwargs)
+ enum_names = [enum_item.name for enum_item in enum_class]
+
+ if val is None:
+ raise AirflowConfigException(
+ f'Failed to convert value. Please check "{key}" key in
"{section}" section. '
+ f'Current value: "{val}" and it must be one of {",
".join(enum_names)}'
+ )
+
+ try:
+ return enum_class[val]
+ except KeyError:
+ if "fallback" in kwargs and kwargs["fallback"] in enum_names:
+ return enum_class[kwargs["fallback"]]
+ raise AirflowConfigException(
+ f'Failed to convert value. Please check "{key}" key in
"{section}" section. '
+ f'Current value: "{val}" and it must be one of {",
".join(enum_names)}'
+ )
+
+ def getenumlist(self, section: str, key: str, enum_class: type[E],
delimiter=",", **kwargs) -> list[E]:
+ string_list = self.getlist(section, key, delimiter, **kwargs)
+ enum_names = [enum_item.name for enum_item in enum_class]
+ enum_list = []
+
+ for val in string_list:
+ try:
+ enum_list.append(enum_class[val])
+ except KeyError:
+ log.warning(
+ "Failed to convert value. Please check %s key in %s
section. "
+ "Current value: %s and it must be one of %s",
+ key,
+ section,
+ val,
Review Comment:
## Clear-text logging of sensitive information
This expression logs [sensitive data (secret)](1) as clear text.
This expression logs [sensitive data (secret)](2) as clear text.
[Show more
details](https://github.com/apache/airflow/security/code-scanning/540)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]