arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2501.05456cs.SEcs.CR
收藏

基于LLM的库API输入空间划分测试

LLM Based Input Space Partitioning Testing for Library APIs

Jiageng Li, Zhen Dong, Chong Wang, Haozhen You, Cen Zhang, Yang Liu, Xin Peng

AI总结:

针对库API复杂输入空间测试难题,提出基于LLM理解代码并划分输入空间的LISP方法,覆盖率优于EvoSuite并发现13个CVE漏洞。

摘要:

自动化库API测试颇具难度,因为它需要探索可能涉及复杂数据类型对象的庞大参数输入空间。现有的基于搜索的方法对对象状态与程序分支之间关系的了解有限,常面临效率低下的问题,即倾向于生成无效输入。基于符号执行的方法能够有效识别此类关系,但无法扩展到大型程序。在本工作中,我们提出了一种用于库API的基于LLM的输入空间划分测试方法LISP。该方法利用LLM理解被测库API的代码,并基于其理解和丰富的常识执行输入空间划分。具体而言,我们将被测API的签名和代码提供给LLM,期望获得被测API每个输入空间划分的文本描述。随后,我们利用生成的文本描述从每个划分中采样输入以生成输入,最终形成系统探索API程序行为的测试套件。我们在来自10个流行开源Java库(例如GitHub上拥有2.6k星的apache/commons-lang和拥有48.8k星的guava)的2,205个库API方法上评估LISP。实验结果表明,LISP在库API测试中是有效的。在边覆盖率方面,它显著优于最先进工具EvoSuite。LISP平均实现67.82%的分支覆盖率,是EvoSuite的1.21倍。实验中LISP总共触发404个异常或错误,并在评估期间发现13个此前未知的漏洞,这些漏洞已被分配CVE ID。

英文摘要:

Automated library APIs testing is difficult as it requires exploring a vast space of parameter inputs that may involve objects with complex data types. Existing search based approaches, with limited knowledge of relations between object states and program branches, often suffer from the low efficiency issue, i.e., tending to generate invalid inputs. Symbolic execution based approaches can effectively identify such relations, but fail to scale to large programs. In this work, we present an LLM-based input space partitioning testing approach, LISP, for library APIs. The approach leverages LLMs to understand the code of a library API under test and perform input space partitioning based on its understanding and rich common knowledge. Specifically, we provide the signature and code of the API under test to LLMs, with the expectation of obtaining a text description of each input space partition of theAPI under test. Then, we generate inputs through employing the generated text description to sample inputs from each partition, ultimately resulting in test suites that systematically explore the program behavior of the API. We evaluate LISP on more than 2,205 library API methods taken from 10 popular open-source Java libraries (e.g.,apache/commonslang with 2.6k stars, guava with 48.8k stars on GitHub). Our experiment results show that LISP is effective in library API testing. It significantly outperforms state-of-the-art tool EvoSuite in terms of edge coverage. On average, LISP achieves 67.82% branch coverage, surpassing EvoSuite by 1.21 times. In total, LISP triggers 404 exceptions or errors in the experiments, and discovers 13 previously unknown vulnerabilities during evaluation, which have been assigned CVE IDs.

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

↑