IBM Appscan源扫描程序在以下源中检测到AppDOS.ConnectionClose漏洞。

我通过在finally块中关闭连接来解决此问题,但仍报告相同。有没有关闭数据库连接的模式?

Connection nCnn = null;

try
{
    nCnn = getConnection();

    /* some database operation */


    nCnn.close() /* Reporting AppDOS.ConnectionClose vulnerability */


} catch (Exception e) {
    throw new SQLException("Connection close", e);
}
finally
{
    try {
        if (nCnn != null)

            nCnn.close(); /* Reporting AppDOS.ConnectionClose vulnerability */

    }
    catch (Exception e) {
        logger.error(e);
    }

}

最佳答案

您的修补程序应该可以缓解此问题。修复后,Appscan Source仍在报告问题的事实很可能是缺陷。 Appscan Source的缓解措施示例如下:

try
{
    Connection connection = DriverManager.getConnection(some_connection_string);
} catch (Exception e) {
    log(e);
} finally {
    connection.close();
}

10-05 17:56