接口介绍
正向调用查询:给定一个方法的全限定名,返回该方法体内直接调用到的所有方法清单(被调方),并对接口/抽象类调用按需展开成实际可能的实现方法。
工具名
find_callees_by_method_name
背景与目标
查找调用点(callers)是反向问题,本工具是正向(我调了谁)。两者合起来才能完成调用图遍历。
应用场景:
- 看 Controller 一个 endpoint 直接/间接到达了哪些 DAO,判断是否绕过了权限层
- 看一个
@Transactional 方法内部是否调用了不该跨事务的远程方法
- 一次审计任务从 sink 反推 source,需要 callees 配合
输入参数
| 参数 |
类型 |
必填 |
说明 |
method_full_name |
string |
是 |
调用方法的全限定名 |
parameter_types |
string[] |
否 |
形参类型重载消歧 |
repository_path |
string |
是 |
仓库本地绝对路径 |
resolve_polymorphic |
bool |
否 |
默认 true。true 时把"接口调用"展开成所有可能实现 |
include_jdk_calls |
bool |
否 |
默认 false。是否把对 java.* 等标准库的调用也算上 |
max_depth |
int |
否 |
默认 1。本工具默认只看一层(直接被调);深层调用链请用上游链路工具 |
输出结构
{
"source_method": "com.example.service.UserService.getUserOrThrow",
"total_callees": 4,
"callees": [
{
"callee_method_full_name": "com.example.dao.UserDao.findById",
"callee_signature": "findById(java.lang.Long): com.example.User",
"call_site_line": 47,
"call_site_snippet": "userDao.findById(id)",
"is_polymorphic_resolved": false,
"resolved_implementations": null,
"is_jdk_call": false
},
{
"callee_method_full_name": "com.example.RequestValidator.validate",
"is_polymorphic_resolved": true,
"resolved_implementations": [
"com.example.impl.JsonRequestValidator.validate",
"com.example.impl.XmlRequestValidator.validate"
]
}
]
}
验收标准
预估工作量
7-10 人日
接口介绍
正向调用查询:给定一个方法的全限定名,返回该方法体内直接调用到的所有方法清单(被调方),并对接口/抽象类调用按需展开成实际可能的实现方法。
工具名
find_callees_by_method_name背景与目标
查找调用点(callers)是反向问题,本工具是正向(我调了谁)。两者合起来才能完成调用图遍历。
应用场景:
@Transactional方法内部是否调用了不该跨事务的远程方法输入参数
method_full_nameparameter_typesrepository_pathresolve_polymorphicinclude_jdk_callsjava.*等标准库的调用也算上max_depth输出结构
{ "source_method": "com.example.service.UserService.getUserOrThrow", "total_callees": 4, "callees": [ { "callee_method_full_name": "com.example.dao.UserDao.findById", "callee_signature": "findById(java.lang.Long): com.example.User", "call_site_line": 47, "call_site_snippet": "userDao.findById(id)", "is_polymorphic_resolved": false, "resolved_implementations": null, "is_jdk_call": false }, { "callee_method_full_name": "com.example.RequestValidator.validate", "is_polymorphic_resolved": true, "resolved_implementations": [ "com.example.impl.JsonRequestValidator.validate", "com.example.impl.XmlRequestValidator.validate" ] } ] }验收标准
resolve_polymorphic=true时通过继承索引把接口/抽象类调用展开成所有实现include_jdk_calls打开预估工作量
7-10 人日