org.owasp.validator.html
Class AntiSamy

java.lang.Object
  extended by org.owasp.validator.html.AntiSamy

public class AntiSamy
extends Object

This is the only class from which the outside world should be calling. The scan() method holds the meat and potatoes of AntiSamy. The file contains a number of ways for scan()'ing depending on the accessibility of the policy file.

Author:
Arshan Dabirsiaghi

Constructor Summary
AntiSamy()
           
 
Method Summary
static void main(String[] args)
          Main method for testing AntiSamy.
 CleanResults scan(String taintedHTML)
          The meat and potatoes.
 CleanResults scan(String taintedHTML, File policyFile)
          This method wraps scan() using the policy File object passed in.
 CleanResults scan(String taintedHTML, Policy policy)
          This method wraps scan() using the Policy object passed in.
 CleanResults scan(String taintedHTML, String filename)
          This method wraps scan() using the Policy object passed in.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AntiSamy

public AntiSamy()
Method Detail

scan

public CleanResults scan(String taintedHTML)
                  throws ScanException,
                         PolicyException
The meat and potatoes. The scan() family of methods are the only methods the outside world should be calling to invoke AntiSamy.

Parameters:
taintedHTML - Untrusted HTML which may contain malicious code.
Returns:
A CleanResults object which contains information about the scan (including the results).
Throws:
ScanException - When there is a problem encountered while scanning the HTML.
PolicyException - When there is a problem reading the policy file.
ScanException
PolicyException

scan

public CleanResults scan(String taintedHTML,
                         Policy policy)
                  throws ScanException,
                         PolicyException
This method wraps scan() using the Policy object passed in.

Throws:
ScanException
PolicyException

scan

public CleanResults scan(String taintedHTML,
                         String filename)
                  throws ScanException,
                         PolicyException
This method wraps scan() using the Policy object passed in.

Throws:
ScanException
PolicyException

scan

public CleanResults scan(String taintedHTML,
                         File policyFile)
                  throws ScanException,
                         PolicyException
This method wraps scan() using the policy File object passed in.

Throws:
ScanException
PolicyException

main

public static void main(String[] args)
Main method for testing AntiSamy.

Parameters:
args - Command line arguments. Only 1 argument is processed, and it should be a URL or filename to run through AntiSamy using the default policy location.