False Negative: ContinueInFalseLoop.ql misses `do ... while(false)` loops once `false` is stored in a local.
还没有人认领这个 Issue。
评估
调研方向
从 Likely Bugs/Statements/ContinueInFalseLoop.ql 开始,检查它在 false 存储于局部变量中时如何评估 do-loop 条件。查看受影响的 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 小时
- 30 天内合并 PR
- 143
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/codeql 的其他 Issue
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 70/100
-
false-positive javascript
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 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 ·