You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Edgar Rodriguez (JIRA)" <ji...@apache.org> on 2017/08/18 18:47:00 UTC
[jira] [Closed] (AIRFLOW-1516) Potential uncaught errors when
getting fernet object in airflow/models.py
[ https://issues.apache.org/jira/browse/AIRFLOW-1516?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Edgar Rodriguez closed AIRFLOW-1516.
------------------------------------
Resolution: Fixed
> Potential uncaught errors when getting fernet object in airflow/models.py
> -------------------------------------------------------------------------
>
> Key: AIRFLOW-1516
> URL: https://issues.apache.org/jira/browse/AIRFLOW-1516
> Project: Apache Airflow
> Issue Type: Bug
> Reporter: Edgar Rodriguez
> Assignee: Edgar Rodriguez
>
> There are unhandled cases for exceptions when importing fernet in `models.py`. This seems to be a remanent of a previous refactor, replacing logic that would depend on the definition of a global variable for Fernet if it was imported correctly.
> Lazy-loading fernet into a function won't have the same behavior and would raise an ImportError instead.
> Code like:
> {code}
> def set_val(self, value):
> if value:
> try:
> fernet = get_fernet()
> self._val = fernet.encrypt(bytes(value, 'utf-8')).decode()
> self.is_encrypted = True
> except NameError:
> self._val = value
> self.is_encrypted = False
> {code}
> won't catch the right exception since it won't raise {{NameError}}, letting it bubble leading to undetermined behavior.
> Remediation would be to either catch the right exceptions coming out of {{get_fernet()}} function or generally catch all exceptions , given that it's the way other functions are already handling it and the only error handling case here is to not use encryption anyways.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)