arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.09414cs.SE
收藏

多智能体辅助的Java JSON库自动测试生成

Multi-agent Assisted Automatic Test Generation for Java JSON Libraries

Research Institute of Trustworthy Autonomous Systems(可信自主系统研究院);University of Utah(犹他大学)

Sinan Wang, Zhiyuan Zhong, Shaojin Wen, Yepang Liu

AI总结:

JsonATG通过多智能体系统生成Java JSON库的多样化测试用例,有效提升测试覆盖率并发现多个bug。

摘要:

JSON是一种广泛用于应用程序之间数据交换的格式。在Java生态系统中,JSON库是处理JSON数据的基本工具包,驱动着现实世界的应用程序,如Web服务、Android应用或数据管理系统。然而,如果没有有效的质量保证方法,如自动测试生成(ATG),开发者可能会引入微妙的数据不一致bug、兼容性问题,甚至安全漏洞。这些缺陷可能影响数十亿最终用户,并可能造成严重的经济损失。最近,大语言模型(LLMs)在增强ATG方面显示出强大的潜力。然而,现有的基于LLM的方法,如TitanFuzz和YanHui,缺乏对JSON领域的专门化。对于Java JSON库(JJLs),有效的测试用例应捕捉格式数据与应用程序之间的约束,从而留有质量保证的关键方面未被解决。为填补这一空白,我们提出了JsonATG,一个多智能体ATG系统,为JJLs生成多样化的触发bug测试。通过历史bug信息作为种子,JsonATG将代码摘要代理和测试验证代理引入生成管道,以生成新的有效测试用例。它应用代理生成的程序突变规则,专门针对JJLs的结构和语义特征,如数据流操作、序列化格式和数据绑定模式。生成的测试通过后处理进一步细化,以确保语法和语义的正确性。我们的实验表明,JsonATG在广泛使用的JSON库上比两种最先进的基于LLM的测试生成方法实现了更高的覆盖率。使用25美元的预算,我们在fastjson中报告了59个bug(包括非崩溃的功能bug),其中47个已确认,28个已经修复。

英文摘要:

JSON is a widely used format for data exchange between applications. In the Java ecosystem, JSON libraries serve as fundamental toolkits for processing JSON data, powering real-world applications such as web services, Android apps, or data management systems. However, without effective quality assurance methods such as automatic test generation (ATG), developers risk introducing subtle data inconsistency bugs, compatibility issues, and even security vulnerabilities. These flaws can affect billions of end users and potentially cause severe financial losses. Recently, large language models (LLMs) have shown strong potential in enhancing ATG. However, existing LLM-based methods like TitanFuzz and YanHui lack specialization in the JSON domain. For Java JSON libraries (JJLs), effective test cases should capture the constraints between formatted data and application programs, leaving critical aspects of quality assurance unaddressed. To fill this gap, we propose JsonATG, a multi-agent ATG system that generates diverse bug-triggering tests for JJLs. With historical bug information as seeds, JsonATG introduces a code summarization agent and a test validation agent into the generation pipeline to produce new and valid test cases. It applies agent-generated program mutation rules tailored specifically for the structural and semantic characteristics of JJLs, such as data streaming operations, serialization formats, and data-binding patterns. The generated tests are further refined through post-processing to ensure syntactic and semantic correctness. Our experiments show that JsonATG achieves higher coverage than two state-of-the-art LLM-based test generation methods on the widely used JSON library. With a \$25 budget, we reported 59 bugs (including non-crashing functional bugs) in fastjson, of which 47 were confirmed and 28 have already been fixed.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑