Deep neural networks (DNNs) have shown remarkable performance in a variety of domains such as computer vision, speech recognition, or natural language processing. Recently they also have been applied to various software engineering tasks, typically involving processing source code. DNNs are well-known to be vulnerable to adversarial examples, i.e., fabricated inputs that could lead to various misbehaviors of the DNN model while being perceived as benign by humans. In this paper, we focus on the code comment generation task in software engineering and study the robustness issue of the DNNs when they are applied to this task. We propose ACCENT, an identifier substitution approach to craft adversarial code snippets, which are syntactically correct and semantically close to the original code snippet, but may mislead the DNNs to produce completely irrelevant code comments. In order to improve the robustness, ACCENT also incorporates a novel training method, which can be applied to existing code comment generation models. We conduct comprehensive experiments to evaluate our approach by attacking the mainstream encoder-decoder architectures on two large-scale publicly available datasets. The results show that ACCENT efficiently produces stable attacks with functionality-preserving adversarial examples, and the generated examples have better transferability compared with baselines. We also confirm, via experiments, the effectiveness in improving model robustness with our training method.
翻译:深神经网络(DNNs)在计算机视觉、语音识别或自然语言处理等各个领域表现出了显著的绩效。最近,这些网络还被用于各种软件工程任务,通常涉及处理源代码。 DNNs众所周知容易受到对抗性例子的伤害,即制造投入可能导致DNN模式的各种错误行为,同时被人类视为无害。在本文件中,我们侧重于软件工程中的代码评论生成任务,并研究DNs在应用到这一任务时的稳健性问题。我们建议采用ACCENT(识别替代方法)来制作对抗代码片断,这些代码片断通常涉及处理源代码代码。DNNS众所周知,这很容易成为对抗性实例,例如,编造物造物,但可能会误导DNNes,以产生完全无关的代码评论。为了提高强健性,ACCENT还采用了一种新的培训方法,可用于现有的代码生成模型生成模型模型。我们进行了全面的实验,通过两个大规模、可公开获取的代码解码结构结构来评估我们的方法。我们用两种大规模、具有更精确性、更精确的实验性的方法,我们用更精确的模型来模拟的模型来评估。