rusackas commented on code in PR #43389:
URL: https://github.com/apache/superset/pull/43389#discussion_r3832415256


##########
superset/semantic_layers/api.py:
##########
@@ -672,6 +675,11 @@ def runtime_schema(self, uuid: str) -> FlaskResponse:
         if not layer:
             return self.response_404()
 
+        try:
+            layer.raise_for_access()
+        except SupersetSecurityException as ex:
+            return self.response(403, message=ex.message)

Review Comment:
   Good catch, added the 403 response docs to the OpenAPI schema.



##########
superset/commands/theme/import_themes.py:
##########
@@ -44,6 +44,11 @@ def import_theme(config: dict[str, Any], overwrite: bool = 
False) -> "Theme | No
     if existing:
         if not overwrite or not can_write:
             return existing
+        if existing.is_system or existing.is_system_default or 
existing.is_system_dark:
+            raise ThemeImportError(
+                "Cannot overwrite a system theme or the active "
+                "system-default/dark theme via import"
+            )

Review Comment:
   Good catch, mirrored UpdateThemeCommand's own admin carve-out here so admins 
can still overwrite the active system theme via import.



##########
tests/unit_tests/utils/test_core.py:
##########
@@ -1942,13 +1942,28 @@ def test_sanitize_svg_content_safe():
 
 
 def test_sanitize_svg_content_removes_scripts():
-    """Test that nh3 removes dangerous script content."""
+    """Test that dangerous script content is removed."""
     malicious_svg = '<svg><script>alert("xss")</script><rect/></svg>'
     result = sanitize_svg_content(malicious_svg)
     assert "script" not in result.lower()
     assert "alert" not in result
 
 
+def test_sanitize_svg_content_removes_script_with_attributes_on_closer():
+    """A closing </script foo> tag is still a valid closer to browsers."""
+    malicious_svg = "<svg><script>fetch('/api/v1/me/')</script foo></svg>"
+    result = sanitize_svg_content(malicious_svg)
+    assert "script" not in result.lower()
+    assert "fetch" not in result
+
+
+def test_sanitize_svg_content_removes_unterminated_script():
+    """An unterminated <script> opener with no closing tag is still 
stripped."""
+    malicious_svg = "<svg><script>alert('xss')"
+    result = sanitize_svg_content(malicious_svg)
+    assert "script" not in result.lower()

Review Comment:
   Traced the sanitizer behavior here - once the tag markers are stripped the 
payload is left as inert plain text, not re-parsed as markup, so it's safe 
as-is. Asserting full text removal would actually be the wrong expectation. 
Leaving this one.



-- 
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]

Reply via email to