Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar committed Nov 7, 2022
1 parent d32195c commit 112f414
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion superset/utils/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def is_safe_url(url: str) -> bool:
return False
if unicodedata.category(url[0])[0] == "C":
return False
if test_url.scheme not in ("http", "https") or ref_url.netloc != test_url.netloc:
if test_url.scheme != ref_url.scheme or ref_url.netloc != test_url.netloc:
return False
return True
2 changes: 1 addition & 1 deletion superset/views/datasource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def save(self) -> FlaskResponse:
"The submitted URL is not considered safe,"
" only use URLs with the same domain as Superset."
),
status=500,
status=400,
)

orm_datasource = DatasourceDAO.get_datasource(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/datasource_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def test_save_default_endpoint_validation_fail(self):
datasource_post["default_endpoint"] = "http://www.google.com"
data = dict(data=json.dumps(datasource_post))
resp = self.client.post("/datasource/save/", data=data)
assert resp.status_code == 500
assert resp.status_code == 400

def test_save_default_endpoint_validation_unsafe(self):
self.app.config["PREVENT_UNSAFE_DEFAULT_URLS_ON_DATASET"] = False
Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests/utils/urls_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ def test_convert_dashboard_link() -> None:
[
("http://localhost/", True),
("http://localhost/superset/1", True),
("https://localhost/", False),
("https://localhost/superset/1", False),
("localhost/superset/1", False),
("ftp://localhost/superset/1", False),
("http://external.com", False),
("https://external.com", False),
("external.com", False),
("///localhost", False),
("xpto://localhost:[3/1/", False),
Expand Down

0 comments on commit 112f414

Please sign in to comment.