rusackas commented on code in PR #43389:
URL: https://github.com/apache/superset/pull/43389#discussion_r3832443258
##########
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:
Fixed — the regex was only stripping the `<script>` opener on an
unterminated tag, leaving the payload text behind. Now drops everything after
an unterminated opener, matching how browsers actually parse it, and the test
asserts the payload is gone.
##########
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 missing 403 response doc to `structure` and
semantic-view `delete`, both of which already raise it.
--
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]