False Negative: ContinueInFalseLoop.ql misses `do ... while(false)` loops once `false` is stored in a local.
まだ誰も着手していません。
評価
調査の方向性
Likely Bugs/Statements/ContinueInFalseLoop.ql から始め、false がローカル変数に格納されている場合に do ループの条件をどのように評価するかを確認します。影響を受ける PosCase1_Var1.java と PosCase1_Var5.java のケースを確認し、その後 checker のテストを実行して、既存のリテラル false の動作が引き続きカバーされたまま、両方のケースが指摘されることを確認します。
索引モデルが issue の本文から書いたものです。
説明
False Negative: ContinueInFalseLoop.ql misses do ... while(false) loops once false is stored in a local.
Version
codeql 2.24.3
Checker
- Checker id:
Likely Bugs/Statements/ContinueInFalseLoop.ql - Checker description: This checker detects a 'continue' statement inside a 'do' loop whose condition is always false, meaning the continue will never actually re-run the loop body.
Description of the false negative
Both samples are still do loops whose condition is false and therefore cannot loop back after continue. The only difference is that the literal false is first assigned to a local variable.
That should still be a direct hit for Likely Bugs/Statements/ContinueInFalseLoop.ql.
Affected test cases
PosCase1_Var1.java
never is a constant false value, so the continue still cannot re-enter the loop body.
// A do loop with a literal false condition contains a continue statement targeting that same loop should be flagged as a positive case.
package scensct.var.pos;
public class PosCase1_Var1 {
public static void main(String[] args) {
final boolean never = false;
do {
// continue inside do with false condition
continue;
} while (never);
}
}
PosCase1_Var5.java
flag is initialized from Boolean.FALSE and never changed. This is still the same impossible loop-back case.
// A do loop with a literal false condition contains a continue statement targeting that same loop should be flagged as a positive case.
package scensct.var.pos;
public class PosCase1_Var5 {
public static void main(String[] args) {
boolean flag = Boolean.FALSE;
do {
// continue inside do with false condition
continue;
} while (flag);
}
}
Cause analysis
The miss is surprisingly basic. The query appears to require a literal false at the loop condition and loses the result as soon as that same value is stored in a local.
For developers, these are the same bug. Whether the condition is written as while (false) or while (never) should not matter.
References
None known.
- 主要言語
- CodeQL
- スター
- 10.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 143
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
github/codeql のほかの issue
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
false-positive javascript
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
C#: cs/simplifiable-boolean-expression false positive on Nullable<bool> compared with a literal オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
false-positive
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
palladius/rails8-app-on-gcp#145 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
elastic/gradle-plugins#156 ·
-
area:workflow bug ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
fil-donadoni/tolaria#4409 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotenvx/dotenv-vscode#139 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Fission-AI/OpenSpec#1960 ·