Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

False Negative : CloseSql.ql cannot detect bugs in the Try-Catch block.

オープン
#21,393 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
java
領域
security

調査の方向性

まず CloseSql.ql の Java リソースリーククエリを読み、createStatement の直接的なケースの処理と Supplier の例の try-catch ブロックを比較します。完了条件は、クエリが supplier.get() によって作成された破棄された Statement を報告し、既存の検出を維持することです。

索引モデルが issue の本文から書いたものです。

説明

question

Version
codeql 2.23.9
Description of the issue
When I used java/Likely Bugs/Resource Leaks/CloseSql.ql to check the following code, it correctly reported an issue of improper use of createStatement.


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class PosCase3 {
    public void test() throws SQLException {
        // Scenario 3: Primary resource assigned
        Connection conn = DriverManager.getConnection("url", "user", "pass");
        // Secondary created from primary, not assigned, not closed
        conn.createStatement(); // [REPORTED LINE]
        // Secondary Statement leak -> Positive detection.
    }
}

However, when using CloseSql.ql to detect the following code, no bug were detected and no bug were reported.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.function.Supplier;
public class PosCase3_Var3 {
    public void test() throws SQLException {
        // Variant 3: Use Supplier to defer creation, then discard
        Connection conn = DriverManager.getConnection("url", "user", "pass");
        Supplier<Statement> supplier = () -> {
            try {
                return conn.createStatement();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        };
        supplier.get();  // Statement created and leaked
    }
}

主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 16時間
マージ済み PR(30日)
143

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

Security の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。