发布于 2019-05-31 10:42:43
在web.xml中配置内容安全策略
您可以使用OWASP
这里提供的建议。它是一个web过滤器,您可以在后端实现。
然后,必须在web.xml
文件中定义以下过滤器。这将在应用程序中的每个请求中被调用。在java中,您可以通过创建一个适当的类来做到这一点。
<filter>
<filter-name>ContentSecurityPolicy</filter-name>
<filter-class>YourPackagePath.ContentSecurityPolicyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ContentSecurityPolicy</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
以上内容将在HTTP报头中实现以下内容安全策略的值
默认-src 'none';样式-src 'self‘不安全-内联’脚本-src‘不安全’-内联‘不安全-eval’;img-src 'self';框架-src 'self';connect src 'self';表单-动作'self';反射-xss块。
发布于 2016-08-31 11:37:22
你试过使用https://github.com/sourceclear/headlines (死链接,这是我所能找到的全部:https://github.com/stevespringett/headlines)吗?它的目标是使与安全相关的标题成为配置问题,而不是像您要求的那样编写代码。
{
"XContentTypeConfig": {
"enabled": true
},
"XFrameOptionsConfig": {
"enabled": true,
"value":"DENY"
},
"XssProtectionConfig": {
"enabled": true
},
"HstsConfig": {
"enabled": true,
"includeSubdomains":true,
"maxAge":31536000
},
"CspConfig": {
"csp": {
"default-src":["'self'"]
},
"cspReportOnly":{}
},
... snip
}
https://stackoverflow.com/questions/39242697
复制相似问题