Adversarial Robustness of Deep Code Comment Generation

Yu Zhou, Xiaoqing Zhang, Juanjuan Shen, Tingting Han, Taolue Chen +1 more
7/31/2021
cs.SE

Official code: Zhangxq-1/ACCENT-repository (7 stars, Python, last commit 2021-09-27).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

70Python, ShellJan 30, 20215 years ago

Similar Papers

Cite this paper

@article{zhou2021adversarial,
  title  = {Adversarial Robustness of Deep Code Comment Generation},
  author = {Yu Zhou and Xiaoqing Zhang and Juanjuan Shen and Tingting Han and Taolue Chen and Harald Gall},
  year   = {2021},
  eprint = {2108.00213},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2108.00213}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2108.00213.svg)](https://codeofpaper.com/paper/2108.00213)

Discussion