[C++] Control Flow Influence not detected interprocedurally
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
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
Hướng dẫn đóng góp
Hướng nghiên cứu
Tái hiện truy vấn ví dụ và kiểm tra semmle.code.cpp.controlflow.IRGuards, đặc biệt là GuardCondition.controls và hành vi liên thủ tục của nó. So sánh các kết quả được báo cáo tại các dòng gọi và dòng điều kiện được đánh dấu, sau đó kiểm tra các bài kiểm thử luồng điều khiển hiện có. Được xem là hoàn tất khi hành vi dự kiến đã được xác lập và được bao phủ bởi một bài kiểm thử hồi quy phù hợp hoặc được ghi lại là không được hỗ trợ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- cpp
- Lĩnh vực
- devtools
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100