[论文解读] White-Box and Black-Box Fuzzing for GraphQL APIs
本文提出了一种新颖的框架,用于使用白盒和黑盒模糊测试技术自动测试GraphQL API。该框架结合了进化算法进行白盒测试以最大化代码覆盖率和故障检测,以及使用随机搜索进行黑盒测试,通过EvoMaster工具在7个开源和31个在线GraphQL API上展示了显著提升的测试有效性。
The Graph Query Language (GraphQL) is a powerful language for APIs manipulation in web services. It has been recently introduced as an alternative solution for addressing the limitations of RESTful APIs. This paper introduces an automated solution for GraphQL APIs testing. We present a full framework for automated APIs testing, from the schema extraction to test case generation. In addition, we consider two kinds of testing: white-box and black-box testing. The white-box testing is performed when the source code of the GraphQL API is available. Our approach is based on evolutionary search. Test cases are evolved to intelligently explore the solution space while maximizing code coverage and fault-finding criteria. The black-box testing does not require access to the source code of the GraphQL API. It is therefore of more general applicability, albeit it has worse performance. In this context, we use a random search to generate GraphQL data. The proposed framework is implemented and integrated into the open-source EvoMaster tool. With enabled white-box heuristics, i.e., white-box mode, experiments on 7 open-source GraphQL APIs show statistically significant improvement of the evolutionary approach compared to the baseline random search. In addition, experiments on 31 online GraphQL APIs reveal the ability of the black-box mode to detect real faults.
研究动机与目标
- 为解决GraphQL API自动化测试方案的缺乏,尤其是在白盒和黑盒测试场景下的问题。
- 开发一个全栈框架,用于提取模式并生成JUnit和Jest格式的可执行测试用例。
- 评估进化算法在GraphQL API白盒测试中的有效性,以及随机搜索在黑盒测试中的有效性。
- 在真实世界中的开源和在线GraphQL API上验证该框架在故障检测和覆盖率提升方面的效果。
- 扩展EvoMaster工具,增加对源代码可访问和远程GraphQL API的白盒与黑盒测试的测试生成能力。
提出的方法
- 该框架提取GraphQL模式,并使用包含多种基因类型的遗传表示法将其建模为可测试结构。
- 在白盒测试中,进化算法使用内部和结构变异操作符,演化出能最大化代码覆盖率和故障检测的测试用例。
- 在黑盒测试中,随机搜索基于模式生成有效GraphQL查询,无需访问源代码。
- 该方法作为开源EvoMaster工具的扩展实现,支持以JUnit和Jest格式输出测试。
- 该框架支持复杂模式特性,如嵌套函数调用和递归数据结构。
- 通过统计分析和30次使用不同随机种子的重复运行,确保白盒评估结果的稳健性。
实验结果
研究问题
- RQ1在白盒测试中,进化搜索在代码覆盖率和故障检测方面是否优于随机搜索?
- RQ2在无源代码访问的情况下,黑盒随机测试是否能有效发现生产级GraphQL API中的真实故障?
- RQ3所提出的框架在涵盖开源和在线服务的多样化GraphQL API实现中,其可扩展性如何?
- RQ4模式分解和遗传操作符对GraphQL测试中测试用例生成质量有何影响?
- RQ5EvoMaster框架在多大程度上可扩展以支持GraphQL API的白盒与黑盒测试?
主要发现
- 在白盒测试中,与随机搜索相比,进化方法在7个开源API上的平均行覆盖率提高了6%(最高达26.9%)。
- 白盒模式在7个测试API中额外检测到77个故障,证明其更强的故障发现能力。
- 在黑盒测试中,随机搜索方法在31个在线GraphQL API的825个端点中,最多检测到641个错误。
- 该框架成功生成了可执行的测试套件,支持JUnit和Jest格式,可无缝集成到CI/CD流水线中。
- 结果具有统计显著性,每个API均进行了30次重复运行,以确保可靠性并减少随机初始化带来的方差。
- 该框架作为EvoMaster的扩展公开提供,所有实验脚本和数据集均托管在GitHub和Zenodo上,以确保可复现性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。