vsp*_*vsp 5 security tomcat clickjacking content-security-policy
我阅读了有关配置/实现Content-Security-Policy标头的信息,并且遇到了两种实现方法:
请注意,这个问题是不能重复的这个,荫寻找一个更好的解决方案比在给定的这个链接
我看到(1)中的缺点是通过代码驱动的,而不是通过配置文件驱动的,选项(2)中的缺点是,如果我说有100个html文件,则需要在每个HTML中放入此标记吗?(如果我错了,请纠正我)我正在寻找的解决方案是可以在web.xml中配置的东西,并且适用于所有html文件。这是我们在web.xml中配置X-框架,选项的情况下做这样给出的方式在这里,我们不是已经在web.xml配置内容安全,政策的类似的方式?
您可以使用OWASP 此处提供的建议。它是一个可以在后端实现的网络过滤器。
然后必须在您的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>
Run Code Online (Sandbox Code Playgroud)
以上将在您的 HTTP 标头中为 content-security-policy 实现以下值
默认-src '无'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src '自我'; frame-src '自我'; 连接-src '自我'; 形式动作“自我”;反射 xss 块
您是否尝试过使用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
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10010 次 |
| 最近记录: |