arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2310.18532cs.SE
收藏

SkipAnalyzer:一种基于大语言模型的静态代码分析工具

SkipAnalyzer: A Tool for Static Code Analysis with Large Language Models

Mohammad Mahdi Mohajer, Reem Aleithan, Nima Shiri Harzevili, Moshi Wei, Alvine Boaye Belle, Hung Viet Pham, Song Wang

AI总结:

本研究提出由LLM驱动的静态代码分析工具SkipAnalyzer,包含缺陷检测、误报过滤、补丁生成三个模块,在空指针解引用和资源泄漏两类缺陷的相关任务中性能优于现有工具。

摘要:

我们推出SkipAnalyzer,一款由大语言模型(LLM)驱动的静态代码分析工具。SkipAnalyzer包含三个组件:1)基于LLM的静态缺陷检测器,可扫描源代码并报告特定类型的缺陷;2)基于LLM的误报过滤器,能够识别静态缺陷检测器结果(例如步骤1的输出)中的误报缺陷,以提升检测准确率;3)基于LLM的补丁生成器,可为上述检测到的缺陷生成修复补丁。作为概念验证,SkipAnalyzer基于ChatGPT构建,后者已在各类软件工程任务中展现出优异性能。\n为评估SkipAnalyzer,我们选取静态缺陷检测针对的两类典型且关键的缺陷作为研究对象,即空指针解引用(Null Dereference)和资源泄漏(Resource Leak)。我们借助Infer工具从10个开源项目中收集这两类缺陷,最终实验数据集包含222个空指针解引用缺陷实例和46个资源泄漏缺陷实例。\n研究表明,SkipAnalyzer在上述静态分析任务(包括缺陷检测、误报警告清除和缺陷修复)中均取得了显著性能。在静态缺陷检测方面,SkipAnalyzer检测空指针解引用缺陷的准确率最高达68.37%,检测资源泄漏缺陷的准确率最高达76.95%,分别将当前主流缺陷检测器Infer的精确率提升了12.86%和43.13%。在清除误报警告方面,SkipAnalyzer对空指针解引用缺陷的精确率最高达93.88%,对资源泄漏缺陷的精确率最高达63.33%,且性能优于现有最先进的误报警告清除工具。此外,在缺陷修复方面,SkipAnalyzer生成语法正确的补丁以修复其检测到的缺陷的成功率最高达97.30%。

英文摘要:

We introduce SkipAnalyzer, a large language model (LLM)-powered tool for static code analysis. SkipAnalyzer has three components: 1) an LLM-based static bug detector that scans source code and reports specific types of bugs, 2) an LLM-based false-positive filter that can identify false-positive bugs in the results of static bug detectors (e.g., the result of step 1) to improve detection accuracy, and 3) an LLM-based patch generator that can generate patches for the detected bugs above. As a proof-of-concept, SkipAnalyzer is built on ChatGPT, which has exhibited outstanding performance in various software engineering tasks. To evaluate SkipAnalyzer, we focus on two types of typical and critical bugs that are targeted by static bug detection, i.e., Null Dereference and Resource Leak as subjects. We employ Infer to aid the gathering of these two bug types from 10 open-source projects. Consequently, our experiment dataset contains 222 instances of Null Dereference bugs and 46 instances of Resource Leak bugs. Our study demonstrates that SkipAnalyzer achieves remarkable performance in the mentioned static analysis tasks, including bug detection, false-positive warning removal, and bug repair. In static bug detection, SkipAnalyzer achieves accuracy values of up to 68.37% for detecting Null Dereference bugs and 76.95% for detecting Resource Leak bugs, improving the precision of the current leading bug detector, Infer, by 12.86% and 43.13%, respectively. For removing false-positive warnings, SkipAnalyzer can reach a precision of up to 93.88% for Null Dereference bugs and 63.33% for Resource Leak bugs. Additionally, SkipAnalyzer surpasses state-of-the-art false-positive warning removal tools. Furthermore, in bug repair, SkipAnalyzer can generate syntactically correct patches to fix its detected bugs with a success rate of up to 97.30%.

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

↑