Skip to content

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

@Ang9876

Description

@Ang9876

Description of the issue
I have a python code and ql as follows:

def EXEC():
    raise Exception("Test exception")

def API():
    pass

def DUMMY():
    pass

try:
    EXEC()
    API()
except Exception as e:
    raise(e)
finally:
    DUMMY()
/**
 * @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.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions