Code Difference Guided Adversarial Example Generation for Deep Code Models

被引:12
作者
Tian, Zhao [1 ]
Chen, Junjie [1 ]
Jin, Zhi [2 ]
机构
[1] Tianjin Univ, Coll Intelligence & Comp, Tianjin, Peoples R China
[2] Peking Univ, Key Lab High Confidence Software Technol, Beijing, Peoples R China
来源
2023 38TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING, ASE | 2023年
基金
中国国家自然科学基金;
关键词
Adversarial Example; Code Model; Guided Testing; Code Transformation;
D O I
10.1109/ASE56229.2023.00149
中图分类号
TP [自动化技术、计算机技术];
学科分类号
0812 ;
摘要
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 effectiveness 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.
引用
收藏
页码:850 / 862
页数:13
相关论文
共 61 条
[21]   Semantic Robustness of Models of Source Code [J].
Henkel, Jordan ;
Ramakrishnan, Goutham ;
Wang, Zi ;
Albarghouthi, Aws ;
Jha, Somesh ;
Reps, Thomas .
2022 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION AND REENGINEERING (SANER 2022), 2022, :526-537
[22]   API Method Recommendation without Worrying about the Task-API Knowledge Gap [J].
Huang, Qiao ;
Xia, Xin ;
Xing, Zhenchang ;
Lo, David ;
Wang, Xinyu .
PROCEEDINGS OF THE 2018 33RD IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMTED SOFTWARE ENGINEERING (ASE' 18), 2018, :293-304
[23]  
Jha Akshita, 2023, P AAAI C ART INT
[24]  
Joshi A., 2015, British Journal of Applied Science Technology, V7, P396, DOI [10.9734/BJAST/2015/14975, DOI 10.9734/BJAST/2015/14975, 10.9734/bjast/2015/14975]
[25]  
Kang YN, 2021, 2021 CONFERENCE ON EMPIRICAL METHODS IN NATURAL LANGUAGE PROCESSING (EMNLP 2021), P3425
[26]   What do pre-trained code models know about code? [J].
Karmakar, Anjan ;
Robbes, Romain .
2021 36TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING ASE 2021, 2021, :1332-1336
[27]  
Kurakin A., 2018, Adversarial machine learning at scale, P99, DOI DOI 10.1201/9781351251389-8
[28]  
Li J, 2018, PROCEEDINGS OF THE TWENTY-SEVENTH INTERNATIONAL JOINT CONFERENCE ON ARTIFICIAL INTELLIGENCE, P4159
[29]   Competition-level code generation with AlphaCode [J].
Li, Yujia ;
Choi, David ;
Chung, Junyoung ;
Kushman, Nate ;
Schrittwieser, Julian ;
Leblond, Remi ;
Eccles, Tom ;
Keeling, James ;
Gimeno, Felix ;
Dal Lago, Agustin ;
Hubert, Thomas ;
Choy, Peter ;
d'Autume, Cyprien de Masson ;
Babuschkin, Igor ;
Chen, Xinyun ;
Huang, Po-Sen ;
Welbl, Johannes ;
Gowal, Sven ;
Cherepanov, Alexey ;
Molloy, James ;
Mankowitz, Daniel J. ;
Robson, Esme Sutherland ;
Kohli, Pushmeet ;
de Freitas, Nando ;
Kavukcuoglu, Koray ;
Vinyals, Oriol .
SCIENCE, 2022, 378 (6624) :1092-1097
[30]  
Li ZJ, 2022, Arxiv, DOI arXiv:2208.08289