一句话:提出 MioHint,用静态数据依赖检索与 LLM 协同引导白盒 REST API 请求变异,突破覆盖瓶颈。
云应用依赖 API 通信,现有 API 测试因覆盖指标缺乏梯度而难以到达严格条件,出现 fitness plateaus。MioHint 是一种白盒 API 测试方法,利用 LLM 的代码理解能力增强测试,但其难点在于系统级测试需分析跨函数、跨文件的请求与目标依赖。为此,MioHint 将静态分析与 LLM 协同:在语句级进行数据依赖检索,包括对目标所用变量做 def-use 分析,并展开目标调用的子函数,从而为 LLM 提供相关代码,辅助请求变异。在 16 个真实 REST API 服务上,MioHint 相比 EvoMaster 平均行覆盖绝对提升 4.95%,变异准确率提升 67 倍,并覆盖超过 57% 的难覆盖目标,而基线不足 10%。
Cloud applications heavily rely on APIs to communicate with each other and exchange data. To ensure the reliability of cloud applications, cloud providers widely adopt API testing techniques. Unfortunately, existing API testing approaches are insufficient to reach strict conditions, a problem known as fitness plateaus, due to the lack of a gradient provided by coverage metrics. To address this issue, we propose MioHint, a novel white-box API testing approach that leverages the code comprehension capabilities of Large Language Model (LLM) to boost API testing. The key challenge of LLM-based API testing lies in system-level testing, which emphasizes the dependencies between requests and targets across functions and files, thereby making the entire codebase the object of analysis. However, feeding the entire codebase to an LLM is impractical due to its limited context length and short memory. MioHint addresses this challenge by synergizing static analysis with LLMs. We retrieve relevant code with data-dependency analysis at the statement level, including def-use analysis for variables used in the target and function expansion for subfunctions called by the target. To evaluate the effectiveness of our method, we conducted experiments across 16 real-world REST API services. The findings reveal that MioHint achieves an average increase of 4.95% absolute in line coverage compared to the baseline, EvoMaster, alongside a remarkable factor of 67 × improvement in mutation accuracy. Furthermore, our method successfully covers over 57% of hard-to-cover targets, while in the baseline, the coverage is less than 10%.