更改 Ember.js Addon Dummy App 的 CSP
Changing the CSP of an Ember.js Addon Dummy App
我正在开发一个 ember 插件,利用 PDF.js 和 ember-cli
版本 2.18.2
,我注意到 PDF.js 注入了内联样式. Content-Security-Policy-Report-Only
header 指定 style-src 'self';
,这会导致 ember serve
的日志爆炸,通过仅报告 uri 将 CSP 违规报告给服务器,并显示以下消息:
Content Security Policy violation:
{
"csp-report": {
"document-uri": "http://localhost:4200/tests/index.html?testId=46b61910",
"referrer": "http://localhost:4200/tests/index.html",
"violated-directive": "style-src",
"effective-directive": "style-src",
"original-policy": "default-src 'none'; script-src 'self' localhost:7020 0.0.0.0:7020 undefined:7020; font-src 'self'; connect-src 'self' ws://localhost:7020 ws://0.0.0.0:7020 ws://undefined:7020 http://localhost:4200; img-src 'self'; style-src 'self'; media-src 'self'; report-uri http://localhost:4200/csp-report;",
"disposition": "report",
"blocked-uri": "inline",
"line-number": 5270,
"column-number": 23,
"source-file": "http://localhost:4200/assets/test-support.js",
"status-code": 200,
"script-sample": ""
}
}
鉴于我们正在构建的应用程序将使用此插件控制它们自己的 CSP 并允许内联样式,我想禁用这些警告,但很难找到如何做到这一点。
是否可以在 Ember.js 插件的虚拟应用程序中自定义 report-only CSP?
通过 ember-cli-content-security-policy 插件支持设置 CSP 选项。
在 tests/dummy/config/environment.js
中提供以下配置将防止控制台和服务日志报告内联样式的使用警告:
module.exports = function(environment) {
var ENV = {
...
contentSecurityPolicy: {
'style-src': ["'self'", "'unsafe-inline'"],
...
我正在开发一个 ember 插件,利用 PDF.js 和 ember-cli
版本 2.18.2
,我注意到 PDF.js 注入了内联样式. Content-Security-Policy-Report-Only
header 指定 style-src 'self';
,这会导致 ember serve
的日志爆炸,通过仅报告 uri 将 CSP 违规报告给服务器,并显示以下消息:
Content Security Policy violation:
{
"csp-report": {
"document-uri": "http://localhost:4200/tests/index.html?testId=46b61910",
"referrer": "http://localhost:4200/tests/index.html",
"violated-directive": "style-src",
"effective-directive": "style-src",
"original-policy": "default-src 'none'; script-src 'self' localhost:7020 0.0.0.0:7020 undefined:7020; font-src 'self'; connect-src 'self' ws://localhost:7020 ws://0.0.0.0:7020 ws://undefined:7020 http://localhost:4200; img-src 'self'; style-src 'self'; media-src 'self'; report-uri http://localhost:4200/csp-report;",
"disposition": "report",
"blocked-uri": "inline",
"line-number": 5270,
"column-number": 23,
"source-file": "http://localhost:4200/assets/test-support.js",
"status-code": 200,
"script-sample": ""
}
}
鉴于我们正在构建的应用程序将使用此插件控制它们自己的 CSP 并允许内联样式,我想禁用这些警告,但很难找到如何做到这一点。
是否可以在 Ember.js 插件的虚拟应用程序中自定义 report-only CSP?
通过 ember-cli-content-security-policy 插件支持设置 CSP 选项。
在 tests/dummy/config/environment.js
中提供以下配置将防止控制台和服务日志报告内联样式的使用警告:
module.exports = function(environment) {
var ENV = {
...
contentSecurityPolicy: {
'style-src': ["'self'", "'unsafe-inline'"],
...