antisamy java_antisamy的使用方法
標 題: antisamy的使用方法
作 者: 狂逆著風
鏈 接: http://blog.sina.com.cn/s/blog_47d78bed0100wnrs.html antisamy是owasp的開源項目,它用來確保用戶輸入的HTML/CSS符合應用規范的API,可以有效防止xss攻擊
有.net和java兩個版本,.net推薦用antixss來做,請看使用antixss防御xss
antisamy項目地址:
https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project
下載地址:
http://code.google.com/p/owaspantisamy/downloads/list
最新版本下載:http://search.maven.org/?搜索?antisamy 選擇最新版下載即可 我們下載
antisamy-1.4.4.jar
antisamy-required-libs-1.2.zip
antisamy-slashdot-1.4.4.xml
required-libs解壓后,所有jar需要導入項目庫,我直接拷貝到/web-inf/lib下了,antisamy-1.4.4解壓之后的antisamy-1.4.4.jar也拷貝到此目錄
策略文件slashdot.xml放入web路徑
輸入測試代碼
pageEncoding="UTF-8"%>
Insert title hereString id_d = request.getParameter("id");
if(id_d == null)
id_d = "";
Policy policy = Policy.getInstance("D:\\antisamy\\antisamy-slashdot-1.4.4.xml");
AntiSamy as = new AntiSamy();
CleanResults cr = as.scan(id_d, policy);
String id = cr.getCleanHTML();
out.println(id);
%>
id輸入test<>
輸出時被轉義
輸入test
被白名單過濾
總結
以上是生活随笔為你收集整理的antisamy java_antisamy的使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 批量ping工具fping怎么用
- 下一篇: java选择排序解释_选择排序