In recent years, deep learning (DL)-based methods have been widely used in code vulnerability detection. The DL-based methods typically extract structural information from source code, e.g., code structure graph, and adopt neural networks such as Graph Neural Networks (GNNs) to learn the graph representations. However, these methods do not consider the heterogeneous relations in the code structure graph, i.e., different types of nodes and edges, which may obstruct the graph representation learning. Besides, these methods are limited in capturing long-range dependencies due to the deep levels in the code structure graph. In this paper, we propose a Meta-path based Attentional Graph learning model for code vulNErability deTection, called MAGNET. MAGNET constructs a multi-granularity meta-path graph for each code snippet, in which the heterogeneous relations are denoted as meta paths to represent the structural information. A meta-path based hierarchical attentional graph neural network is also proposed to capture the relations between distant nodes in the graph. We evaluate MAGNET on three public datasets and the results show that MAGNET outperforms the best baseline method in terms of F1 score by 6.32%, 21.50%, and 25.40%, respectively. MAGNET also achieves the best performance among all the baseline methods in detecting Top-25 most dangerous Common Weakness Enumerations (CWEs), further demonstrating its effectiveness in vulnerability detection.
翻译:近年来,基于深度学习(DL)的方法被广泛用于代码脆弱性检测。基于 DL 的方法通常从源代码(例如代码结构图)中提取结构性信息,例如代码结构图,并采用神经网络,如图形神经网络(GNNS)等神经网络来学习图示。然而,这些方法并不考虑代码结构图中的差异关系,即不同类型的节点和边缘,这可能会阻碍图形代表性学习。此外,由于代码结构图中的深度,这些方法在捕捉远程脆弱性方面受到限制。在本文件中,我们建议为代码Vulnerable deTection(GANGNET)采用基于元路径的注意图学习模型模型,用于学习图形图示。但是,这些方法没有考虑到代码结构图中的差异关系,即不同类型的节点和边缘,可能阻碍图形代表性学习。还提议采用基于元路径的分级图神经神经网络神经网络,以进一步捕捉图中远端点之间的关系。我们在三个公共数据集中评估了磁数据网的注意性模型模型模型,并且分别显示ASNEMARMER 25 基准值中的最佳方法。