[C++] Control Flow Influence not detected interprocedurally
- Lingua principale
- CodeQL
- Stelle
- 10.1k
- Fork
- 2.1k
- Merge medio
- 2g 15h
- PR unite (30g)
- 141
Descrizione
The `controls` predicate from `GuardCondition` does not detect influence across function boundaries. Is this intended behavior?
Here is the code for my example. Influence from `condition` in line 23 is detected but not from line 14.
Similarly the influence on `call()` in line 30 is detected but not on line 8.
```cpp
#include
void call()
{
}
void call_wrapper()
{
call(); // not detected as controlled
}
void check_condition(bool condition)
{
if (condition) // not detected as controlling
{
throw std::exception();
}
}
void my_fn(bool outer, bool condition)
{
if (condition) // detected as controlling
{
throw std::exception();
}
check_condition(condition);
call(); // detected as controlled
call_wrapper();
}
```
```ql
import cpp
import semmle.code.cpp.controlflow.IRGuards
from Variable v, VariableAccess va, GuardCondition cond, Call c, int line
where
c.getTarget().getName() = "call" and
va.getTarget() = v and
v.getName() = "condition" and
cond.getAChild*() = va and
cond.controls(c.getBasicBlock(), _) and
line = va.getLocation().getStartLine()
select v, va, cond, c, line
```
```
| v | va | cond | c | line |
+-----------+-----------+-----------+--------------+------+
| condition | condition | condition | call to call | 23 |
```
CodeQL version: 2.19.3
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Riproduci la query di esempio e ispeziona semmle.code.cpp.controlflow.IRGuards, in particolare GuardCondition.controls e il suo comportamento interprocedurale. Confronta i risultati riportati nelle righe di chiamata e di condizione contrassegnate, quindi verifica i test di controllo del flusso esistenti. Il lavoro è completato quando il comportamento previsto è stabilito e coperto da un test di regressione appropriato oppure documentato come non supportato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100