gpt4 book ai didi

security - 在 web.xml 中设置 'HttpOnly' 和 'Secure'

转载 作者:行者123 更新时间:2023-12-04 10:23:08 25 4
gpt4 key购买 nike

我需要将 'HttpOnly' 和 'Secure' 属性设置为 'true' 以防止 CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' AttributeCWE-402: Transmission of Private Resources into a New Sphere Veracode 报告中显示的缺陷。

网上查了一些,貌似最好的办法是简单的在项目的web.xml文件中设置属性如下:

<session-config>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
</session-config>

但是,我在开始标签上收到一条错误消息,说 "元素类型 "session-config"的内容必须匹配 "(session-timeout)?"

我不确定这到底是什么意思。我猜它与元素的顺序有关,但我真的不知道如何解决它。

有什么想法吗?

谢谢!

最佳答案

对安全和 http-only 属性的支持仅在 http-servlet 规范 3 上可用。检查 web.xml 中的版本属性是“3.0”。

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">

关于security - 在 web.xml 中设置 'HttpOnly' 和 'Secure',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44553017/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com