antgroup / antgroup/YASA-Engine
[OSS26] 查找方法被调用点 find_callers_by_method_name
Open
@wryyyds7 is already working on this.
Since Jul 30, 2026.
OSS26-Team
- Dominant language
- TypeScript
- Stars
- 323
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
接口介绍
反向引用查询:给定一个方法的全限定名,返回仓库内所有调用该方法的位置 — 包括调用方所在方法、行号、调用表达式片段;支持把通过父类/接口间接调用到该方法的位置也算上。
工具名
find_callers_by_method_name
背景与目标
调用关系是程序分析的核心。从安全审计角度看:
- 找到所有调用
Runtime.exec的位置 → 命令注入入口 - 找到所有调用
Cipher.getInstance("DES")的位置 → 弱加密风险定位 - 修一个 API 时确认所有上游调用都更新了
这是 YASA 跨仓审计的基础能力之一,本任务先做单仓库版,后续可扩展跨仓。
输入参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
method_full_name |
string | 是 | 被调方法全限定名 |
parameter_types |
string[] | 否 | 形参类型,重载消歧 |
repository_path |
string | 是 | 仓库本地绝对路径 |
include_test_code |
bool | 否 | 默认 false |
include_inherited_callers |
bool | 否 | 默认 true。true 时:调用方法的实际类型是子类,但目标解析到父类方法也算上 |
max_results |
int | 否 | 默认 200 |
输出结构
{
"target_method": "com.example.dao.UserDao.findById",
"total_callers": 12,
"callers": [
{
"caller_method_full_name": "com.example.service.UserService.getUserOrThrow",
"file_path": "src/main/java/com/example/service/UserService.java",
"line_number": 47,
"call_expression_snippet": "User user = userDao.findById(id);",
"caller_class": "com.example.service.UserService",
"is_test_code": false
}
]
}
验收标准
- 正确解析以下调用形式:
- 普通实例调用
obj.method(...) - 静态调用
Cls.method(...) - 链式调用
a.b().method(...) - 方法引用
Foo::method - 通过接口/父类调用(由
include_inherited_callers控制)
- 普通实例调用
- 跳过注释、字符串内的伪命中
- 单元测试覆盖:静态/实例/方法引用/链式/匿名类内调用
- 中等仓库(~5k Java 文件)响应 < 10s
- 必要时建立调用图索引(可作为后续上游链路工具的底座)
预估工作量
7-10 人日(团队协作:索引构建 + 类型解析 + 调用点提取分头做)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.