We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content-Security-Policy 中文的意思是 网页安全政策,主要用来防止XSS攻击。
通过 Content-Security-Policy 网页的开发者可以控制整个页面中 外部资源 的加载和执行。
比如可以控制哪些 域名下的静态资源可以被页面加载,哪些不能被加载。
这样就可以很大程度的防范了 来自 跨站(域名不同) 的脚本攻击。
它还有个非常响亮的称号:XSS攻击的终结者😄
对于页面开发者来说,只需要在页面中设置
<meta http-equiv="Content-Security-Policy" content="">
类别
script-src
值
下面来个具体的例子:
<meta http-equiv="Content-Security-Policy" content=" default-src http: https: *.meituan.com 'self' 'unsafe-inline' ; style-src 'self' 'unsafe-inline' *.meituan.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' ; ">
http
https
当前域名
*.meituan.com
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Content-Security-Policy介绍
Content-Security-Policy 中文的意思是 网页安全政策,主要用来防止XSS攻击。
如何防范XSS攻击的
通过 Content-Security-Policy 网页的开发者可以控制整个页面中 外部资源 的加载和执行。
比如可以控制哪些 域名下的静态资源可以被页面加载,哪些不能被加载。
这样就可以很大程度的防范了 来自 跨站(域名不同) 的脚本攻击。
它还有个非常响亮的称号:XSS攻击的终结者😄
如何使用
对于页面开发者来说,只需要在页面中设置
类别
script-src
值
下面来个具体的例子:
http
,https
协议资源,信任当前域名
资源,信任符合*.meituan.com
的域名资源当前域名
资源,允许内嵌的CSS资源,信任来自*.meituan.com
下的CSS资源当前域名
资源,允许内嵌的JS执行,允许将字符串当作代码执行参考
The text was updated successfully, but these errors were encountered: