I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit f0dd09cf authored by zzz's avatar zzz
Browse files

filter logging

parent 4746d9eb
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,9 @@ import javax.servlet.http.HttpServletRequestWrapper;
//import org.owasp.esapi.ESAPI;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
public class XSSRequestWrapper extends HttpServletRequestWrapper {
// Adapted from https://owasp-esapi-java.googlecode.com/svn/trunk/configuration/esapi/ESAPI.properties
private static Pattern parameterValuePattern = Pattern.compile("^[a-zA-Z0-9.,:\\-\\/+=@_ \r\n]*$");
......@@ -36,14 +39,23 @@ public class XSSRequestWrapper extends HttpServletRequestWrapper {
@Override
public String getParameter(String parameter) {
String value = super.getParameter(parameter);
return stripXSS(value, parameterValuePattern);
String rv = stripXSS(value, parameterValuePattern);
if (value != null && rv == null) {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(XSSRequestWrapper.class);
log.logAlways(Log.WARN, "URL \"" + getServletPath() + "\" Stripped param \"" + parameter + "\" : \"" + value + '"');
}
return rv;
}
@Override
public String getHeader(String name) {
String value = super.getHeader(name);
return stripXSS(value, headerValuePattern);
String rv = stripXSS(value, headerValuePattern);
if (value != null && rv == null) {
Log log = I2PAppContext.getGlobalContext().logManager().getLog(XSSRequestWrapper.class);
log.logAlways(Log.WARN, "URL \"" + getServletPath() + "\" Stripped header \"" + name + "\" : \"" + value + '"');
}
return rv;
}
private String stripXSS(String value, Pattern whitelistPattern) {
......
......@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 21;
public final static long BUILD = 22;
/** for example "-test" */
public final static String EXTRA = "-rc";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment