Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome Chrome未报告CSP违规行为_Google Chrome_Content Security Policy - Fatal编程技术网

Google chrome Chrome未报告CSP违规行为

Google chrome Chrome未报告CSP违规行为,google-chrome,content-security-policy,Google Chrome,Content Security Policy,出于某种原因,Chrome(或者至少我的Chrome)没有报告CSP违规。它正确地拒绝显示禁止的内容,但不报告违规行为。作为比较,Firefox报告的违规情况很好 。您的浏览器不应在该页面中显示图像,因为该图像来自禁止的URL。铬合金做得很好。但是,Chrome不遵守report to或report uri指令(我两者都有)。同样,Firefox遵守这些指令 我知道浏览器可能会选择不报告重复的违规行为,但这里的情况并非如此。而且没有一家公司出具报告 我使用的是Chrome版本75.0.3770.

出于某种原因,Chrome(或者至少我的Chrome)没有报告CSP违规。它正确地拒绝显示禁止的内容,但不报告违规行为。作为比较,Firefox报告的违规情况很好

。您的浏览器不应在该页面中显示图像,因为该图像来自禁止的URL。铬合金做得很好。但是,Chrome不遵守report to或report uri指令(我两者都有)。同样,Firefox遵守这些指令

我知道浏览器可能会选择不报告重复的违规行为,但这里的情况并非如此。而且没有一家公司出具报告

我使用的是Chrome版本75.0.3770.90(官方版本)(64位)


非常感谢您的帮助。

您可以收听“securitypolicyviolation”事件并手动报告

if(window.chrome/*在未报告问题得到修复之前*){
让我们来看看http://localhost:8080/api/csp-报告';
文件。添加的文件列表器('securitypolicyviolation',(e)=>{
让data=JSON.stringify({
“csp报告”:{
“blocked uri”:e.blockedURI,
“文档uri”:e.documentURI,
“原始政策”:即原始政策,
“推荐人”:例如推荐人,
“脚本示例”:例如,
“源文件”:e.sourceFile,
“违反指令”:例如,违反指令
}
});
获取(reportUri{
方法:“POST”,
标题:{
“内容类型”:“应用程序/csp报告”
},
正文:数据,
凭证:“省略”,
缓存:“无缓存”,
推荐人政策:“无推荐人”
});
});
}

Chrome 76.0.3809.100版也有同样的问题。另外,根据页面Firefox不支持
报告到
,只支持
报告uri
,所以我猜Firefox只是在使用这个。Chrome同时支持这两种功能,只有使用
报告uri
才能在Chrome中工作。当我将
报告添加到
时,尽管它停止工作。我怀疑当同时使用这两种浏览器时,Chrome会忽略
报告uri
,而偏爱
报告对象
,这显然是有缺陷的,导致它什么都不做。从Chrome 89开始,报告对象似乎仍然被破坏: