论文标题
基于元路径的注意图检测模型
Meta-Path Based Attentional Graph Learning Model for Vulnerability Detection
论文作者
论文摘要
近年来,基于深度学习(DL)的方法已被广泛用于代码脆弱性检测中。基于DL的方法通常从源代码中提取结构信息,例如代码结构图,并采用神经网络,例如图形神经网络(GNN)来学习图表。但是,这些方法无法考虑代码结构图中的异质关系,即,异质关系意味着不同类型的边缘连接图中的不同类型的节点,这可能会阻碍图表的学习。此外,由于代码结构图中的深度级别,这些方法在捕获长期依赖性方面受到限制。在本文中,我们提出了一个基于元路径的注意力图学习模型,用于代码脆弱性检测,称为磁铁。磁铁为每个代码段构建一个多粒性元路径图,其中异质关系表示为表示结构信息的元路径。还提出了基于元路径的分层注意图神经网络,以捕获图中遥远的节点之间的关系。我们在三个公共数据集上评估磁铁,结果表明,磁铁的表现分别优于F1得分的最佳基线方法,分别为6.32%,21.50%和25.40%。磁铁还可以在检测前25个最危险的常见弱点(CWE)的所有基线方法中取得最佳性能,进一步证明了其在脆弱性检测中的有效性。
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 fail to consider the heterogeneous relations in the code structure graph, i.e., the heterogeneous relations mean that the different types of edges connect different types of nodes in the graph, 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.