github / github/codeql

False Positive: DoNotCallFinalize.ql cannot detect 'finalize()' in the function call chain.

未關閉
#21,394 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**Version**
2.23.9

**Description of the false positive**

When I use java/Violations of Best Practice/Undesirable Calls/DoNotCallFinalize.ql to detect the code as below, it passes normally.
```java
public class NegCase2 {
@Override
protected void finalize() throws Throwable {
// Override of finalize with super.finalize call is allowed.
super.finalize();
}
}

```
However, when I put "super.finalize();" into another function for calling, DoNotCallFinalize.ql reported a problem.
```java
public class NegCase2_Var3 {
// Helper method to encapsulate the call
private void callSuperFinalize() throws Throwable {
super.finalize(); // [REPORTED LINE]
}
@Override
protected void finalize() throws Throwable {
// Delegate to helper
callSuperFinalize();
}
}
```
These two code snippets are essentially the same and should both pass the test.

貢獻指南

開啟貢獻指南

研究方向

從 java/Violations of Best Practice/Undesirable Calls/DoNotCallFinalize.ql 開始,比較它如何處理對 super.finalize() 的直接呼叫與 callSuperFinalize() 內部的相同呼叫。針對兩個程式碼片段執行查詢;當使用輔助方法的版本與直接呼叫得到一致處理且不再被回報時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
java
領域
security
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。