如何在遵守 script-src 的严格内容安全策略的同时让 KendoUI 正常运行
How can I get KendoUI to function while adhering to strict Content Security Policy for script-src
我有一个大型 Web 应用程序,在尝试实施内容安全策略时遇到了一个问题。为了重现,我创建了一个非常基本的页面,如下所述。 KendoUI 失败了。我已将其缩小为 CSP 问题,特别是 KendoUI 在启用 'unsafe-eval' 时运行良好,但在禁用时运行良好,当然这是一个严重的问题,所以我想知道我是否使用了错误的构建或我遗漏了什么?
演示问题的粗略演示(header 值是通过元标记插入的):
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://cdn.kendostatic.com https://code.jquery.com;">
<script src="https://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript" ></script>
<script src="https://cdn.kendostatic.com/2015.3.930/js/kendo.web.min.js" type="text/javascript" ></script>
</head>
<body>
<h1>See CSP Error in console</h1>
</body>
我使用这个 header 得到 CSP 错误:
Content-Security-Policy: script-src 'self' https://cdn.kendostatic.com https://code.jquery.com;
只要我将 "unsafe-eval" 添加到 script-src 选项,错误就会消失,但这似乎是不可接受的,并且可能是一个常见问题,因为 kendoui 是一个广泛使用的框架。
通过与 Telerik 的进一步对话,我得到了以下回复:
Kendo UI uses eval() calls internally. This is how the Kendo UI templates work internally. Currently we do not have a workaround, but we are in a process of exploring new ways for rendering of the Kendo UI widgets, which will comply with this policy as well.
我有一个大型 Web 应用程序,在尝试实施内容安全策略时遇到了一个问题。为了重现,我创建了一个非常基本的页面,如下所述。 KendoUI 失败了。我已将其缩小为 CSP 问题,特别是 KendoUI 在启用 'unsafe-eval' 时运行良好,但在禁用时运行良好,当然这是一个严重的问题,所以我想知道我是否使用了错误的构建或我遗漏了什么?
演示问题的粗略演示(header 值是通过元标记插入的):
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="script-src 'self' https://cdn.kendostatic.com https://code.jquery.com;">
<script src="https://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript" ></script>
<script src="https://cdn.kendostatic.com/2015.3.930/js/kendo.web.min.js" type="text/javascript" ></script>
</head>
<body>
<h1>See CSP Error in console</h1>
</body>
我使用这个 header 得到 CSP 错误:
Content-Security-Policy: script-src 'self' https://cdn.kendostatic.com https://code.jquery.com;
只要我将 "unsafe-eval" 添加到 script-src 选项,错误就会消失,但这似乎是不可接受的,并且可能是一个常见问题,因为 kendoui 是一个广泛使用的框架。
通过与 Telerik 的进一步对话,我得到了以下回复:
Kendo UI uses eval() calls internally. This is how the Kendo UI templates work internally. Currently we do not have a workaround, but we are in a process of exploring new ways for rendering of the Kendo UI widgets, which will comply with this policy as well.