paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Code Difference Guided Adversarial Example Generation for Deep Code Models

代码差异引导的深度代码模型对抗样本生成
ASE 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE)2023匹配度 3/10 · 论文研究深度代码模型的对抗样本生成,属于PL与ML交叉,但核心是模型鲁棒性测试,而非用户关注的静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析。其问题设定与用户研究画像中的核心方向匹配度较低。引用 51 inbox
Zhao Tian, Junjie Chen, Zhi Jin
crossref: 2026-09-12dblp: 2026-09-12arxiv: 2026-09-12

AI 速览

一句话:提出代码差异引导的对抗样本生成技术 CODA,高效测试并增强深度代码模型鲁棒性。

论文针对深度代码模型对抗样本生成因源代码离散且需满足复杂语法语义约束、成分搜索空间巨大而效果不佳的问题,提出 CODA。其核心利用目标输入与参考输入之间的代码差异,包括结构差异与标识符差异,来引导对抗样本生成;通过设计并引导等价结构变换和标识符重命名变换,在保留原始语义的同时大幅缩小搜索空间。在 15 个深度代码模型上的实验表明,CODA 有效且高效,生成样本具有自然性,并经对抗微调提升模型鲁棒性;相比 CARROT 和 ALERT,平均多发现 88.05% 和 72.51% 的模型缺陷。

问题
深度代码模型易受对抗样本影响,但源代码离散且受复杂语法语义约束,现有对抗样本生成方法搜索空间大、效果不理想。
方法
提出 CODA,利用目标输入与参考输入间的结构和标识符差异指导生成,并通过等价结构变换与标识符重命名在保持语义下缩小搜索空间。
评估
在 15 个深度代码模型上实验,评估有效性、效率、生成样本自然性以及对抗微调后的鲁棒性提升,并与 CARROT、ALERT 对比。
原文摘要(Abstract)

Adversarial examples are important to test and enhance the robustness of deep code models. As source code is discrete and has to strictly stick to complex grammar and semantics constraints, the adversarial example generation techniques in other domains are hardly applicable. Moreover, the adversarial example generation techniques specific to deep code models still suffer from unsatisfactory effectiveness due to the enormous ingredient search space. In this work, we propose a novel adversarial example generation technique (i.e., CODA) for testing deep code models. Its key idea is to use code differences between the target input (i.e., a given code snippet as the model input) and reference inputs (i.e., the inputs that have small code differences but different prediction results with the target input) to guide the generation of adversarial examples. It considers both structure differences and identifier differences to preserve the original semantics. Hence, the ingredient search space can be largely reduced as the one constituted by the two kinds of code differences, and thus the testing process can be improved by designing and guiding corresponding equivalent structure transformations and identifier renaming transformations. Our experiments on 15 deep code models demonstrate the effective-ness and efficiency of CODA, the naturalness of its generated examples, and its capability of enhancing model robustness after adversarial fine-tuning. For example, CODA reveals 88.05 % and 72.51 % more faults in models than the state-of-the-art techniques (i.e., CARROT and ALERT) on average, respectively.

链接与引用

DOI 原文 · arXiv · PDF(开放获取) · DBLP

BibTeX
@inproceedings{TianCJ23,
  title = {Code Difference Guided Adversarial Example Generation for Deep Code Models},
  author = {Zhao Tian and Junjie Chen and Zhi Jin},
  booktitle = {ASE},
  year = {2023},
  doi = {10.1109/ase56229.2023.00149}
}