github / github/codeql

[Python] General issue: Wrong domination is reported in control flow analysis

Đang mở
#20,551 1 bình luận 0 reaction 1 người được giao Được @tausbn nhận Xem trên GitHub
question
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ả

**Description of the issue**
I have a python code and ql as follows:
``` python
def EXEC():
raise Exception("Test exception")

def API():
pass

def DUMMY():
pass

try:
EXEC()
API()
except Exception as e:
raise(e)
finally:
DUMMY()
```
``` ql
/**
* @kind problem
* @problem.severity warning
* @id python/find-if
*/

import python

predicate isCall(Call call, string name) {
exists (Name n | call.getFunc() = n and n.getId() = name)
}

from Call callAPI, Call callDummy
where
isCall(callAPI, "API") and isCall(callDummy, "DUMMY") and
not exists (ControlFlowNode nAPI, ControlFlowNode nDummy |
nAPI = callAPI.getAFlowNode() and nDummy = callDummy.getAFlowNode() and
nAPI.dominates(nDummy))
select callAPI, callAPI.toString()
```

The ql code simply check if the call to `API()` does not dominate the call to `DUMMY()`
**Expected Behaviour**: Call to `API()` is reported because `API()` does not dominate `DUMMY()`.
**Actual Result**: nothing is reported

CodeQL version: `CodeQL command-line toolchain release 2.23.1.`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.