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

PATCH:通过程序员意图引导和协作行为模拟增强大语言模型的自动漏洞修复能力

PATCH: Empowering Large Language Model with Programmer-Intent Guidance and Collaborative-Behavior Simulation for Automatic Bug Fixing

Yuwei Zhang, Zhi Jin, Ying Xing, Ge Li, Fang Liu, Jiaxin Zhu, Wensheng Dou, Jun Wei

AI总结:

针对现有大语言模型(LLMs)自动漏洞修复方法忽视协作性、仅以漏洞代码为输入的局限,提出分阶段框架PATCH,通过补充依赖上下文与意图信息、模拟程序员协作的四阶段任务流程,在BFP基准上性能优于现有LLMs。

摘要:

漏洞修复在软件开发与维护中具有重要意义。近期研究在探索大语言模型(LLMs)自动解决软件漏洞的潜力方面取得了显著进展。然而,现有方法存在一个明显的不足:忽视了漏洞修复过程中固有的协作层面,将其视为单阶段任务。此外,大多数方法在补丁生成阶段仅将有漏洞的代码片段作为LLMs的输入。为缓解上述局限性,我们提出了一种名为PATCH的新型分阶段框架。具体而言,我们首先为有漏洞的代码片段补充相应的依赖上下文和意图信息,以更好地引导LLMs生成正确的候选补丁。此外,受漏洞管理实践的启发,我们将漏洞修复任务分解为四个不同阶段:漏洞报告、漏洞诊断、补丁生成和补丁验证。这些阶段由LLMs以交互方式执行,旨在模拟程序员在解决软件漏洞过程中的协作行为。通过利用这些协同贡献,PATCH有效增强了LLMs的漏洞修复能力。我们使用强大的基于对话的LLM ChatGPT实现了PATCH。在广泛使用的漏洞修复基准BFP上的评估表明,PATCH的性能优于最先进的LLMs。

英文摘要:

Bug fixing holds significant importance in software development and maintenance. Recent research has made substantial strides in exploring the potential of large language models (LLMs) for automatically resolving software bugs. However, a noticeable gap in existing approaches lies in the oversight of collaborative facets intrinsic to bug resolution, treating the process as a single-stage endeavor. Moreover, most approaches solely take the buggy code snippet as input for LLMs during the patch generation stage. To mitigate the aforementioned limitations, we introduce a novel stage-wise framework named PATCH. Specifically, we first augment the buggy code snippet with corresponding dependence context and intent information to better guide LLMs in generating the correct candidate patches. Additionally, by taking inspiration from bug management practices, we decompose the bug-fixing task into four distinct stages: bug reporting, bug diagnosis, patch generation, and patch verification. These stages are performed interactively by LLMs, aiming to simulate the collaborative behavior of programmers during the resolution of software bugs. By harnessing these collective contributions, PATCH effectively enhances the bug-fixing capability of LLMs. We implement PATCH by employing the powerful dialogue-based LLM ChatGPT. Our evaluation on the widely used bug-fixing benchmark BFP demonstrates that PATCH has achieved better performance than state-of-the-art LLMs.

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

↑