False Positive: DoNotCallFinalize.ql cannot detect 'finalize()' in the function call chain.
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
**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.
Beitragsleitfaden
Rechercherichtung
Beginne mit java/Violations of Best Practice/Undesirable Calls/DoNotCallFinalize.ql und vergleiche, wie der direkte Aufruf von super.finalize() im Vergleich zu demselben Aufruf innerhalb von callSuperFinalize() behandelt wird. Führe die Abfrage für beide Snippets aus; abgeschlossen ist die Aufgabe, wenn die Version mit der Hilfsmethode konsistent mit dem direkten Aufruf behandelt und nicht mehr gemeldet wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- security
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100