False Positive: DoNotCallFinalize.ql cannot detect 'finalize()' in the function call chain.
- Linguagem predominante
- CodeQL
- Estrelas
- 10.1k
- Forks
- 2.1k
- Merge médio
- 2d 15h
- PRs com merge (30d)
- 141
Descrição
**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.
Guia de contribuição
Direção de pesquisa
Start with java/Violations of Best Practice/Undesirable Calls/DoNotCallFinalize.ql and compare how it handles the direct super.finalize() call with the same call inside callSuperFinalize(). Run the query against both snippets; done means the helper-method version is treated consistently with the direct call and is no longer reported.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- security
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 55/100