github / github/codeql

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

未關閉
#20,551 1 則留言 0 個 reaction 已指派 1 人 已被 @tausbn 認領 在 GitHub 檢視
question
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**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.`

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。