arXiv:2504.21205cs.CRcs.AI2025-04被引 13

评测代码智能体在真实项目中生成安全代码的能力,发现智能体显著优于普通大模型。

SecRepoBench: Benchmarking Code Agents for Secure Code Completion in Real-World Repositories

  • 构建318个真实仓库中的安全补全任务,覆盖15类漏洞。
  • 代码智能体在安全性和正确性上远超独立大模型。
  • 为提升代码生成安全性提供关键方向,适合安全开发研究者参考。

本文提出SecRepoBench,一个用于评估代码智能体在真实项目仓库中进行安全代码补全的基准。该基准包含27个C/C++仓库中的318个代码补全任务,覆盖15种常见漏洞类型(CWE)。我们使用该基准对29个独立大模型和15个代码智能体进行了评测,这些智能体基于三个主流智能体框架构建。结果表明,当前最先进的大模型在生成正确且安全的代码方面表现不佳;而代码智能体则显著优于独立大模型。此外,我们的分析显示SecRepoBench比现有最先进基准更具挑战性。最后,全面分析揭示了提升代码智能体在真实环境中生成正确、安全代码能力的潜在方向。

原文摘要 · Abstract (English)

This paper introduces SecRepoBench, a benchmark to evaluate code agents on secure code completion in real-world repositories. SecRepoBench has 318 code completion tasks in 27 C/C++ repositories, covering 15 CWEs. We evaluate 29 standalone LLMs and 15 code agents across 3 state-of-the-art agent frameworks using our benchmark. We find that state-of-the-art LLMs struggle with generating correct and secure code completions. However, code agents significantly outperform standalone LLMs. We show that SecRepoBench is more difficult than the prior state-of-the-art benchmark. Finally, our comprehensive analysis provides insights into potential directions for enhancing the ability of code agents to write correct and secure code in real-world repositories.

代码生成安全补全智能体评测

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。