Code defects in software seriously affect the experience and security of software users. Traditional code defect detection methods have the problem of low accuracy, while the existing methods combined with deep learning have coarse detection granularity and less than ideal detection effect. For this reason, this paper proposed a code defect detection method based on program semantics and metrics. A point-of-interest detection algorithm for code defects based on LLVM IR was designed, which used SymPas, a lightweight symbolic program slicing tool, to obtain program slices related to defective points of interest. The program slices code fragments were transformed into vector representations by a pre-trained model, and the instruction-level slicing metric, cognitive complexity metric, was fused to deeply analyze the relationships and features between the sliced statements. A hybrid model ResCNN-GRU was constructed for training to effectively fuse and learn the extracted features. The experimental results show that this paper refines the granularity of vulnerability detection by using symbolic program slicing technique, the fused semantic and metric information under the intermediate representation LLVM IR can better represent the relationships and features between the defective code statements, and the constructed hybrid model solves the time-series problem as well as the unbalanced number of samples problem to a certain extent, and comparing with several advanced methods, the accuracy of this paper's method reaches 94.1%.
LIZ, ZOUD Q, XUS H, et al. VulDeePecker: a deep learning-based system for vulnerability detection[C]//The 25th Annual Network and Distributed System Security Symposium (NDSS), 2018: 234-258.
LIZ, ZOUD, XUS, et al. SySeVR: A framework for using deep learning to detect software vulnerabilities[J]. IEEE Transactions on Dependable and Secure Computing, 2021, 19(4): 2244-2258.
[4]
PHAMN H, NGUYENT T, NGUYENH A, et al. Detection of Recurring software vulnerabilities[C]//The IEEE/ACM International Conference on Automated Software Engineering, 2010: 447-456.
[5]
ZHOUY, LIUS, SIOWJ, et al. Devign: effective vulnerability identification by learning comprehensive program semantics via graph neural networks[C]//Proceedings of the 33rd International Conference on Neural Information Processing Systems, 2019: 10197-10207.
[6]
CAOS, SUNX, BOL, et al. MVD: Memory-related vulnerability detection based on flow-sensitive graph neural networks[C]//Proceedings of the 44th International Conference on Software Engineering(ICSE), 2022: 1456-1468.
[7]
WUY, ZOUD, DOUS, et al. VulCNN: an image-inspired scalable vulnerability detection system[C]//Proceedings of the 44th International Conference on Software Engineering, 2022: 2365-2376.
[8]
RABHERUR, HANIFH, MAFFEISS. A hybrid graph neural network approach for detecting PHP vulnerabilities[C]//2022 IEEE Conference on Dependable and Secure Computing (DSC). IEEE, 2022: 1-9.
[9]
PANK, KIMS, WHITEHEADJ. Bug classification using program slicing metrics[C]//2006 Sixth IEEE International Workshop on Source Code Analysis and Manipulation, 2006: 31-42.
[10]
ZHANGY Z. SymPas: symbolic program slicing[J]. Journal of Computer Science and Technology, 2021, 36(2): 397-418.
[11]
FENGZ Y, GUOD Y, TANGD Y, et al. CodeBERT: A pre-trained model for programming and natural languages[DB/OL]. (2020-09-18)[2023-10-31].
[12]
GUIY, WANY, ZHANGH, et al. Cross-language binary-source code matching with intermediate representations[C]//2022 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), 2022: 601-612.
[13]
CHOK, VAN MERRIENBOERB, BAHDANAUD, et al. On the Properties of neural machine translation: Encoder-decoder approaches[C]//Proceedings of the 8th Workshop on Syntax, Semantics and Structure in Statistical Translation. Stroudsburg: Associationfor Computational Linguistics, 2014: 103-111.
[14]
HEK, ZHANGX, RENS, et al. Deep residual learning for image recognition[C]//IEEE conference on Computer Vision and Pattern Recognition(CVPR), 2016: 770-778.
[15]
AGNIHOTRIM, CHUGA. A systematic literature survey of software metrics, code smells and refactoring techniques[J]. Journal of Information Processing Systems, 2020, 16(4): 915-934.
[16]
闫丽. 基于切片度量的软件模块复杂性研究[D]. 南京: 南京邮电大学, 2017.
[17]
AHMEDM, SERAJR, ISLAMS M S. The k-means algorithm: A comprehensive survey and performance evaluation[J]. Electronics, 2020, 9(8): 1295.
[18]
DHRUVP, NASKARS. Image classification using convolutional neural network (CNN) and recurrent neural network (RNN): A review[C]//Machine Learning and Information Processing: Proceedings of ICMLIP 2019, 2020: 367-381.
[19]
National Institute of Standards and Technology.NIST Software Assurance Reference Dataset[EB/OL].[2023-10-31].
[20]
D’PEREIRAJ, VIEIRAM. On the use of open-source C/C++ static analysis tools in large projects[C]//2020 16th European Dependable Computing Conference (EDCC). IEEE, 2020: 97-102.
[21]
BASETA, DENNINGT. IDE plugins for detecting in-put-validation vulnerabilitie[C]//IEEE Symposium on Security and Privacy Workshops, 2017: 143-146.