简体   繁体   English

Java:Owasp AntiSamy vs Owasp-java-html-sanitize

[英]Java: Owasp AntiSamy vs Owasp-java-html-sanitize

I am looking for html purifier library now. 我现在正在寻找html净化器库。 And I've found that there are two "owasp" library. 而且我发现有两个“owasp”库。 First is https://code.google.com/p/owasp-java-html-sanitizer/ and the second is https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project . 首先是https://code.google.com/p/owasp-java-html-sanitizer/ ,第二个是https://www.owasp.org/index.php/Category:OWASP_AntiSamy_Project

My question is - what are pros and cons when comparing them. 我的问题是 - 比较它们时的利弊是什么。

OWASP java html sanitizer is newer project than antisamy. OWASP java html sanitizer是比antiisamy更新的项目。 Goals of these projects are the same - sanitizing HTML to prevent XSS and filter out other unwanted content. 这些项目的目标是相同的 - 清理HTML以防止XSS并过滤掉其他不需要的内容。 However their approach is different. 然而他们的方法是不同的。 Every approach has its tradeoffs so you should choose the solution depending on your requirements. 每种方法都有其权衡,因此您应根据自己的要求选择解决方案。 In a nutshell html sanitizer is simpler to use and faster, on the other hand it is less flexible. 简而言之,html消毒剂使用起来更简单,速度更快,另一方面它的灵活性较低。 However it should be good enough for most users. 但是对于大多数用户来说它应该足够好了。 Note that antisamy can process not only html but also css. 请注意,antisamy不仅可以处理html,还可以处理css。

Here is message from owasp mailing lists requesting creation of HTML sanitizer project, including list of some of its advantages and differences from antisamy. 以下是来自owasp邮件列表的消息 ,请求创建HTML清理程序项目,包括其中一些优点的列表以及与antisamy的差异。

I would like to start a new OWASP project that is very similar to AntiSamy. 我想开始一个与AntiSamy非常相似的新OWASP项目。

I would like to call this project the "OWASP Java HTML Sanitizer" and have code available already at: 我想将此项目称为“OWASP Java HTML Sanitizer”,并且已在以下位置提供代码:

https://code.google.com/p/owasp-java-html-sanitizer/ https://code.google.com/p/owasp-java-html-sanitizer/

This is code from the Caja project that was donated by Google. 这是由Google捐赠的Caja项目的代码。 It is rather high performance and low memory utilization. 它具有相当高的性能和低内存利用率。

  1. This code provides 4X the speed of AntiSamy sanitization in DOM mode and 2X the speed of AntiSamy in SAX mode 此代码提供DOM模式下AntiSamy清理速度的4倍,SAX模式下AntiSamy速度的2倍
  2. Very easy to use. 非常好用。 It allows for simple programmatic POSITIVE policy configuration (see below). 它允许简单的编程POSITIVE策略配置(见下文)。 No XML config. 没有XML配置。
  3. It does not suffer from the various security flaws that the Niko HTML parser brought with it 它没有遭受Niko HTML解析器带来的各种安全漏洞
  4. Actively maintained by myself and Mike Samuel from Google's AppSec team 由我自己和来自Google AppSec团队的Mike Samuel积极维护
  5. Already passing 80% of AntiSamy's unit tests plus many more . 已经超过80%的AntiSamy单元测试加上更多
  6. Only 3 dependent jar files 只有3个相关的jar文件
  7. This is a pure Java 6 project and does not support Java 5 or below ( Please note AntiSamy supports 1.4+ ). 这是一个纯Java 6项目,不支持Java 5或更低版本(请注意AntiSamy支持1.4+)。

We are currently at Alpha right now - but will be production ready and soon. 我们目前正在阿尔法,但很快就会投入生产。

Sample programmatic policy example: 示例性程序策略示例:

  // A VERY SIMPLE WHITELISTING POLICY final ImmutableSet<String> okTags = ImmutableSet.of( "a", "b", "br", "div", "i", "img", "input", "li", "ol", "p", "span", "ul"); final ImmutableSet<String> okAttrs = ImmutableSet.of( "div", "checked", "class", "href", "id", "target", "title", "type"); 

What do you think? 你怎么看? Is a little respectful competition a good thing? 是一个有点尊重的竞争是一件好事吗?

  • Jim 吉姆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM