Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tensorboard/backend/http_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# @vaadin/vaadin-lumo-styles/font-icons(via vaadin-grid) uses data URI for
# loading font icons.
_CSP_FONT_DOMAINS_WHITELIST = ["data:"]
_CSP_FRAME_DOMAINS_WHITELIST = []
_CSP_FRAME_DOMAINS_WHITELIST = ["https://ui.perfetto.dev"]
_CSP_IMG_DOMAINS_WHITELIST = []
_CSP_SCRIPT_DOMAINS_WHITELIST = []
_CSP_CONNECT_DOMAINS_WHITELIST = []
Expand Down
50 changes: 35 additions & 15 deletions tensorboard/backend/http_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,14 @@ def testCsp(self):
q, "<b>hello</b>", "text/html", csp_scripts_sha256s=["abcdefghi"]
)
expected_csp = (
"default-src 'self';font-src 'self' data:;"
"frame-src 'self';img-src 'self' data: blob:;object-src 'none';"
"default-src 'self';"
"font-src 'self' data:;"
"frame-src 'self' https://ui.perfetto.dev;"
"img-src 'self' data: blob:;"
"object-src 'none';"
"style-src 'self' https://www.gstatic.com data: 'unsafe-inline';"
"connect-src 'self';script-src 'self' 'unsafe-eval' 'sha256-abcdefghi'"
"connect-src 'self';"
"script-src 'self' 'unsafe-eval' 'sha256-abcdefghi'"
)
self.assertEqual(r.headers.get("Content-Security-Policy"), expected_csp)

Expand All @@ -243,10 +247,14 @@ def testCsp_noHash(self):
q, "<b>hello</b>", "text/html", csp_scripts_sha256s=None
)
expected_csp = (
"default-src 'self';font-src 'self' data:;"
"frame-src 'self';img-src 'self' data: blob:;object-src 'none';"
"default-src 'self';"
"font-src 'self' data:;"
"frame-src 'self' https://ui.perfetto.dev;"
"img-src 'self' data: blob:;"
"object-src 'none';"
"style-src 'self' https://www.gstatic.com data: 'unsafe-inline';"
"connect-src 'self';script-src 'unsafe-eval'"
"connect-src 'self';"
"script-src 'unsafe-eval'"
)
self.assertEqual(r.headers.get("Content-Security-Policy"), expected_csp)

Expand All @@ -258,10 +266,14 @@ def testCsp_noHash_noUnsafeEval(self):
q, "<b>hello</b>", "text/html", csp_scripts_sha256s=None
)
expected_csp = (
"default-src 'self';font-src 'self' data:;"
"frame-src 'self';img-src 'self' data: blob:;object-src 'none';"
"default-src 'self';"
"font-src 'self' data:;"
"frame-src 'self' https://ui.perfetto.dev;"
"img-src 'self' data: blob:;"
"object-src 'none';"
"style-src 'self' https://www.gstatic.com data: 'unsafe-inline';"
"connect-src 'self';script-src 'none'"
"connect-src 'self';"
"script-src 'none'"
)
self.assertEqual(r.headers.get("Content-Security-Policy"), expected_csp)

Expand All @@ -273,10 +285,14 @@ def testCsp_onlySelf(self):
q, "<b>hello</b>", "text/html", csp_scripts_sha256s=None
)
expected_csp = (
"default-src 'self';font-src 'self' data:;"
"frame-src 'self';img-src 'self' data: blob:;object-src 'none';"
"default-src 'self';"
"font-src 'self' data:;"
"frame-src 'self' https://ui.perfetto.dev;"
"img-src 'self' data: blob:;"
"object-src 'none';"
"style-src 'self' https://www.gstatic.com data: 'unsafe-inline';"
"connect-src 'self';script-src 'self'"
"connect-src 'self';"
"script-src 'self'"
)
self.assertEqual(r.headers.get("Content-Security-Policy"), expected_csp)

Expand All @@ -287,10 +303,14 @@ def testCsp_disableUnsafeEval(self):
q, "<b>hello</b>", "text/html", csp_scripts_sha256s=["abcdefghi"]
)
expected_csp = (
"default-src 'self';font-src 'self' data:;"
"frame-src 'self';img-src 'self' data: blob:;object-src 'none';"
"default-src 'self';"
"font-src 'self' data:;"
"frame-src 'self' https://ui.perfetto.dev;"
"img-src 'self' data: blob:;"
"object-src 'none';"
"style-src 'self' https://www.gstatic.com data: 'unsafe-inline';"
"connect-src 'self';script-src 'self' 'sha256-abcdefghi'"
"connect-src 'self';"
"script-src 'self' 'sha256-abcdefghi'"
)
self.assertEqual(r.headers.get("Content-Security-Policy"), expected_csp)

Expand Down
Loading