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