[论文解读] CoCoFuzzing: Testing Neural Code Models with Coverage-Guided Fuzzing
CoCoFuzzing 是一种新颖的覆盖引导模糊测试框架,通过生成语义保持的代码变异来测试神经代码模型的鲁棒性。通过采用十个自定义的变异操作符并以神经元覆盖率为驱动的测试生成,该框架提升了模型的鲁棒性,在 NeuralCodeSum 上实现了高达 84.81% 的性能下降,同时使用其输出进行对抗性微调可将模型准确率提升高达 35.15%。
Deep learning-based code processing models have shown good performance for tasks such as predicting method names, summarizing programs, and comment generation. However, despite the tremendous progress, deep learning models are often prone to adversarial attacks, which can significantly threaten the robustness and generalizability of these models by leading them to misclassification with unexpected inputs. To address the above issue, many deep learning testing approaches have been proposed, however, these approaches mainly focus on testing deep learning applications in the domains of image, audio, and text analysis, etc., which cannot be directly applied to neural models for code due to the unique properties of programs. In this paper, we propose a coverage-based fuzzing framework, CoCoFuzzing, for testing deep learning-based code processing models. In particular, we first propose ten mutation operators to automatically generate valid and semantically preserving source code examples as tests; then we propose a neuron coverage-based approach to guide the generation of tests. We investigate the performance of CoCoFuzzing on three state-of-the-art neural code models, i.e., NeuralCodeSum, CODE2SEQ, and CODE2VEC. Our experiment results demonstrate that CoCoFuzzing can generate valid and semantically preserving source code examples for testing the robustness and generalizability of these models and improve the neuron coverage. Moreover, these tests can be used to improve the performance of the target neural code models through adversarial retraining.
研究动机与目标
- 为解决基于深度学习的神经代码模型缺乏有效测试框架的问题,这些模型对对抗性输入存在脆弱性。
- 开发一种系统化方法,生成有效且语义保持的代码变异,以彻底测试模型的鲁棒性。
- 使用神经元覆盖率作为度量标准引导测试生成,实现对多样化程序变换的系统性探索。
- 评估生成测试在暴露模型弱点以及通过对抗性微调提升模型性能方面的有效性。
提出的方法
- 设计并实现十个代表真实世界语义保持代码变换的变异操作符,例如变量重命名、无用代码插入和参数添加。
- 使用神经元覆盖率(NC)作为引导度量标准,驱动变异过程,确保对模型内部行为的多样化和全面探索。
- 集成一个覆盖引导的模糊测试器,根据操作符提升神经元覆盖率的有效性来选择并应用变异操作符。
- 将生成的测试用例应用于评估模型鲁棒性,并对模型进行对抗性微调以提升泛化能力。
- 通过微调测量测试用例对模型性能下降和提升的影响。
实验结果
研究问题
- RQ1覆盖引导的模糊测试框架能否有效生成适用于神经代码模型的有效且语义保持的代码测试?
- RQ2神经元覆盖率在引导生成多样化且鲁棒的代码模型测试用例方面有多有效?
- RQ3生成的测试用例在多大程度上降低了最先进神经代码模型的性能?
- RQ4使用生成的测试用例进行对抗性微调能否提升这些模型的鲁棒性和准确率?
主要发现
- CoCoFuzzing 有效生成了有效且语义保持的代码示例,分别使 NeuralCodeSum、CODE2SEQ 和 CODE2VEC 的性能下降了 84.81%、22.06% 和 27.58%。
- 生成的测试用例提升了模型鲁棒性,对抗性微调使 NeuralCodeSum 的性能提升 35.15%,CODE2SEQ 提升 8.83%,CODE2VEC 提升 34.14%。
- 神经元覆盖率度量标准有效引导模糊测试器探索多样化程序变换,并实现了对模型内部神经元的更高覆盖率。
- CoCoFuzzing 是首个专为神经代码模型设计的基于覆盖的模糊测试框架,解决了现有方法在图像、音频和 NLP 领域中的局限性。
- 十个自定义的变异操作符使语义保持的代码变异探索范围广于以往仅依赖两个操作符(如重命名和无用代码插入)的方法。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。