I use Eclipse to develop my web project,and use HP fortify scan my JAVA source code. The report show that I have 7200 A1 Inject issue(Log forging).
the sample code show logger.info will cause log forging
public void storedProcedure(HttpServletResponse response,
@RequestParam("idn") String idn,
@RequestParam("agentNo")String agentNo){
logger.info("call idn :" + idn + ",agentNo="+agentNo); // log forging
}
And then,I find a solution use Spring framework HtmlUtil to escape but too many code Scattered anywhere. I want to change to logger for
logger.info("call idn :" + HtmlUtil.htmlEscape(idn)
",agentNo=" + HtmlUtil.htmlEscape(agentNo));
How can I use regular expression to find the line start with logger.info and find all the "+" variables replace HtmlUtil.htmlEscpse(variable)
?