Checkmarx将以下代码段指示为sql注入漏洞。Checkmarx突出显示代码为sqlinjection漏洞
在checkmarx报告descibe下面的代码片断如下所示
“从的readLine元素获得的用户输入。该元素的值然后 流经代码没有被正确过滤或验证 这可以使SQL注入攻击“
为简洁起见,我还未包含全文。
InputStreamReader isr = null;
BufferedReader br = null;
try{
ClassPathResource defaultReports = new ClassPathResource(dbVendor + "/sql_inserts.sql");
isr = new InputStreamReader(defaultReports.getInputStream());
br = new BufferedReader(isr);
c = session.connection();
String sqlLine = null;
while((sqlLine = br.readLine()) != null) {
sqlLine = sqlLine.trim();
Statement st = null;
try{
st = c.createStatement();
st.execute(sqlLine);
}catch(SQLException e){
}catch(Exception e){
}finally{
if (st != null)
st.close();
}
}
}
//sql_inserts.sql文件包含设置插入语句
我想上面的代码转换为checkmarx友好way.After认为勾选不应该强调的代码片段高达SQL注入漏洞的。
根据发布的代码,“这些查询的来源究竟是什么” - 类路径。 – Trejkaz