Skip to content
Draft
Prev Previous commit
Next Next commit
Add captured call target diagnostic
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
  • Loading branch information
yoff and Copilot committed Aug 25, 2026
commit a529a03c5670ddfc0cba8f946f30513ab887ca93
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| test.py:14:13:14:38 | Attribute() | test.py:3:5:3:25 | Function compile | CallTypeStaticMethod |
| test.py:14:13:14:38 | Attribute() | test.py:9:5:9:25 | Function compile | CallTypeStaticMethod |
| test.py:23:16:23:21 | func() | test.py:29:1:29:12 | Function first | CallTypePlainFunction |
| test.py:23:16:23:21 | func() | test.py:34:1:34:13 | Function second | CallTypePlainFunction |
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import python
private import semmle.python.controlflow.internal.Cfg as Cfg
private import semmle.python.dataflow.new.internal.DataFlowDispatch as Dispatch

from Call call, Function target, Dispatch::CallType callType
where
exists(Cfg::CallNode cfgCall |
cfgCall.getNode() = call and
Dispatch::resolveCall(cfgCall, target, callType)
) and
call.getLocation().getFile().getRelativePath() = "test.py" and
target.getLocation().getFile().getRelativePath() = "test.py" and
(
call.getFunc().(Name).getId() = "func"
or
call.getFunc().(Attribute).getName() = "compile"
)
select call, target, callType.toString()
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class RegexRule:
@staticmethod
def compile(pattern):
return pattern


class GlobRule:
@staticmethod
def compile(pattern):
return pattern


def compile_rules(rule_type, patterns):
return [rule_type.compile(pattern) for pattern in patterns]


compile_rules(RegexRule, ["x"])
compile_rules(GlobRule, ["*"])


def decorate(func):
def wrapper():
return func()

return wrapper


@decorate
def first():
return 1


@decorate
def second():
return 2


first()
second()