FLAG:利用生成式人工智能发现(代码中的)行级异常
FLAG: Finding Line Anomalies (in code) with Generative AI
AI总结:
FLAG利用大型语言模型逐行比较代码以定位异常,无需语言特定规则,在121个基准上识别101个缺陷,将搜索空间缩减至12-17%。
摘要:
代码包含安全性和功能性缺陷。识别和定位这些缺陷的过程困难且依赖人工劳动。在这项工作中,我们提出了一种新颖的方法(FLAG)来辅助人类调试人员。FLAG基于生成式人工智能的词汇能力,特别是大型语言模型(LLMs)。在此,我们输入一个代码文件,然后提取并重新生成该文件中的每一行,以进行自我比较。通过将原始代码与LLM生成的替代代码进行比较,我们可以将显著差异标记为异常以供进一步检查,其中诸如与注释的距离和LLM置信度等特征也有助于此分类。这减少了设计者的检查搜索空间。与该领域的其他自动化方法不同,FLAG与语言无关,可以处理不完整(甚至无法编译)的代码,并且不需要创建安全属性、功能测试或定义规则。在这项工作中,我们探索了有助于LLM进行此分类的特征,并评估了FLAG在已知缺陷上的性能。我们使用了跨C、Python和Verilog的121个基准;每个基准包含一个已知的安全或功能弱点。我们使用OpenAI的code-davinci-002和gpt-3.5-turbo这两个最先进的LLM进行了实验,但我们的方法也可用于其他模型。FLAG可以识别101个缺陷,并有助于将搜索空间减少到源代码的12-17%。
英文摘要:
Code contains security and functional bugs. The process of identifying and localizing them is difficult and relies on human labor. In this work, we present a novel approach (FLAG) to assist human debuggers. FLAG is based on the lexical capabilities of generative AI, specifically, Large Language Models (LLMs). Here, we input a code file then extract and regenerate each line within that file for self-comparison. By comparing the original code with an LLM-generated alternative, we can flag notable differences as anomalies for further inspection, with features such as distance from comments and LLM confidence also aiding this classification. This reduces the inspection search space for the designer. Unlike other automated approaches in this area, FLAG is language-agnostic, can work on incomplete (and even non-compiling) code and requires no creation of security properties, functional tests or definition of rules. In this work, we explore the features that help LLMs in this classification and evaluate the performance of FLAG on known bugs. We use 121 benchmarks across C, Python and Verilog; with each benchmark containing a known security or functional weakness. We conduct the experiments using two state of the art LLMs in OpenAI's code-davinci-002 and gpt-3.5-turbo, but our approach may be used by other models. FLAG can identify 101 of the defects and helps reduce the search space to 12-17% of source code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。