一句话:提出用强化学习动态优先化操作与参数的自适应 REST API 测试技术,提升覆盖率与缺陷发现能力。
REST API 测试面临巨大的搜索空间:既要选择操作以构成调用序列,又要从大量参数中选参,并在近乎无限的输入空间中采样取值。现有工具缺乏高效探索机制,对所有操作与参数同等对待,缺少优先级策略,且在规范中缺失响应模式或存在变体时表现不佳。本文提出一种自适应 REST API 测试技术,引入强化学习在探索过程中优先化操作与参数;同时动态分析请求与响应数据以推断依赖参数,并采用基于采样的策略高效处理动态 API 反馈。作者在十个 RESTful 服务上开展评估,与最先进的 REST 测试工具比较代码覆盖率、生成请求数、覆盖操作数与触发的服务故障数,并对优先化、动态反馈分析与采样进行消融研究。结果表明该方法在有效性、效率与缺陷发现能力上均优于现有 REST API 测试工具。
Modern web services increasingly rely on REST APIs. Effectively testing these APIs is challenging due to the vast search space to be explored, which involves selecting API operations for sequence creation, choosing parameters for each operation from a potentially large set of parameters, and sampling values from the virtually infinite parameter input space. Current testing tools lack efficient exploration mechanisms, treating all operations and parameters equally (i.e., not considering their importance or complexity) and lacking prioritization strategies. Furthermore, these tools struggle when response schemas are absent in the specification or exhibit variants. To address these limitations, we present an adaptive REST API testing technique that incorporates reinforcement learning to prioritize operations and parameters during exploration. Our approach dynamically analyzes request and response data to inform dependent parameters and adopts a sampling-based strategy for efficient processing of dynamic API feedback. We evaluated our technique on ten RESTful services, comparing it against state-of-the-art REST testing tools with respect to code coverage achieved, requests generated, operations covered, and service failures triggered. Additionally, we performed an ablation study on prioritization, dynamic feedback analysis, and sampling to assess their individual effects. Our findings demonstrate that our approach outperforms existing REST API testing tools in terms of effectiveness, efficiency, and fault-finding ability.