Research and Implementation of Code Similarity Detection Technology Based on Deep Learning
Xibao Wu, Zhao Wei, Zhuo Tan, Xinyao Zhang, Wenbai Chen · 2023
To enhance code security and stability, code similarity detection techniques are crucial for identifying known software code vulnerabilities, particularly in open-source code. Traditional code clone detection methods based on Abstract Syntax Tree (AST) have shown limitations in achieving satisfactory results. To address this, researchers have turned to deep neural network models for extracting latent semantic features from code. This paper presents a novel methodology that leverages an enhanced AST to extract semantic information from the source code. A Tree-Long Short-Term Memory (Tree-LSTM) neural network is then utilized to encode the AST into function feature vectors. The similarity between code snippets is determined through cosine similarity calculations on these feature vectors. The experimental results demonstrate the significant advantages of this approach in code similarity detection, enabling effective identification and prevention of known code vulnerabilities. Thus, ensuring software security and stability.