A software source code vulnerability detection method based on hybrid graph neural network

By combining the hybrid graph neural network with graph convolution and gated graph neural network, combined with the focus loss function, the problems of structural information loss and sample imbalance in software source code vulnerability detection are solved, improving vulnerability detection capabilities and achieving more accurate software. Source code vulnerability detection.

CN114611115BActive Publication Date: 2024-10-29BEIJING UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210274334.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-18
Publication Date
2024-10-29
Estimated Expiration
2042-03-18

AI Technical Summary

Technical Problem

Existing software source code vulnerability detection methods lose internal structure and semantic information when processing software source code, resulting in limited model detection capabilities, and there is a serious imbalance between positive and negative samples, causing the model to tend to overfit the vulnerability-free category and cannot Effectively detect vulnerabilities in software source code.

Method used

Adopt a method based on hybrid graph neural network, use graph convolutional neural network (GCN) to extract local features of software source code, gated graph neural network (GGNN) to extract global features, and assign positive and negative samples through the focal loss function (Focal Loss) Different weights avoid model overfitting and improve vulnerability detection capabilities.

Benefits of technology

It effectively retains the structural and semantic information of the software source code, improves vulnerability detection capabilities, can better identify vulnerability characteristics in the software source code, reduces the model's dependence on non-vulnerability categories, and improves detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114611115B_ABST
    Figure CN114611115B_ABST
Patent Text Reader

Abstract

The present invention relates to a software source code vulnerability detection method based on a hybrid graph neural network, which is used to solve the problem that the internal structure and semantic information of the source code are lost during the software source code processing, and the vulnerability detection effect is poor. The method comprises: representing the source code file with an information-enhanced code attribute graph, vectorizing the information-enhanced code attribute graph and inputting it into a graph convolutional neural network to obtain a local feature matrix; and inputting it into a gated graph neural network to obtain a global feature matrix. The local feature matrix and the global feature matrix are spliced ​​and input into a classifier, and finally the detection result is output. The method can effectively retain the internal structure and semantic information of the source code. The model training uses a focal loss function to assign different weights to positive and negative samples when calculating the loss, so as to avoid the model from overfitting the sample with more non-vulnerability categories, thereby improving the vulnerability detection effect of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of software vulnerability detection, and in particular to a software source code vulnerability detection method based on a hybrid graph neural network. Background Art

[0002] With the rapid development of information technology, application software plays an important role in all aspects of the economy, military, society, etc. around the world. Vulnerabilities in application software pose a huge threat to the operational security of software systems. Once software security is compromised, it will bring huge harm and losses to individuals, enterprises and even countries. It is of great significance to develop an effective software source code vulnerability detection method, which can detect potential vulnerabilities in software source code as quickly as possible so that technicians can patch them in time and minimize the losses caused by software vulnerabilities.

[0003] With the continuous development of deep learning, more and more researchers have applied deep learning methods to the field of software vulnerability detection technology, using convolutional neural networks (CNN) and recurrent neural networks (RNN) to extract software source code features and input them into classifiers to finally output detection results. This type of sequence-based method uses a method similar to that of processing natural language to process software source code, converting the software source code into a flat sequence. However, software source code is actually more structural and logical than natural language. In the process of software source code modeling, the internal structural information and semantic information, which are critical information for identifying software source code vulnerabilities, are lost, limiting the model's ability to detect and cover various types of vulnerabilities.

[0004] In actual applications, the ratio of non-vulnerability samples to vulnerability samples is more than 40:1, and there is a serious imbalance problem between positive and negative samples. After model training, the model is more inclined to the non-vulnerability category with more samples. Most existing technologies use the cross entropy loss function, assuming that the ratio of vulnerability samples to non-vulnerability samples is 1:1, which cannot effectively solve the sample imbalance problem. Therefore, it is necessary to adopt a more effective loss function so that the model can better learn the characteristics of vulnerability samples and improve the model's ability to detect software source code vulnerabilities. Summary of the invention

[0005] In view of the above problems existing in the prior art, the present invention proposes a software source code vulnerability detection method based on a hybrid graph neural network. The graph convolutional neural network GCN is used to extract the local features of the software source code file, and the gated graph neural network GGNN is used to extract the global features of the software source code file. The local features and the global features are then spliced ​​and input into the classifier, and the detection results are finally output. The focal loss function (Focal Loss) is used to give different weights to positive and negative samples when calculating the loss, so as to avoid overfitting samples with more non-vulnerability categories during model training and improve the vulnerability detection capability of the model.

[0006] To achieve the above object, the present invention provides a software source code vulnerability detection method based on a hybrid graph neural network, comprising the following:

[0007] A software source code vulnerability detection method based on a hybrid graph neural network includes the following steps:

[0008] Step A: Obtain a code attribute graph of the source code file to be detected, add the encoding sequence information of the source code file to the code attribute graph to obtain an information-enhanced code attribute graph, and the nodes in the graph correspond to one or more keywords in the source code file.

[0009] Step B: Vectorize the information-enhanced code attribute graph to obtain the source code representation G. The vectorization includes the vectorization of the nodes in the graph and the vectorization of the edges connecting the nodes.

[0010] Step C: Input the source code representation G into the graph convolutional neural network GCN to obtain the local feature matrix H l ; Input the source code representation G into the gated graph neural network GGNN to obtain the global feature matrix H g .

[0011] Step D: Transform the local feature matrix H l and the global feature matrix H g After splicing, input the classifier and finally output the detection result.

[0012] The code attribute graph after information enhancement described in step A is specifically:

[0013] The encoding order information of the source code file is added to the code attribute graph, and the nodes in the graph that have encoding order relations are connected using the encoding order information edge E scs Connect them to get the code attribute graph after information enhancement. The code attribute graph after information enhancement is as follows Figure 3 As shown in the figure, the types of edges in the code attribute graph after information enhancement are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs , the abstract syntax information edge E ast Refers to the grammatical and structural relationship between keywords; control flow information edge E cfg Refers to all paths that may be traversed during program execution. The choice of path is determined by conditional statements; data flow information edge E dfg Refers to the usage of each keyword, including keyword access and modification; encoding sequence information edge scs Refers to the natural order of keywords in the source code.

[0014] The vectorization of the nodes described in step B is specifically as follows:

[0015] Vectorize the nodes in the information-enhanced code attribute graph. The nodes correspond to the keywords in the source code file. Use the set of all keywords as the corpus to pre-train the word embedding model Word2Vec. Then use the pre-trained word embedding model Word2Vec to convert the keywords into d-dimensional numerical vectors v to obtain the graph node matrix V, V∈R m×d , where m is the total number of nodes in the graph, and d is the dimension of the numerical vector corresponding to each node;

[0016] The vectorization of the connecting edges between nodes described in step B is specifically as follows:

[0017] The edges between nodes in the information-enhanced code attribute graph are vectorized. The edges between nodes in the enhanced code attribute graph are represented by the adjacency matrix A, A∈{0,1} k×m×m , m is the total number of nodes, k is the total number of edge types, k = 4, the four types of edges are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs ,in, is an element in the adjacency matrix A When it is equal to 1, it means that the node v with sequence number i i and node v with sequence number j j There are edges of type p between them, When it is equal to 0, it means that the node v with serial number i i and node v with sequence number j j There is no edge of type p between them;

[0018] Finally, the information-enhanced code attribute graph can be expressed as G = (V, A), where V is the graph node feature matrix and A is the graph adjacency matrix.

[0019] The step C is specifically as follows:

[0020] Step C-1: Source code representation G input graph convolutional neural network GCN to obtain local feature matrix H l , where the graph convolutional neural network is composed of the first graph convolutional layer GraphConv1 and the second graph convolutional layer GraphConv2 in sequence. The first graph convolutional layer GraphConv1 aggregates the information of each node and its adjacent nodes in the source code representation G to update the feature vector of each node in the code attribute graph after information enhancement. Then, the second graph convolutional layer GraphConv2 aggregates the information of each node and its adjacent nodes again to update the feature vector of each node again to obtain the local feature matrix Hl , the formula is as follows:

[0021] H l =GraphConv2(GraphConv1(G)) (1)

[0022] Step C-2: Assume that the source code representation G is input into the gated graph neural network GGNN and after T time, the global feature matrix H is obtained g At each time t (t≤T), each node in the information-enhanced code attribute graph receives information from adjacent nodes and sends information to adjacent nodes at the same time. By aggregating all nodes with node v at time t-1 i Get node v with the information of adjacent nodes connected by edges of type p i The updated state vector The update formula is as follows:

[0023]

[0024] in, is the adjacency matrix A corresponding to the edge of type p in A p The transpose of W p is the weight matrix, b is the bias term, It is the transpose of the hidden state vector of the nodes numbered 1, …, m at time t-1.

[0025] Step C-3: Accumulate the node v at time t-1 i The updated state vector is obtained by updating information through k different types of edges, and then the gated recurrent unit GRU is combined with the node v at time t-1 i The hidden state vector Get the node v at the current time t i The hidden state vector The specific expressions are as follows:

[0026]

[0027] in, Represents the node v at time t i The hidden state vector of GRU represents the gated recurrent unit, and SUM represents the accumulation function;

[0028] At time T, concatenate the hidden state vectors of all nodes in the vertex set V to obtain the global feature matrix H g , the formula is as follows:

[0029]

[0030] Where m is the total number of nodes in the vertex set V, is the node v at time T iThe hidden state vector of .

[0031] The classifier is composed of a first one-dimensional convolutional layer, a first one-dimensional global pooling layer, a second one-dimensional convolutional layer, a second one-dimensional global pooling layer, a fully connected layer and an activation function Sigmoid in sequence.

[0032] During the training process, the focal loss function is used to assign different weights to positive and negative samples according to the ratio of positive and negative samples when calculating the loss.

[0033] Beneficial Effects

[0034] This paper proposes a software source code vulnerability detection method based on a hybrid graph neural network, which has the following advantages and beneficial effects compared with the prior art:

[0035] This method combines the enhanced code attribute graph to characterize the source code files, which can effectively retain the internal structure and semantic information of the source code; uses the graph convolutional neural network GCN to extract the local features of the software source code files, and uses the gated graph neural network GGNN to extract the global features of the software source code files, which can better mine the source code vulnerability features; uses the focal loss function (Focal Loss) to give different weights to positive and negative samples when calculating the loss, avoiding overfitting of samples with more non-vulnerability categories during model training, thereby improving the model's software source code vulnerability detection capabilities. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 , the overall framework of the model;

[0037] Figure 2 Source code file example;

[0038] Figure 3 An example of a code property graph after information enhancement. DETAILED DESCRIPTION

[0039] Step A: For a source code file to be detected, the source code file to be detected is as follows: Figure 2 The Joern tool is used to obtain the code attribute graph of the file. The code attribute graph includes keywords and combinations of keywords. The coding sequence information of the source code file is added to the code attribute graph to obtain the code attribute graph with enhanced information, as shown in Figure 3 As shown, the nodes in the graph correspond to keywords or combinations of keywords in the code attribute graph. For example, some nodes in the graph correspond to a keyword "x", and some nodes correspond to a combination of keywords "x", "=", "1" (x=1).

[0040] Specifically, the encoding order information of the source code file is added to the code attribute graph, and the nodes in the graph that have encoding order relations are connected using the encoding order information edge E scsConnect them to get the code attribute graph after information enhancement. The edge types in the code attribute graph after information enhancement are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs The abstract syntax information E ast Refers to the grammatical and structural relationship between keywords; control flow information edge E cfg Refers to all paths that may be traversed during program execution. The choice of path is determined by conditional statements; data flow information edge E dfg Refers to the usage of each keyword, including keyword access and modification; encoding sequence information edge scs Refers to the natural order of keywords in the source code. For example, there is a grammatical relationship between the node corresponding to the keyword "int y" and the node corresponding to the keyword "y" in the graph, so there is an abstract grammatical information edge E between them. ast ; The execution path of the program is to execute "if(y>0)" first and then execute "x=x+y". Therefore, there is a control flow information edge E between the node corresponding to "if(y>0)" and the node corresponding to "x=x+y". cfg ; When the program executes to "int x = 1", the keyword "x" is modified to 1. When the program executes to "x = x + y", the keyword "x" is modified to x + y. The usage of the keyword "x" uses the data flow information edge E between the node corresponding to "x = 1" and the node corresponding to "x = x + y". dfg Indicates that in the natural order of the source code keywords, the keyword "int" comes before the keyword "y", so there is an edge E encoding the order information between the node corresponding to the keyword "int" and the node corresponding to the keyword "y". scs .

[0041] Step B: vectorize the information-enhanced code attribute graph to obtain the source code representation G. The vectorization includes the vectorization of the nodes in the graph and the vectorization of the edges connecting the nodes.

[0042] Further, step B-1: vectorize the nodes in the information-enhanced code attribute graph, the nodes correspond to the keywords (tokens) in the source code file, use the set of all keywords as the corpus to pre-train the word embedding model Word2Vec, and then use the pre-trained word embedding model Word2Vec to convert the keywords into d-dimensional numerical vectors v, and obtain the graph node matrix V, V∈R m×d , where m is the total number of nodes in the graph and d is the dimension of the numerical vector corresponding to each node.

[0043] Step B-2: Vectorize the edges between nodes in the information-enhanced code attribute graph. The edges between nodes in the enhanced code attribute graph are represented by the adjacency matrix A, A∈{0,1} k×m×m , m is the total number of nodes, k is the total number of edge types, k = 4, the four types of edges are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs .assumed is an element in the adjacency matrix A When it is equal to 1, it means that the node v with sequence number i i and node v with sequence number j j There are edges of type p between them, When it is equal to 0, it means that the node v with serial number i i and node v with sequence number j j There is no edge of type p between them.

[0044] Finally, the information-enhanced code attribute graph can be expressed as G = (V, A), where V is the graph node feature matrix and A is the graph adjacency matrix.

[0045] Step C: Input the source code representation G into the graph convolutional neural network GCN to obtain the local feature matrix H l ; Input the source code representation G into the gated graph neural network GGNN to obtain the global feature matrix H g .

[0046] Furthermore,

[0047] Step C-1: Source code representation G input graph convolutional neural network GCN to obtain local feature matrix H l The graph convolutional neural network is composed of the first graph convolutional layer GraphConv1 and the second graph convolutional layer GraphConv2. The first graph convolutional layer GraphConv1 aggregates the information of each node and its adjacent nodes to update the feature vector of each node in the graph. Then, the second graph convolutional layer GraphConv2 aggregates the information of each node and its adjacent nodes again to update the feature vector of each node to obtain the local feature matrix H. l , the formula is as follows:

[0048] H l =GraphConv2(GraphConv1(G)) (1)

[0049] Step C-2: Assume that the source code representation G is input into the gated graph neural network GGNN and after T time, the global feature matrix H is obtainedg At each time t (t≤T), each node in the graph receives information from adjacent nodes and sends information to adjacent nodes. The initial state vector of each node is set to the numerical vector v of the node. By aggregating all nodes with node v at time t-1 i Get node v with the information of adjacent nodes connected by edges of type p i The updated state vector The update formula is as follows:

[0050]

[0051] in, is the node v at time t-1 i The updated state vector is is the adjacency matrix A corresponding to the edge of type p in A p The transpose of W p is the weight matrix, b is the bias term, It is the transpose of the hidden state vectors of the nodes numbered 1, ..., m at time t-1. The hidden state vector of each node at time t-1 is obtained by updating the initial state vector of the node at t-1 times.

[0052] Step C-3: Accumulate the node v at time t-1 i The updated state vector is obtained by updating information through k different types of edges (k=4), and then the gated recurrent unit GRU is combined with the node v at time t-1 i The hidden state Get the node v at the current time t i The hidden state vector The formula is as follows:

[0053]

[0054] in, Represents the node v at time t i The hidden state vector of Represents the node v at time t-1 i The updated state vector obtained by aggregating the information received through the edges of type p, GRU represents the gated recurrent unit, and SUM represents the accumulation function.

[0055] The gated recurrent unit contains a control gate and an update gate. The node uses the update gate to select a part of the information received at the current time t and the information received at time t-1 to retain; the reset gate is used to select a part of the information received at the current time t and the information received at time t-1 to discard. The information output by the reset gate, the information output by the update gate, and the node's own information are combined as the hidden state vector of the node at time t.

[0056] At time T, concatenate the hidden state vectors of all nodes in the vertex set V to obtain the global feature matrix H g , the formula is as follows:

[0057]

[0058] Where m is the total number of nodes in the vertex set V, is the node v at time T i The hidden state vector of .

[0059] Step D: Transform the local feature matrix H l and the global feature matrix H g After splicing, the data is input into the classifier, which is composed of a one-dimensional convolutional layer, a one-dimensional global pooling layer, a one-dimensional convolutional layer, a one-dimensional global pooling layer, a fully connected layer and an activation function Sigmoid, and finally outputs the detection result.

[0060] Step D is specifically as follows:

[0061] Step D1: The obtained local feature matrix H l And the semantic feature matrix H g The feature matrix H is obtained by splicing, and the formula is as follows:

[0062] H = Concat(H l ,H g ) (5)

[0063] Step D2: Input the feature matrix H into the classifier. The classifier is composed of a one-dimensional convolution layer Conv1D1, a one-dimensional global pooling layer MaxPool1D1, a one-dimensional convolution layer Conv1D2, a one-dimensional global pooling layer MaxPool1D2, a fully connected layer Linear and an activation function Sigmoid. The processing process is as follows:

[0064] After H passes through the one-dimensional convolution layer Conv1D1 and the one-dimensional maximum pooling layer MaxPool1D1, the feature matrix Z_1 formula is as follows:

[0065] Z_1=MaxPool1D1(Conv1D1(H)) (6)

[0066] After Z_1 passes through the one-dimensional convolution layer Conv1D2 and the one-dimensional maximum pooling layer MaxPool1D2, the characteristic moment Z_2 formula is as follows:

[0067] Z_2=MaxPool1D2(Conv1D2(Z_1)) (7)

[0068] Z_2 passes through the fully connected layer Linear and the activation function Sigmoid and finally outputs the detection result y. The formula is as follows:

[0069] y=Sigmoid(Linear(Z_2)) (8)

[0070] y=1 indicates that there is no vulnerability in the source code file, and y=0 indicates that there is no vulnerability in the source code file.

[0071] Obtain a software vulnerability detection system dataset, which is represented by (source code file, label), where the source code file is represented by c, and the label Y is divided into vulnerability samples (Y=1) and non-vulnerability samples (Y=0). Samples with vulnerabilities (vulnerability samples) are called positive samples, and samples without vulnerabilities (non-vulnerabilities) are called negative samples; the function files in the dataset are randomly divided into training sets, validation sets, and test sets according to a certain ratio. The model is trained on the training set. During the training process, the focal loss function (Focal Loss) is used to assign different weights to positive and negative samples when calculating the loss. The focal loss function calculation formula is as follows:

[0072]

[0073] Among them, α is the balance parameter α∈[0,1], p is the probability of the model output p∈[0,1], γ is the parameter γ∈[0,5] that adjusts the weight of positive and negative samples, Y is the label, and log is the ln function. α adjusts the weight of the loss of vulnerability samples and non-vulnerability samples, and γ reduces the loss contribution of non-vulnerability samples to avoid overfitting of non-vulnerability categories with more samples during model training, and optimizes the vulnerability detection effect of the model.

Claims

1. A software source code vulnerability detection method based on hybrid graph neural network, characterized in that: The following steps are involved: Step A: obtaining a code attribute graph of the source code file to be detected, the code attribute graph including keywords and combinations of keywords, adding the encoding sequence information of the source code file to the code attribute graph to obtain an information-enhanced code attribute graph, wherein the nodes in the information-enhanced code attribute graph correspond to keywords or combinations of keywords in the code attribute graph; Step B: vectorize the information-enhanced code attribute graph to obtain the source code representation G. The vectorization includes the vectorization of the nodes in the graph and the vectorization of the edges connecting the nodes. Step C: Input the source code representation G into the graph convolutional neural network GCN to obtain the local feature matrix H l ; Input the source code representation G into the gated graph neural network GGNN to obtain the global feature matrix H g ; Step D: Transform the local feature matrix H l and the global feature matrix H g After splicing, input the classifier and finally output the detection result.

2. A software source code vulnerability detection method based on a hybrid graph neural network as claimed in claim 1, characterized in that: The code attribute graph after information enhancement described in step A is specifically: The encoding order information of the source code file is added to the code attribute graph, and the nodes in the graph that have encoding order relations are connected using the encoding order information edge E scs Connect them to get the information-enhanced code attribute graph. The edge types in the information-enhanced code attribute graph are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs , the abstract syntax information edge E ast Refers to the existence of grammatical and structural relationships between keywords; control flow information edge E cfg Refers to all paths that may be traversed during program execution, and the choice of path is determined by conditional statements; Data flow information edge E dfg Refers to the usage of each keyword, including keyword access and modification; encoding sequence information edge scs Refers to the natural order of keywords in the source code.

3. A software source code vulnerability detection method based on a hybrid graph neural network as claimed in claim 1, characterized in that: The vectorization of the nodes described in step B is specifically as follows: Vectorize the nodes in the information-enhanced code attribute graph. The nodes correspond to the keywords in the source code file. Use the set of all keywords as the corpus to pre-train the word embedding model Word2Vec. Then use the pre-trained word embedding model Word2Vec to convert the keywords into d-dimensional numerical vectors to obtain the graph node matrix V, V∈R m×d , where m is the total number of nodes in the graph, and d is the dimension of the numerical vector corresponding to each node; The vectorization of the connecting edges between nodes described in step B is specifically as follows: The edges between nodes in the information-enhanced code attribute graph are vectorized. The edges between nodes in the enhanced code attribute graph are represented by the adjacency matrix A, A∈{0,1} k×m×m , m is the total number of nodes, k is the total number of edge types, k = 4, the four types of edges are: Abstract syntax information edge E ast , control flow information edge E cfg , data flow information edge E dfg , encoding order information edge E scs ,in, is an element in the adjacency matrix A When it is equal to 1, it means that the node v with sequence number i i and node v with sequence number j j There are edges of type p between them, When it is equal to 0, it means that the node v with serial number i i and node v with sequence number j j There is no edge of type p between them; Finally, the information-enhanced code attribute graph can be expressed as G = (V, A), where V is the graph node feature matrix and A is the graph adjacency matrix.

4. A software source code vulnerability detection method based on a hybrid graph neural network as claimed in claim 1, characterized in that: The step C is specifically as follows: Step C-1: Source code representation G input graph convolutional neural network GCN to obtain local feature matrix H l , where the graph convolutional neural network is composed of the first graph convolutional layer GraphConv1 and the second graph convolutional layer GraphConv2 in sequence. The first graph convolutional layer GraphConv1 aggregates the information of each node and its adjacent nodes in the source code representation G to update the feature vector of each node in the code attribute graph after information enhancement. Then, the second graph convolutional layer GraphConv2 aggregates the information of each node and its adjacent nodes again to update the feature vector of each node again to obtain the local feature matrix H l , the formula is as follows: H l =GraphConv2(GraphConv1(G)) (1) Step C-2: Assume that the source code representation G is input into the gated graph neural network GGNN and after T time, the global feature matrix H is obtained g At each time t, t≤T, each node in the information-enhanced code attribute graph receives information from adjacent nodes and sends information to adjacent nodes at the same time. By aggregating all nodes with node v at time t-1 i The information of the adjacent nodes connected by the edge of type p is used to obtain the node v at time t-1 i The updated state vector The update formula is as follows: in, is the adjacency matrix A corresponding to the edge of type p in A p The transpose of W p is the weight matrix, b is the bias term, is the transpose of the hidden state vector of the nodes numbered 1, ..., m at time t-1; Step C-3: Accumulate the node v at time t-1 i The updated state vector is obtained by updating information through k different types of edges, and then the gated recurrent unit GRU is combined with the node v at time t-1 i The hidden state vector Get the node v at the current time t i The hidden state vector The specific expressions are as follows: in, Represents the node v at time t i The hidden state vector of GRU represents the gated recurrent unit, and SUM represents the accumulation function; At time T, concatenate the hidden state vectors of all nodes in the vertex set V to obtain the global feature matrix H g , the formula is as follows: Where m is the total number of nodes in the vertex set V, is the node v at time T i The hidden state vector of .

5. The method for detecting software source code vulnerabilities based on a hybrid graph neural network according to claim 1, characterized in that: The classifier is composed of a first one-dimensional convolutional layer, a first one-dimensional global pooling layer, a second one-dimensional convolutional layer, a second one-dimensional global pooling layer, a fully connected layer and an activation function Sigmoid in sequence.

6. A software source code vulnerability detection method based on a hybrid graph neural network as claimed in claim 1, characterized in that: During the training process, the focal loss function is used to assign different weights to positive and negative samples according to the ratio of positive and negative samples when calculating the loss.

Citation Information

Patent Citations

  • Face expression recognition method and device, terminal and storage medium

    CN109766840A

  • Fine-grained source code vulnerability detection method based on graph neural network

    CN111259394A