You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2022/03/16 11:42:16 UTC

[airflow] branch v2-2-test updated (94a75ae -> a336a6c)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a change to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git.


    from 94a75ae  Fix race condition between triggerer and scheduler (#21316)
     new da7c463  A trigger might use a connection; make sure we mask passwords (#21207)
     new a8e9aa6  fix: Update custom connection field processing (#20883)
     new a336a6c  Set X-Frame-Options header to DENY only if X_FRAME_ENABLED is set to true. (#19491)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 airflow/cli/commands/triggerer_command.py |  1 +
 airflow/www/extensions/init_security.py   |  3 ++-
 airflow/www/views.py                      | 28 +++++++++++++++++-----------
 tests/www/views/test_views_connection.py  | 15 +++++++++++++++
 4 files changed, 35 insertions(+), 12 deletions(-)

[airflow] 01/03: A trigger might use a connection; make sure we mask passwords (#21207)

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit da7c4634a65ba22a3e0cf59ce90fc84307363e11
Author: Malthe Borch <mb...@gmail.com>
AuthorDate: Sat Jan 29 16:10:23 2022 +0000

    A trigger might use a connection; make sure we mask passwords (#21207)
    
    (cherry picked from commit 3d0c1aea5a85a4d31d3ade530e4c5b85b045503a)
---
 airflow/cli/commands/triggerer_command.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/airflow/cli/commands/triggerer_command.py b/airflow/cli/commands/triggerer_command.py
index 40b1b0e..110ff4f 100644
--- a/airflow/cli/commands/triggerer_command.py
+++ b/airflow/cli/commands/triggerer_command.py
@@ -30,6 +30,7 @@ from airflow.utils.cli import setup_locations, setup_logging, sigint_handler, si
 @cli_utils.action_logging
 def triggerer(args):
     """Starts Airflow Triggerer"""
+    settings.MASK_SECRETS_IN_LOGS = True
     print(settings.HEADER)
     job = TriggererJob(capacity=args.capacity)
 

[airflow] 02/03: fix: Update custom connection field processing (#20883)

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit a8e9aa64069b919dfb06e82b85b5cc38ff4814af
Author: Mike McDonald <30...@users.noreply.github.com>
AuthorDate: Sun Jan 23 16:33:06 2022 -0800

    fix: Update custom connection field processing (#20883)
    
    * fix: Update custom connection field processing
    
    Fixes issue where custom connectionfields are not updated because `extra` field is in form and has previous values, overriding custom field values.
    Adds portion of connection form tests to test functionality.
    
    (cherry picked from commit 44df1420582b358594c8d7344865811cff02956c)
---
 airflow/www/views.py                     | 28 +++++++++++++++++-----------
 tests/www/views/test_views_connection.py | 15 +++++++++++++++
 2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/airflow/www/views.py b/airflow/www/views.py
index d6bc40b..750cbd9 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -3518,19 +3518,17 @@ class ConnectionModelView(AirflowModelView):
         """Process form data."""
         conn_type = form.data['conn_type']
         conn_id = form.data["conn_id"]
-        extra = {
-            key: form.data[key]
-            for key in self.extra_fields
-            if key in form.data and key.startswith(f"extra__{conn_type}__")
-        }
 
-        # If parameters are added to the classic `Extra` field, include these values along with
-        # custom-field extras.
-        extra_conn_params = form.data.get("extra")
+        # The extra value is the combination of custom fields for this conn_type and the Extra field.
+        # The extra form field with all extra values (including custom fields) is in the form being processed
+        # so we start with those values, and override them with anything in the custom fields.
+        extra = {}
+
+        extra_field = form.data.get("extra")
 
-        if extra_conn_params:
+        if extra_field:
             try:
-                extra.update(json.loads(extra_conn_params))
+                extra.update(json.loads(extra_field))
             except (JSONDecodeError, TypeError):
                 flash(
                     Markup(
@@ -3539,11 +3537,19 @@ class ConnectionModelView(AirflowModelView):
                         "<p>If connection parameters need to be added to <em>Extra</em>, "
                         "please make sure they are in the form of a single, valid JSON object.</p><br>"
                         "The following <em>Extra</em> parameters were <b>not</b> added to the connection:<br>"
-                        f"{extra_conn_params}",
+                        f"{extra_field}",
                     ),
                     category="error",
                 )
 
+        custom_fields = {
+            key: form.data[key]
+            for key in self.extra_fields
+            if key in form.data and key.startswith(f"extra__{conn_type}__")
+        }
+
+        extra.update(custom_fields)
+
         if extra.keys():
             form.extra.data = json.dumps(extra)
 
diff --git a/tests/www/views/test_views_connection.py b/tests/www/views/test_views_connection.py
index 249bf2a..d64d261 100644
--- a/tests/www/views/test_views_connection.py
+++ b/tests/www/views/test_views_connection.py
@@ -107,6 +107,21 @@ def test_process_form_extras():
 
     assert json.loads(mock_form.extra.data) == {"extra__test3__custom_field": "custom_field_val3"}
 
+    # Testing parameters set in both extra and custom fields (cunnection updates).
+    mock_form = mock.Mock()
+    mock_form.data = {
+        "conn_type": "test4",
+        "conn_id": "extras_test4",
+        "extra": '{"extra__test4__custom_field": "custom_field_val3"}',
+        "extra__test4__custom_field": "custom_field_val4",
+    }
+
+    cmv = ConnectionModelView()
+    cmv.extra_fields = ["extra__test4__custom_field"]  # Custom field
+    cmv.process_form(form=mock_form, is_created=True)
+
+    assert json.loads(mock_form.extra.data) == {"extra__test4__custom_field": "custom_field_val4"}
+
 
 def test_duplicate_connection(admin_client):
     """Test Duplicate multiple connection with suffix"""

[airflow] 03/03: Set X-Frame-Options header to DENY only if X_FRAME_ENABLED is set to true. (#19491)

Posted by ep...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit a336a6caac0130ba4ebc6f2eb9638473daf8d6af
Author: Kanthi <su...@gmail.com>
AuthorDate: Sat Jan 22 18:09:51 2022 -0500

    Set X-Frame-Options header to DENY only if X_FRAME_ENABLED is set to true. (#19491)
    
    (cherry picked from commit 084079f446570ba43114857ea1a54df896201419)
---
 airflow/www/extensions/init_security.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/airflow/www/extensions/init_security.py b/airflow/www/extensions/init_security.py
index 544deeb..2481a96 100644
--- a/airflow/www/extensions/init_security.py
+++ b/airflow/www/extensions/init_security.py
@@ -35,7 +35,8 @@ def init_xframe_protection(app):
         return
 
     def apply_caching(response):
-        response.headers["X-Frame-Options"] = "DENY"
+        if not x_frame_enabled:
+            response.headers["X-Frame-Options"] = "DENY"
         return response
 
     app.after_request(apply_caching)