我正在尝试通过使用 struts 1.3.8 的应用程序来实现 HDIV。我在 pom 文件和监听器中添加了依赖项,在 web.xml 文件中进行了过滤。
令牌_HDIV_STATE_被注入每个页面,链接..所以为了测试它是否按预期工作以对抗CSRF攻击,我在应用程序外部制作了一个小html页面,将数据发送到应用程序以修改一些数据以模拟CSRF攻击。
不幸的是,测试成功了,因为目标数据被修改了。当我检查日志时,似乎 HDIV 检测到该请求不包含 _HDIV_STATE_ 但它没有取消它并重定向到错误页面或其他内容。
我的配置是错的,还是我不明白请求中不存在令牌时 HDIV 会做什么?
谢谢你的帮助
pom.xml:
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-config</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-struts-1</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.hdiv</groupId>
<artifactId>hdiv-jstl-taglibs-1.2</artifactId>
<version>2.1.12</version>
</dependency>
web.xml
<listener>
<listener-class>org.hdiv.listener.InitListener</listener-class>
</listener>
<filter>
<filter-name>ValidatorFilter</filter-name>
<filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ValidatorFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-html-el.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/hdiv-html-el.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-logic-el.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/hdiv-logic-el.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/c.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/hdiv-c.tld</taglib-location>
</taglib>
</jsp-config>
hdiv-config.hml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hdiv="http://www.hdiv.org/schema/hdiv"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.hdiv.org/schema/hdiv
http://www.hdiv.org/schema/hdiv/hdiv.xsd">
<hdiv:config excludedExtensions="css,png,gif,jpeg,jpg,js" errorPage="/error.jsp"
maxPagesPerSession="2" debugMode="true">
<hdiv:sessionExpired loginPage="/index.jsp" homePage="/"/>
<hdiv:startPages>/index.jsp</hdiv:startPages>
</hdiv:config>
</beans>