rusackas commented on code in PR #40587:
URL: https://github.com/apache/superset/pull/40587#discussion_r3685455443
##########
superset/tasks/schemas.py:
##########
@@ -119,14 +119,21 @@ def get_payload_dict(self, obj: object) -> dict[str,
object] | None:
return obj.payload_dict # type: ignore[attr-defined]
def get_properties(self, obj: object) -> dict[str, object]:
- """Get properties dict, filtering stack_trace if SHOW_STACKTRACE is
disabled."""
+ """Get properties dict, filtering debugging details when
SHOW_STACKTRACE
+ is disabled."""
Review Comment:
Good catch, shortened it to one line. The original single-line version was
over the 88-char limit which is why it got wrapped weirdly.
##########
superset/tasks/schemas.py:
##########
@@ -119,14 +119,21 @@ def get_payload_dict(self, obj: object) -> dict[str,
object] | None:
return obj.payload_dict # type: ignore[attr-defined]
def get_properties(self, obj: object) -> dict[str, object]:
- """Get properties dict, filtering stack_trace if SHOW_STACKTRACE is
disabled."""
+ """Get properties dict, filtering debugging details when
SHOW_STACKTRACE
+ is disabled."""
from flask import current_app
properties = dict(obj.properties_dict) # type: ignore[attr-defined]
- # Remove stack_trace unless SHOW_STACKTRACE is enabled
+ # Remove internal debugging details unless SHOW_STACKTRACE is enabled.
+ # The full traceback and the raw exception class name disclose internal
+ # file paths, library versions, and architecture details (CWE-209), so
+ # they are gated behind the same flag that controls stack traces
+ # elsewhere in Superset. ``error_message`` is left in place as the
+ # consumer-facing failure reason.
Review Comment:
Fair, updated properties_description to note exception_type and stack_trace
only show up when SHOW_STACKTRACE is on.
##########
tests/unit_tests/tasks/test_schemas.py:
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from types import SimpleNamespace
+
+from flask import current_app
+from pytest_mock import MockerFixture
+
+from superset.tasks.schemas import TaskResponseSchema
+
+
+def _task_with_error_properties() -> SimpleNamespace:
+ return SimpleNamespace(
+ properties_dict={
+ "is_abortable": True,
+ "progress_percent": 1.0,
+ "error_message": "boom",
+ "exception_type": "KeyError",
+ "stack_trace": 'Traceback (most recent call last):\n File
"/app/x.py"',
+ }
+ )
+
+
+def test_get_properties_hides_debug_fields_by_default(app_context: None) ->
None:
+ """
+ By default (SHOW_STACKTRACE disabled) the serialized task properties must
+ not disclose the stack trace or the raw exception class name (CWE-209),
+ while still returning consumer-safe fields like error_message.
+ """
+ properties =
TaskResponseSchema().get_properties(_task_with_error_properties())
Review Comment:
Fair point, made it explicit with mocker.patch.dict instead of relying on
the config default. The app fixture is module scoped so it wasn't actually
leaking across files, but explicit is better here.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]