首页 | 本学科首页   官方微博 | 高级检索  
     

基于深度学习的API误用缺陷检测
引用本文:汪昕,陈驰,赵逸凡,彭鑫,赵文耘. 基于深度学习的API误用缺陷检测[J]. 软件学报, 2019, 30(5): 1342-1358
作者姓名:汪昕  陈驰  赵逸凡  彭鑫  赵文耘
作者单位:复旦大学 软件学院, 上海 201203;上海市数据科学重点实验室(复旦大学), 上海 201203,复旦大学 软件学院, 上海 201203;上海市数据科学重点实验室(复旦大学), 上海 201203,复旦大学 软件学院, 上海 201203;上海市数据科学重点实验室(复旦大学), 上海 201203,复旦大学 软件学院, 上海 201203;上海市数据科学重点实验室(复旦大学), 上海 201203,复旦大学 软件学院, 上海 201203;上海市数据科学重点实验室(复旦大学), 上海 201203
基金项目:国家重点研发计划(2016YFB1000801)
摘    要:开发人员经常需要使用各种应用程序编程接口(application programming interface,简称API)来复用已有的软件框架、类库等.由于API自身的复杂性、文档资料的缺失等原因,开发人员经常会误用API,从而导致代码缺陷.为了自动检测API误用缺陷,需要获得API使用规约,并根据规约对API使用代码进行检测.然而,可用于自动检测的API规约难以获得,而人工编写并维护的代价又很高.针对以上问题,将深度学习中的循环神经网络模型应用于API使用规约的学习及API误用缺陷的检测.在大量的开源Java代码基础上,通过静态分析构造API使用规约训练样本,同时利用这些训练样本搭建循环神经网络学习API使用规约.在此基础上,针对API使用代码进行基于上下文的语句预测,并通过预测结果与实际代码的比较发现潜在的API误用缺陷.对所提出的方法进行实现并针对Java加密相关的API及其使用代码进行了实验评估,结果表明,该方法能够在一定程度上实现API误用缺陷的自动发现.

关 键 词:API误用  使用规约  缺陷检测  深度学习
收稿时间:2018-08-31
修稿时间:2018-10-31

API Misuse Bug Detection Based on Deep Learning
WANG Xin,CHEN Chi,ZHAO Yi-Fan,PENG Xin and ZHAO Wen-Yun. API Misuse Bug Detection Based on Deep Learning[J]. Journal of Software, 2019, 30(5): 1342-1358
Authors:WANG Xin  CHEN Chi  ZHAO Yi-Fan  PENG Xin  ZHAO Wen-Yun
Affiliation:Software School, Fudan University, Shanghai 201203, China;Shanghai Key Laboratory of Data Science(Fudan University), Shanghai 201203, China,Software School, Fudan University, Shanghai 201203, China;Shanghai Key Laboratory of Data Science(Fudan University), Shanghai 201203, China,Software School, Fudan University, Shanghai 201203, China;Shanghai Key Laboratory of Data Science(Fudan University), Shanghai 201203, China,Software School, Fudan University, Shanghai 201203, China;Shanghai Key Laboratory of Data Science(Fudan University), Shanghai 201203, China and Software School, Fudan University, Shanghai 201203, China;Shanghai Key Laboratory of Data Science(Fudan University), Shanghai 201203, China
Abstract:Developers often need to use various application programming interfaces (API) to reuse existing software frameworks, class libraries, and so on. Because of the complexity of the API itself, or the lack of documentation, developers often make some API misuses, which can lead to some code defects. In order to automatically detect API misuse defects, the API use specification is required and the API is tested according to the specification. However, API specifications that can be used for automatic detection are difficult to obtain, and the cost of manual writing and maintenance is high. To address the issue, this study applies the recurrent neural network model of deep learning to the task of learning API use specifications and the task of detecting the API misuse defect. In this study, based on a large number of open source Java code, the training sample of API use specification is extracted based on static analysis method, and then use the training sample to set up the recurrent neural network to learning API use specification. On this basis, this study makes a context-based prediction on the API use code, and finds out the potential API misuse defects by comparing the prediction results with the actual code. The method above is implemented, and it is evaluated with experiments about Java encryption related APIs and their used code. The results show that the proposed approach has the ability to a certain extent to automatically detect API misuse defects.
Keywords:API misuse  usage specification  bug detection  deep learning
点击此处可从《软件学报》浏览原始摘要信息
点击此处可从《软件学报》下载全文
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号