一句话:提出 RoPGen,通过在对抗训练中结合数据与梯度增强,学习难以模仿的编码风格模式以提升深度代码作者归属的鲁棒性。
源代码作者归属在软件取证、缺陷修复与软件质量分析中很重要,但现有基于深度学习的归属方法容易受到对抗样本和编码风格操纵的攻击,因此需要鲁棒方案。本文提出 RoPGen 框架,其核心是在对抗训练阶段结合数据增强与梯度增强,从而学习作者独特且难以操纵或模仿的编码风格模式。该方法增加了训练样本的多样性,对深度神经网络梯度生成有意义的扰动,并学习多样化的编码风格表示。作者在 C、C++ 和 Java 编写的四个程序数据集上评估 RoPGen,实验表明它能显著提升基于深度学习的代码作者归属鲁棒性,平均将 targeted 和 untargeted 攻击的成功率分别降低 22.8% 和 41.0%。
Source code authorship attribution is an important problem often encountered in applications such as software forensics, bug fixing, and software quality analysis. Recent studies show that current source code authorship attribution methods can be compromised by attackers exploiting adversarial examples and coding style manipulation. This calls for robust solutions to the problem of code authorship attribution. In this paper, we initiate the study on making Deep Learning (DL)-based code authorship attribution robust. We propose an innovative framework called Robust coding style Patterns Generation (RoPGen), which essentially learns authors' unique coding style patterns that are hard for attackers to manipulate or imitate. The key idea is to combine data augmentation and gradient augmentation at the adversarial training phase. This effectively increases the diversity of training examples, generates meaningful perturbations to gradients of deep neural networks, and learns diversified representations of coding styles. We evaluate the effectiveness of RoPGen using four datasets of programs written in C, C++, and Java. Experimental results show that RoPGen can significantly improve the robustness of DL-based code authorship attribution, by respectively reducing 22.8% and 41.0% of the success rate of targeted and untargeted attacks on average.