哪种 CSP 更安全 - style-src 'none' 或 style-src 'unsafe-inline'
What CSP is safer - style-src 'none' or style-src 'unsafe-inline'
我正在努力完全理解 style-src 'none'
。从命名上看,好像是限制性的,还是说没有规则,可以为所欲为?
对于 script-src 'none'
的相同问题,在不太可能的情况下它的行为不同。
旁注 - 如果您正在使用库 styled-components
(所有内容都作为内联注入此库),最好的 CSP 是什么?
编辑:
我之前看过mdn的none
的描述
'none'
Refers to the empty set; that is, no URLs match. The single quotes are required.
这是什么意思?这是否意味着它不会阻止 styles/scripts 或相反?
'none'
的政策来源是最 限制;这意味着 NO 主机有效。
来自我上面引用的link:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
Let's consider a page located at http://example.com/signup.html. It
uses the following policy, disallowing everything but stylesheets from
cdn.example.com.
Content-Security-Policy: default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports
我正在努力完全理解 style-src 'none'
。从命名上看,好像是限制性的,还是说没有规则,可以为所欲为?
对于 script-src 'none'
的相同问题,在不太可能的情况下它的行为不同。
旁注 - 如果您正在使用库 styled-components
(所有内容都作为内联注入此库),最好的 CSP 是什么?
编辑:
我之前看过mdn的none
的描述
'none'
Refers to the empty set; that is, no URLs match. The single quotes are required.
这是什么意思?这是否意味着它不会阻止 styles/scripts 或相反?
'none'
的政策来源是最 限制;这意味着 NO 主机有效。
来自我上面引用的link:
https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
Let's consider a page located at http://example.com/signup.html. It uses the following policy, disallowing everything but stylesheets from cdn.example.com.
Content-Security-Policy: default-src 'none'; style-src cdn.example.com; report-uri /_/csp-reports