Code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement
By building a lightweight program semantic graph and combining multi-dimensional feature extraction and edge semantic enhancement, the problem of redundant nodes and feature fragmentation in code vulnerability detection is solved, and the accuracy and efficiency of vulnerability detection are improved.
Patent Information
- Application Number
- CN202510716910.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-07-29
AI Technical Summary
There are problems in existing code vulnerability detection methods such as redundant nodes leading to bloated graph structure, splitting local and global features, and missing edge semantic information, which affects the efficiency and accuracy of vulnerability detection.
By compressing the AST subtree structure based on subtree folding rules, fusing the dependencies of PDG data flow and control flow, building a lightweight program semantic graph, and combining multi-dimensional feature extraction and edge semantic enhancement mechanisms, program-level global features are extracted, and potential vulnerabilities are identified using the full connection layer.
It effectively solves the problem of bloated graph structure caused by redundant nodes, takes into account syntax integrity and execution logical representation, improves the model's dynamic interactive modeling ability of heterogeneous graph edge attributes, and improves the accuracy and generalization ability of vulnerability detection.
Smart Images

Figure CN120387170A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of code detection, and in particular to a code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement. Background Art
[0002] With the rapid development of information technology, the scale and complexity of modern software systems have been continuously increasing, resulting in a significant increase in the generation rate of source code vulnerabilities. Classic vulnerability types such as buffer overflows and resource management errors have continued to dominate the CVE vulnerability database in the past decade, and their high concealment and destructiveness pose systematic risks to critical information infrastructure. Such vulnerabilities not only directly cause hazards such as data leakage and service paralysis, but may also be used by APT (Advanced Persistent Threat) attackers as a springboard for persistent penetration, leading to cascading security risks.
[0003] Traditional manual auditing and rule engine detection methods are inefficient in dealing with large-scale heterogeneous code libraries, and there is an urgent need for automated solutions. Deep learning technology has significantly improved the automation level and accuracy of source code vulnerability detection through automated feature extraction and semantic pattern learning. The code analysis method based on neural networks can efficiently extract hidden vulnerability patterns from a large number of code libraries, such as those covering various programming languages, architecture patterns, and open-source and closed-source projects. Its core breakthrough lies in the modeling ability and context awareness ability for complex code structures. In the field of code analysis, to achieve automated vulnerability detection, it is usually necessary to convert the code into a computer-parsable representation form. Currently, the mainstream technical routes are mainly divided into three categories: a) Sequence-based program representation. The code is regarded as a sequence of lexical tokens, and models such as Transformer or LSTM are used to learn local syntax and long-range dependencies. For example, the VulDeePecker detection model proposed by Li et al. generates a token sequence through code slicing and uses Bi-LSTM (Bidirectional Long Short-Term Memory) to extract features. Subsequently, Li et al. continued to develop the SySeVR vulnerability detection model based on existing research. This model has been optimized technically in multiple dimensions while inheriting the core mechanism of VulDeePecker. Compared with the previous method, SySeVR not only retains the analysis dimension of library functions and API calls but also innovatively introduces syntax feature analysis technology. By constructing a syntax parse tree, it realizes in-depth mining of key code patterns such as array operations, pointer references, and arithmetic operations. Although sequence-based program representation can effectively capture the local lexical information of the code, due to the flattening of the structure caused by the code serialization process, it is difficult to completely retain the hierarchical association characteristics of the source code. Especially in the expression of deep semantic features such as control flow jump relationships and data dependency propagation paths, there is information attenuation, which affects the accurate modeling ability of key program logic.
[0004] b) Program representation based on Abstract Syntax Tree (AST). This program representation method uses a tree structure to represent the code syntax level and uses Tree-LSTM or GNN to capture structured semantics. Usually, by using the topological connection characteristics and node type information of the AST, the syntax specification features of the source code can be systematically presented. For example, Dam et al. innovatively constructed a Tree-LSTM network architecture, directly combining the hierarchical node distribution characteristics of the AST with a deep learning model. By introducing node vector embedding technology, this model captures both the structured syntax features of the program and the semantic association characteristics between symbols during the encoding process. However, the inherent redundant node structure of the AST will introduce noise information, and its static syntax representation method is difficult to comprehensively capture the dynamic features during program execution, which has a significant impact on the accuracy of vulnerability detection.
[0005] c) Graph-based program representation. This method models program dependencies through the topological relationships of nodes and edges, and can effectively capture the dynamic semantic features of control flow and data flow. Zhou et al. proposed a vulnerability detection method that integrates Code Property Graph (CPG) and natural word order information. This method constructs a joint graph structure based on Gated Graph Neural Network (GGNN), and significantly enhances the interpretability of complex code structures by integrating multi-dimensional semantic information from Abstract Syntax Tree (AST), Control Flow Graph (CFG), and Program Dependence Graph (PDG). Duan et al. constructed CPG using AST and CFG, introduced an attention mechanism to achieve fine-grained detection, and their path decomposition technology can filter redundant nodes and reduce the feature overlap rate. Cao et al. introduced reverse edges through a bidirectional graph neural network, expanding the scope of node information propagation. Regarding the problem of graph structure complexity, Wu et al. proposed to simplify the code property graph, only retaining the core components of AST and CFG, combining hierarchical graph readout functions and residual connection technologies. In addition, introducing LLVM intermediate representation can compress instruction-level semantics, reduce the number of graph nodes, and relieve the computational storage pressure.
[0006] Although a large number of vulnerability detection methods based on graph neural networks have made certain progress, there are still the following deficiencies.
[0007] a) Redundant nodes lead to bloated graph structures. Existing heterogeneous graph construction methods usually directly rely on Abstract Syntax Tree, Control Flow Graph, or Program Dependence Graph, without effectively screening or fusing nodes, resulting in large-scale and redundant program graphs. This not only increases the computational overhead of the model but also interferes with the capture of key semantic features, restricting the improvement of vulnerability detection performance.
[0008] b) Disconnection between local and global features. Current feature modeling methods mainly focus on the local syntactic or data dependence features of nodes, often ignoring the correlation between vulnerability patterns and the program's global context, resulting in insufficient ability of the model to depict the evolution features of vulnerabilities under different code structures and scopes, and affecting the generalization ability of detection.
[0009] c) Lack of edge semantic information. When dealing with program graphs, existing mainstream graph neural networks mostly model node interactions with simple adjacency relationships, lacking the modeling of different types of edge semantics and being difficult to achieve dynamic collaborative updates of edge attributes and node features. Therefore, they cannot fully utilize the complex semantic connections within the program, restricting the accuracy of vulnerability detection. Summary of the Invention
[0010] To address the above technical problems, the present invention provides a code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement.
[0011] The present invention is implemented by the following technical solutions: A code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement, comprising the following steps: Step S1: On the basis of retaining the high-level syntax framework of the AST, compress the AST subtree structure based on the subtree folding rule, and fuse the data flow and control flow dependencies of the PDG to construct a lightweight program semantic graph; Step S2: Extract the multi-dimensional features of the nodes from the program semantic graph, combine the edge semantic enhancement mechanism to extract the global features at the program level, and perform vector representation; Step S3: Input the program semantic graph features into the fully connected layer to identify potential vulnerabilities and output the detection results.
[0012] Specifically, the step S1 specifically includes: Step S11: Construct a hierarchical fusion strategy based on AST and PDG, remove redundant details while retaining the syntax framework, and perform structure compression; Step S12: Introduce the control and data dependencies of the PDG, dynamically model the program execution semantics, and construct a lightweight program graph representation with both syntactic integrity and semantic logic.
[0013] Specifically, the step S11 specifically includes: Establish a node fusion rule based on the minimum complete subtree MCS. Let be any subtree in the AST, and denote its leaf node set as , and for each leaf node , the corresponding source code line number is . When and only when two conditions are satisfied simultaneously, is determined to be an MCS; where, is the abstract syntax tree and , is the node set, and each node is represented by a quadruple . represents the syntax type of the node, represents the specific syntax unit of the node, refers to the code line number where the node is located, represents the set of child nodes of the node, is the edge set describing the parent-child relationship between nodes; For the root node of each MCS, fold its entire subtree into a statement node , Inherit the syntax type of the root node of the subtree and the content of the corresponding code line, while preserving the parent node in the original AST and the hierarchical relationship; for high-level AST nodes that are not MCS, the original structure is maintained.
[0014] Specifically, the two conditions for determining an MCS are specifically as follows: All the source code line numbers corresponding to the leaf nodes of the subtree are exactly the same, that is, there exists a certain code line number such that for any leaf node , all satisfy ; On the premise of satisfying the line number consistency, the subtree should not contain smaller true subtrees that satisfy the same line number condition, that is, there does not exist any true subtree such that its leaf nodes are still all located on the line numbers corresponding to , and .
[0015] Specifically, the step S12 specifically includes: Perform node alignment operations. In the folded AST, locate the statement node corresponding to each statement node in the PDG according to the code line number consistency ; Inject the data dependence edges and control dependence edges in the PDG into the semantic graph in units of statement nodes to obtain a lightweight program semantic graph.
[0016] Specifically, the multi-dimensional features of the nodes extracted in the step S2 specifically include: Code semantic features based on text sequences: For the statement node , split its corresponding code text into a Token sequence , generate an initial embedding through the pre-trained CodeBERT model, and input it into the Bi-LSTM network to capture context-sensitive semantics, and finally obtain the semantic feature representation of the node ; Hierarchical syntax features based on tree structure: Use CodeBERT to embed the content of each node in the subtree to generate an initial feature representation of the node; combine the type information of the node to assign a type feature to each node; use the Tree-LSTM model to hierarchically model the content feature and type feature of the node to capture the local and global syntax dependence relationships in the AST subtree, and generate the node syntax feature representation ; Context Constraint Features Based on Scope Path: Establish a hierarchical context encoding mechanism based on the scope path. By constructing the scope nested path of a statement node in the AST starting from the statement node, explicitly retain the syntactic structure environment where the statement is located, and provide more discriminative context features.
[0017] Specifically, the hierarchical context encoding mechanism specifically includes: For any statement node , identify its corresponding leaf node position in the program semantic graph, and trace back along the parent node reference chain from bottom to top to the root node to obtain a complete syntactic scope path; Establish a scope boundary type screening rule, and only retain node types with control or semantic constraint capabilities, as well as the type of the statement node itself; Use a bidirectional long short-term memory network Bi-LSTM to model the path. Regard the scope path as a sequence of node types and input it into the model. The model captures bidirectional semantics from both the start and end points of the path, learns the context interaction relationship between nodes in the path, and take the hidden state of the model in the last layer as the semantic vector of the path, denoted as .
[0018] Specifically, the extraction of the multi-dimensional features of the node also includes dynamically fusing the multi-dimensional features of the node, specifically including: Through the attention mechanism, calculate the mutual influence between different features to obtain the weight of each feature dimension , and the formula is: ; Among them, is a learnable query vector, is the feature dimension, is the multi-dimensional feature of the node; Generate a basic feature representation by weighted summation , and the formula is: ; Use a gating mechanism to perform weighted fusion on the features, so as to strengthen the influence of important features and suppress the interference of irrelevant features, denoted as: ; Among them, is the Sigmoid activation function, represents the Hadamard product; Perform a residual connection on the weighted fusion feature and the original feature to obtain the feature fusion formula as: .
[0019] Specifically, the edge semantic enhancement mechanism specifically includes: For the semantic graph , set the initial edge embedding matrix according to different edge types , and use MLP to dynamically update the edge attributes. The formula is: ; Among them, the program semantic graph , is the set of nodes, is the set of AST edges, and respectively represent the control dependence edge set and the data dependence edge set; t is the number of edge types, d is the edge embedding dimension, represents the initial edge attribute. For each edge , extract the corresponding embedding vector of from the embedding matrix through the edge type index, and ; and are the feature representations of nodes and respectively, represents the vector concatenation operation, and MLP is a multi-layer perceptron used to map the concatenated vector to a new feature space; For any node and its neighbor node , use the shared linear mapping W and the learnable attention vector to calculate the attention weight . The calculation formula is: ; Use the calculated attention weight , through the message passing mechanism, jointly update the feature of node by combining the edge information and the neighbor nodes. The node update formula is: .
[0020] Specifically, the step S2 further includes: After obtaining the final node features, aggregate the features of all nodes in the graph into a graph-level representation to input into the classifier. Based on the attention-weighted pooling mechanism, dynamically distinguish the importance of nodes through learnable parameters. The calculation formula is: ; ; Among them is the weight matrix, is the bias term; Finally, the graph-level representation Predict whether there are vulnerabilities through the fully connected layer and the Sigmoid function.
[0021] The beneficial effects of the present invention are as follows: On the basis of retaining the AST high-level syntax framework, the present invention compresses the AST subtree structure based on the subtree folding rule, and integrates the data flow and control flow dependencies of the PDG to construct a lightweight program semantic graph, effectively solving the problem of bloated graph structure caused by redundant nodes, and taking into account both syntax integrity and execution logic representation. In addition, the scope path feature is innovatively introduced, combined with the multi-dimensional feature collaborative coding mechanism, to extract the local syntax, semantics and context constraint features of statement nodes from three dimensions: code text sequence, AST subtree structure and scope path, and use the dynamic attention fusion strategy to achieve cross-dimensional information interaction to prevent the separation of local and global features. In addition, an edge semantic enhancement module based on the Multi-Layer Perceptron (MLP) is constructed to strengthen the differential propagation of logical dependencies between nodes, thereby enhancing the dynamic interaction modeling ability of the graph neural network for heterogeneous graph edge attributes. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on the structures shown in these drawings.
[0023] Figure 1 [[ID=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36]] Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 It is the overall model architecture diagram of multi-dimensional feature fusion and edge semantic enhancement in the embodiment of the present invention; Figure 2 It is the schematic diagram of program semantic graph construction in the embodiment of the present invention; Figure 3 It is an example of the program semantic graph in the embodiment of the present invention; Figure 4 It is the schematic diagram of multi-dimensional feature extraction of statement nodes in the embodiment of the present invention; Figure 5 It is the schematic diagram of the edge semantic enhancement mechanism in the embodiment of the present invention; Figure 6 It is the comparison of the accuracy rates of different methods for various types of vulnerabilities in the embodiment of the present invention; Figure 7 It is the comparison of the precision rates of different methods for various types of vulnerabilities in the embodiment of the present invention; Figure 8 It is the comparison of the recall rates of different methods for various types of vulnerabilities in the embodiment of the present invention; Figure 9 It is the comparison of the F1 values of different methods for various types of vulnerabilities in the embodiment of the present invention. Specific Embodiments
[0024] To make the objectives, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Components of the embodiments of the present invention generally described and illustrated in the drawings herein may be arranged and designed in a variety of different configurations.
[0025] It should be noted that: like reference numerals and letters denote like items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0026] The following combines the attached Figures 1-9 drawings to elaborate on some embodiments of the present invention. Without conflict, the following embodiments and the features in the embodiments may be combined with each other.
[0027] The present invention proposes a code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement. The overall architecture is as Figure 1 shown, and mainly includes: Program Semantic Graph Construction: On the basis of retaining the high-level syntax framework of the AST, the AST subtree structure is compressed according to the subtree folding rule, and the data flow and control flow dependencies of the PDG are fused to construct a lightweight program semantic graph.
[0028] Feature Extraction: Extract multi-dimensional features of nodes from the program semantic graph, and combine the edge semantic enhancement mechanism to extract program-level global features and perform vectorization representation.
[0029] Classification and Detection: Input the program semantic graph features into the fully connected layer to identify potential vulnerabilities and output the detection results.
[0030] The following elaborates on the technical features of each part of the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement in combination with specific embodiments: I. Program Semantic Graph Construction Traditional AST and PDG each have their own advantages in program semantic modeling but also have obvious limitations. AST can better reflect the syntax structure and hierarchical relationship of code, retaining the syntax context between statements. However, the node granularity of AST is relatively fine, containing a large number of low-level syntax details, which easily introduces a large number of redundant nodes during the graph construction process, leading to the expansion of the graph structure, and then affecting the model training efficiency and generalization ability. At the same time, AST lacks the description of logical dependencies during program execution and is difficult to capture deep semantic features. In contrast, PDG explicitly models the semantic logic of the program through data dependency and control dependency edges, which helps to mine the path features of potential vulnerability behaviors. However, its structure usually does not contain a complete syntax organization and easily ignores the context constraints of statements at the syntax level, restricting the integrity of its semantic expression. Existing work usually fuses AST, CFG, and PDG into a multi-graph to construct a unified heterogeneous graph structure to enhance the code representation ability. However, this type of fusion method often does not effectively screen the nodes in the graph, resulting in a large amount of redundant information mixing into the graph structure, which not only increases the computational burden but also interferes with the model's attention to key structures and affects the overall learning effect.
[0031] To address the above problems, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in the present invention proposes a hierarchical fusion strategy based on AST and PDG, removing redundant details while retaining the syntax framework, and performing structure compression. On this basis, the control and data dependency relationships of PDG are introduced to dynamically model the program execution semantics, thereby constructing a lightweight program graph representation with both syntax integrity and semantic logic, improving the accuracy and efficiency of code semantic modeling.
[0032] (1) Related Definitions Abstract Syntax Tree , where is the node set, and each node is represented by a quadruple . Specifically, represents the syntax type of the node, such as assignment, definition, loop, etc., represents the specific syntax unit of the node, such as operator, literal, etc., refers to the line number of the code where the node is located, and represents the set of sub-nodes of the node. The edge set describes the parent-child relationship between nodes.
[0033] Program Dependence Graph where represents the node set of the graph, and each node corresponds to a line of statement in the code. and represent the sets of data dependency edges and control dependency edges respectively.
[0034] Program semantic graph . Among them, is a set of nodes, including the nodes in the original AST and the statement nodes generated by folding subtrees, is a set of AST edges, representing the syntactic structure relationships in the AST, and represent the control dependence edge set and the data dependence edge set respectively.
[0035] (2)Fusion strategy The high-level AST nodes correspond to function declarations and control flow statements, such as the syntactic skeleton units like if and for, which are responsible for defining the global logical framework of the code. The low-level nodes represent fine-grained syntactic units such as identifiers and operators. To reduce the number of nodes and compress the graph scale, a node fusion rule based on the Minimal Complete Subtree (MCS) is designed, and the MCS determination rule is as follows.
[0036] Let be any subtree in the AST, and denote its set of leaf nodes as , and the source code line number corresponding to each leaf node is . Then is determined to be an MCS if and only if the following two conditions are satisfied simultaneously: a) Line number consistency. It is required that the source code line numbers corresponding to all leaf nodes of a certain subtree must be exactly the same. That is, there exists a certain code line number , such that for any leaf node , it satisfies ; b) Subtree minimality. On the premise of satisfying line number consistency, the subtree should not contain a smaller proper subtree that satisfies the same line number condition. That is, there does not exist any proper subtree such that all its leaf nodes are still on the line numbers corresponding to , and .
[0037] For each MCS root node , fold its entire subtree into a statement node , inherits the syntactic type and the corresponding code line content of the subtree root node, and at the same time retains the parent node of in the original AST and the hierarchical relationship of . For the high-level AST nodes that are not MCSs, such as function declarations and control flow blocks, keep the original structure to ensure the integrity of the program logic framework and facilitate the association between vulnerability patterns and the global context in the subsequent feature extraction process.
[0038] As Figure 2 shown, after completing the subtree folding, to ensure a comprehensive representation of the program semantics, the dependency relationships of the PDG are further embedded into the optimized AST through anchor mapping. First, a node alignment operation is performed, that is, in the folded AST, the statement nodes corresponding to each statement node in the PDG are located according to the consistency of the line numbers of the code . Subsequently, the data dependency edges and control dependency edges in the PDG are injected into the semantic graph in units of statement nodes
[0039] An example of the program semantics diagram is as Figure 3 shown. In this embodiment, the program semantics graph construction algorithm is as follows Algorithm 1 Program Semantics Graph Construction Algorithm Input: AST = , PDG =
[0040] Output:
[0041] a) Initialize the node set V and edge set of the semantic graph , ,
[0042] b) For each node n ∈ N do c) If n is the root node of MCS then d) Traverse the subtree , collect all the children's ( , c), and generate a Token sequence e) Create a new statement node ; f) .τ = n.τ; g) .c = the source code text of the corresponding line h) .l = n.l; i) .χ = ∅; j) Update V ← V ∪ { }; k) Update , add the high-level AST node to the AST edge of l) Delete the children of n m) Otherwise, retain n and its AST edge with the parent node, and add them to V and ; n) end for o) for each node v ∈ do p) Obtain the corresponding one by matching the line numbers ∈ V; q) Inject and edges into Gu; r) end for s) return Gu II. Feature extraction (1) Node multi-dimensional feature extraction For the constructed program semantic graph, the high-level AST nodes adopt label encoding based on node types and use it as structural features to input into the model to provide global syntax guidance. For the low-level statement nodes, during the construction of the program semantic graph, redundant syntax units are aggregated through a graph fusion strategy, significantly reducing the scale of the graph and improving the computational efficiency. However, this also leads to the loss of some local syntax information, thus weakening the model's ability to model complex syntax structures and micro-code patterns.
[0043] To alleviate this problem, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed by the present invention proposes a multi-dimensional feature extraction strategy. As Figure 4 shown, while retaining the global syntax framework, by co-modeling semantic constraints, syntactic details, and context information, the syntax units are efficiently characterized from multiple dimensions, enhancing the model's perception ability of diverse vulnerability patterns. The specific feature extraction involved includes: (a) Code semantic features based on text sequences The code text contains rich semantic information, and its sequence of lexical units (tokens) can represent the program logic. For the statement node , first split its corresponding code text into a Token sequence , where contains basic elements such as variable names and operators. Generate initial embeddings through the pre-trained CodeBERT model and input them into a Bi-LSTM network to capture context-sensitive semantics, and finally obtain the semantic feature representation of the node .
[0044] (b) Hierarchical syntax features based on tree structures To fully extract the features of the AST subtree, modeling is performed from two dimensions: the content and type of the nodes. First, CodeBERT is used to embed the content of each node in the subtree to generate the initial feature representation of the node. At the same time, combined with the type information of the node, a type feature is assigned to each node to more comprehensively reflect its syntactic role. Then, the Tree-LSTM model is used to hierarchically model the content features and type features of the nodes to capture the local and global syntactic dependencies in the AST subtree. Finally, the syntactic feature representation of the node is generated 。
[0045] (c) Context Constraint Features Based on Scope Path To effectively capture the structured context constraints of statement nodes in the program and enhance the model's ability to understand global semantics, a hierarchical context encoding mechanism based on scope paths is proposed. This mechanism constructs the scope nesting path of a statement node in the AST starting from the statement node, explicitly retaining the syntactic structure environment where the statement is located, thereby providing more discriminative context features, including the following steps: The first step is path extraction and construction. For any statement node , first identify its corresponding leaf node position in the program semantic graph, and trace back along the parent node reference chain from bottom to top to the root node to obtain a complete syntactic scope path. This path records the nesting of the statement in structures such as function bodies, conditional branches, and loop blocks, and can truly reflect the execution context and control domain of the statement. For example, Figure 2 the statement ; in corresponds to the path [Func, IfStatement, CompoundStmt, IfStatement, Condition, BinExpr], indicating that it is nested in multiple judgment statements and function definitions.
[0046] Step 2: Node Screening and Type Specification. To avoid redundant or semantically unproductive structural nodes in the path, a set of scope boundary type screening rules are defined. Specifically, only node types with control or semantic constraint capabilities are retained, including: Function Declarations (FunctionDecl), Conditional Statements (IfStmt), Loop Structures (ForStmt, WhileStmt), Code Blocks (CompoundStmt), Exception Structures (TryStmt, CatchStmt), Branch Controls (SwitchStmt, CaseStmt, DefaultStmt), Return and Conditional Nodes (ReturnStmt, Condition), Lambda Expressions, etc. Additionally, the types of the statement nodes themselves are also retained to fully describe the semantic context at the end of the path. Through this strategy, it is ensured that the scope path only retains the structural levels that have a decisive impact on the program behavior, improving the quality of context encoding.
[0047] Step 3: To model the hierarchical information and semantic dependency relationships in the path, a Bidirectional Long Short-Term Memory Network (Bi-LSTM) is used to model the path. Regarding the scope path as a sequence of node types and inputting it into the model, the Bi-LSTM can capture bidirectional semantics simultaneously from both the start and end points of the path, learning the context interaction relationships among the nodes in the path. Finally, the hidden state of the model at the last layer is taken as the semantic vector representation of the path. 。
[0048] (d) Feature Fusion After obtaining the multi-dimensional features of the statement nodes, a comprehensive representation needs to be generated. Traditional feature fusion methods such as feature concatenation and linear addition, although having high computational efficiency, are difficult to effectively model the non-linear interaction relationships between different features due to the adoption of static fusion strategies. Therefore, this invention adopts a dynamic attention fusion method, leveraging lightweight attention and gating strategies to dynamically learn the importance differences among features and enhancing the fusion stability through residual connections.
[0049] First, through the attention mechanism, the mutual influence between different features is calculated to obtain the weight of each feature dimension , where is a learnable query vector, is the feature dimension, and the weight expression is: (1) Subsequently, a weighted summation method is used to generate the basic feature representation , and the expression is: (2) Next, a gating mechanism is used to perform weighted fusion on the features, thereby strengthening the influence of important features and suppressing the interference of irrelevant features. is the Sigmoid activation function. represents the Hadamard product, and the expression is: (3) Finally, a residual connection is made between the features after weighted fusion and the original features. The relevant formulas for feature fusion are as follows: (4) (2) Edge semantic enhancement In traditional Graph Convolutional Networks (GCNs), all edges are uniformly processed, ignoring the different impacts of different edge types on node feature updates. In Graph Attention Networks (GATs), although an attention mechanism is introduced to dynamically calculate the importance of neighbor nodes, it is still assumed that all edges are homogeneous, and no dedicated parameters are introduced for different types of edges. To better capture the different impacts of multiple edge types on node features, the present invention integrates edge semantic information on the basis of existing GATs to construct a GAT network with enhanced edge semantics, dynamically encoding the semantic attributes of edges, enabling the model to implicitly learn the impacts of different types of edges. The specific process is as follows.
[0050] (a) Dynamic update of edge attributes For the semantic graph , each edge e has a semantic attribute, and different edges may belong to different edge types. An initial edge embedding matrix is set according to different edge types, where is the number of edge types, is the edge embedding dimension. For each edge , , the corresponding embedding vector is taken from the embedding matrix as the initial edge attribute . As shown in Figure 5 (a), in order to fully consider the association between edge attributes and node features, an MLP is used to dynamically update the edge attributes. The update formula is as follows: (5) where and are the feature representations of nodes and respectively, represents the vector concatenation operation, and the MLP is a multi-layer perceptron used to map the concatenated vector to a new feature space.
[0051] (b) Edge-based attention weight calculation For any node and its neighbor nodes , using the shared linear mapping W and the learnable attention vector , calculate the attention weight : (6) The non-linear activation function uses LeakyReLU. Its advantage is that it can alleviate the "neuron death" problem that may occur in the traditional ReLU in the negative value region, while retaining the non-linear expression ability, making the model more stable and having stronger feature learning ability.
[0052] (c) Node feature update As shown in Figure 5 (b), using the calculated attention weight , through the message passing mechanism, jointly update the node 's features by combining edge information and neighbor nodes. The node update formula is as follows: (7) By dynamically encoding the semantic attributes of edges, the model can adaptively learn the influence of different types of edges on node feature updates, thereby effectively capturing the different roles of different edge types such as data flow, control flow, and AST structure in node information transmission, further improving the model's understanding and feature expression ability of complex graph structures. It avoids the limitation of the one-size-fits-all treatment of all edge types in traditional models, and more flexibly and accurately reflects the feature heterogeneity of various edges in the graph structure.
[0053] (3) Graph-level pooling and classification After obtaining the final node features, the node features of the entire graph need to be aggregated into a graph-level representation for input to the classifier. Traditional mean / max pooling methods assume that each node contributes equally, but in code vulnerability detection, the semantic contributions of key nodes, such as nodes with sensitive API calls like strcpy and free, are significantly higher than those of ordinary nodes. Therefore, an attention-weighted pooling mechanism is designed to dynamically distinguish the importance of nodes through learnable parameters, and its calculation process is defined as: (8) (9) where is the weight matrix, the bias term. Finally, the graph-level representation is predicted for the presence or absence of vulnerabilities through a fully connected layer and the Sigmoid function.
[0054] In this embodiment, corresponding experiments were also set up for result analysis. This experiment was based on the PyTorch 1.12.1 deep learning framework and CUDA 11.3 for model training. The dataset was divided into a training set and a test set in a ratio of 8:2, and the training batch size was set to 32 to avoid loss of feature details caused by too large a batch. The optimizer used was Adam, and the initial learning rate was set to 5×10−4. The experiment verified that this learning rate could converge stably under this model structure. The feature embedding dimension was set to 128, and the edge semantic embedding dimension was 64, which was used to reduce the computational complexity of heterogeneous graph modeling. This dimension configuration had been verified by ablation experiments and could effectively integrate multi-source information such as code text, AST structure, and scope path. Dropout was introduced into the fully connected layer after feature fusion, and the ratio was set to 0.3 to mitigate the overfitting risk brought by multi-dimensional features. The loss function used was binary cross-entropy (Cross-Entropy), and no class weight factor was introduced, mainly considering the relatively balanced class distribution in the dataset. The upper limit of the number of training epochs was set to 60. The model usually converged within the 30th to 40th epochs, and an early stopping strategy (Patience = 10) was set to prevent overfitting, ensuring the training efficiency and stability.
[0055] The code samples used in the dataset were sourced from C / C++ code in the Software Assurance Reference Dataset (SARD), containing 42,490 function-level samples. Among them, 16,811 samples contained vulnerabilities, and 25,679 were normal samples, covering 6 common software vulnerabilities such as buffer overflow and resource leakage. The specific categories and data distributions are shown in Table 1.
[0056] Table 1 Vulnerability Data Types
[0057] The confusion matrix provides a detailed analysis of classification performance by recording the relationship between the model's prediction results and the true labels. Table 2 defines four cases of the confusion matrix: True Positive (TP) represents the number of functions correctly predicted to contain vulnerabilities, False Positive (FP) represents the number of functions wrongly predicted to contain vulnerabilities, True Negative (TN) represents the number of functions correctly predicted to not contain vulnerabilities, and False Negative (FN) represents the number of functions wrongly predicted to not contain vulnerabilities.
[0058] Table 2 Confusion Matrix
[0059] Based on the confusion matrix, the following evaluation metrics are adopted: Accuracy (A) reflects the overall prediction accuracy of the model, Precision (P) represents the proportion of codes predicted as vulnerabilities that are actually vulnerabilities, Recall (R) measures the model's ability to identify vulnerability instances, and the F1 value (F1-Score, F1) is the harmonic mean of Precision and Recall, used to balance the performance of the two. The relevant calculation formulas are as follows: (10) (11) (12) (13) To evaluate the performance advantages of the proposed vulnerability detection method, four representative baseline methods were selected for horizontal comparison experiments: LineVul, LineVD, MGVD, and VulMPFF methods. To ensure comparability, all experiments were conducted under the same data partitioning strategy, and each group of configurations was independently repeated 5 times to eliminate the influence of randomness. Figure 6 The comprehensive performance comparison results of each method on the dataset are summarized.
[0060] 1) LineVul is based on the pre-trained model CodeBERT, uses BPE tokenization to generate context-aware token representations, and models the semantics and context relationships of source code through the self-attention mechanism of Transformer.
[0061] 2) LineVD captures control and data dependency information between statements by constructing a PDG, and learns the semantic security features of each statement in the way of node classification. At the same time, the pre-trained model CodeBERT is introduced to encode semantic information, and a joint feature fusion mechanism is designed to collaboratively model at both the function level and the statement level.
[0062] 3) MGVD proposes a multi-graph fusion representation method, constructs statement-level subgraphs to reduce the graph scale, and improves the GNN's ability to model fine-grained features. By introducing CNN and SENet modules, multi-channel features are adaptively fused, enhancing the detection ability for multiple types of vulnerabilities.
[0063] 4) VulMPFF extracts features from three perspectives: code sequences, lexical and syntactic relationships, and graph structures, uses serialized AST and CPG as intermediate representations, learns and fuses features with Bi-LSTM and GNN, and introduces a double attention mechanism to highlight key information.
[0064] Table 3 Detection results of different methods
[0065] The experimental results show that the detection method in this paper is significantly superior to the existing mainstream baseline models in terms of comprehensive performance. As shown in Table 3, this method leads comprehensively with an accuracy of 93.1% and an F1 value of 92.8%. It achieves a 0.3% accuracy improvement and a 2.2% F1 gain compared to the best baseline VulMPF, and the precision and recall reach the optimal balance, verifying the effectiveness of the multi-dimensional feature fusion and edge semantic enhancement mechanisms. Specifically: 1) For the pure sequence model LineVul, by introducing syntactic structure and context path features, the F1 value of this method is increased by 3.4%, proving that structured features can effectively make up for the deficiency of the pure text model in modeling code logic. Compared with the multi-graph fusion method MGVD, the dynamic edge semantic encoding mechanism improves the recall rate by 7.6% by adaptively capturing cross-layer dependency relationships; compared with the multi-view framework VulMPFF, based on the deep feature interaction strategy of the heterogeneous graph neural network, this method effectively alleviates the semantic fragmentation problem caused by the simple splicing of its sequence and graph models, and the F1 value is increased by 2.2%. In addition, the standard deviation of this method in five independent experiments is less than 0.5%, which is significantly better than LineVD (1.2%) and MGVD (1.8%), verifying the robustness of the model.
[0066] To comprehensively evaluate the detection ability of the proposed method for different vulnerability types, multi-method comparison experiments are carried out for six common vulnerability types such as CWE-119 in terms of accuracy, precision, recall, and F1 value. The experimental results correspond to Figure 6 (accuracy), Figure 7 (precision), Figure 8 (recall), and Figure 9 (F1 value).
[0067] The experimental results show that the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement in the present invention demonstrates overall performance advantages superior to existing methods in six common CWE vulnerabilities, reflecting strong robustness and generalization capabilities. In terms of accuracy, most of the indicators of the method in this paper are better than those of the other four methods in the six types of vulnerabilities. Among them, the accuracy rates for CWE-399, CWE-119, and CWE-20 reach 94.8%, 93.7%, and 92.6% respectively, significantly better than the other four methods, indicating its stronger capabilities in global semantic modeling and vulnerability sample discrimination. This result also shows that by retaining the grammatical backbone structure and integrating the program semantic graph of data and control dependencies, the problems of traditional structure bloat or information loss can be effectively alleviated, and the overall discrimination accuracy can be improved. In terms of precision, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement in the present invention performs particularly outstandingly in complex vulnerability types that highly depend on control logic, such as CWE-399 and CWE-119, reaching 93.7% and 92.2% respectively, and the false positive rate significantly decreases compared with other methods. This benefits from the model introducing the edge semantic enhancement mechanism and the scope path modeling strategy, enabling it to accurately distinguish the actual roles of different control and data dependency semantic edges during the feature learning stage, thereby effectively avoiding the interference caused by the propagation of invalid paths. This ability is crucial for reducing false positives of non-vulnerabilities in complex regions of code structures. In terms of recall rate, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in the present invention exceeds 95% in both CWE-399 and CWE-787, and is more capable of identifying potential real vulnerabilities compared with other methods, indicating its stronger coverage ability for actual vulnerability samples. This shows that the model not only performs excellently in identifying key vulnerability features but also has the ability to capture complex logic nesting and boundary condition anomalies. In terms of F1 value, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in the present invention exceeds 90% in all vulnerability types. Among them, CWE-399, CWE-787, and CWE-20 reach 95.0%, 92.8%, and 92.8% respectively, which are 2.1%, 1.5%, and 3.5% higher than the currently optimal VulMPFF method, comprehensively superior to other comparison methods. This result shows that in terms of the comprehensive performance of balancing precision and recall rate, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in the present invention shows better stability and overall discrimination ability. Especially in scenarios with deep control semantics and complex data dependencies, its graph structure modeling ability has obvious advantages.
[0068] Overall, the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in this invention shows the most significant performance in high-complexity vulnerability types such as CWE-119, CWE-399, CWE-787, and CWE-20, and is almost comprehensively superior to the other four methods. The experimental results fully verify the practicality and effectiveness of the code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement proposed in this paper in the vulnerability detection task, not only significantly improving the detection accuracy, but also enhancing the model's adaptability and discriminative ability to diverse vulnerability types.
[0069] To systematically verify the effectiveness of the node multi-dimensional feature fusion module and the edge semantic enhancement mechanism (Edge Semantic Augmentation, ESA), 8 groups of progressive ablation experiments were designed, as shown in Table 4, covering three levels: single-variable control, multi-feature collaboration, and semantic enhancement. a) Single-variable control group. By independently adopting code sequence (Token-Sequence), AST sub-tree (Sub-AST), and scope path (Scope Path, SP) features (experimental groups 1-3), the independent contributions of each dimension of features were quantified.
[0070] b) Multi-feature collaboration group. Token-Sequence + Sub-AST (group 4), Token-Sequence + SP (group 5), Sub-AST + SP (group 6), and the full-feature combination Token-Sequence + Sub-AST + SP (group 7) were constructed to analyze the complementarity and collaborative effects between features.
[0071] c) Edge semantic enhancement group. On the basis of full features, the graph attention network ESA-GAT with edge semantic enhancement was introduced (group 8) to verify the modeling gain of edge semantic information for complex logical relationships.
[0072] The experimental results show that among single features, Token-Sequence based on text sequences and Sub-AST based on syntactic structures perform the best, with F1 scores reaching 79.7% and 79.1% respectively, verifying the basic discrimination ability of text sequences and syntactic structures. When using the scope path SP alone, the F1 score is only 70.9%, and the effect is limited, and it needs to rely on other features to activate its context constraint effect. In terms of feature combination, the fusion of Token-Sequence and Sub-AST increases the F1 score to 85.8%, with the highest improvement of 6.7% compared to single features, proving that text and structural features are strongly complementary; further adding the fusion model of SP optimizes the F1 score to 88.4% and the recall rate to 87.2%, indicating that SP effectively reduces the missed detection of complex code patterns by encoding the hierarchical relationship of syntactic scopes. Finally, after introducing the edge semantic enhancement mechanism ESA, the model achieves the optimal performance, with the accuracy rate increased to 93.1% and the F1 score reaching 92.8%. The balance between its precision rate of 91.2% and recall rate of 94.5% indicates that ESA enhances the perception ability of logical dependencies between nodes by explicitly modeling edge semantic relationships such as control flow and data flow. This experiment verifies the necessity of feature fusion: the combination of text, structure, and context constraint features contributes 88.4% of the baseline performance, while ESA provides an additional 2.8% gain, highlighting the key role of edge semantic enhancement in complex code analysis.
[0073] Table 4 Influence of Different Feature Extraction Combination Methods on Vulnerability Detection
[0074] The present invention proposes a code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement. On the basis of retaining the high-level syntactic structure of the AST, this method constructs a lightweight program semantic graph by folding and compressing the AST structure and fusing data and control dependencies in the PDG, effectively solving the problem of bloated graph structure. Aiming at the problem that traditional methods are difficult to capture the context of statements, a context modeling mechanism based on the scope path is introduced, which combines semantic subtrees, syntactic structures, and scope information to extract syntactic, semantic, and context features of statement nodes, and realizes multi-dimensional information fusion through a dynamic attention mechanism, preventing the separation of local and global features. In addition, by constructing an edge semantic enhancement module, edge type information is introduced to participate in attention calculation and node update, improving the model's ability to distinguish heterogeneous edges and feature expression ability.
[0075] Future research will be deeply expanded along two directions: 1) constructing an integrated framework for vulnerability location and repair, and generating targeted patch suggestions in combination with interpretability analysis techniques; 2) expanding the representation dimension of the program semantic graph and integrating dynamic runtime features to enhance the model's detection ability.
[0076] For the foregoing embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that this application is not limited by the described action sequence, because according to this application, some steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to this application.
[0077] In the above embodiments, the basic principles, main features and advantages of the present invention are described. Those skilled in the art of this industry should understand that the present invention is not limited by the above embodiments. What is described in the above embodiments and the specification only illustrates the principles of the present invention. Without departing from the spirit and scope of the present invention, any changes and modifications made by those skilled in the art that do not depart from the spirit and scope of the present invention should fall within the protection scope of the appended claims of the present invention.
Claims
1. A code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement, characterized in that It includes the following steps: Step S1: On the basis of retaining the high-level syntax framework of the AST, compress the AST subtree structure based on the subtree folding rule, and fuse the data flow and control flow dependencies of the PDG to construct a lightweight program semantic graph; Step S2: Extract the multi-dimensional features of the nodes from the program semantic graph, combine the edge semantic enhancement mechanism to extract the global program-level features, and perform vectorized representation; Step S3: Input the program semantic graph features into the fully connected layer to identify potential vulnerabilities and output the detection results.
2. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 1, characterized in that The specific content of the said Step S1 includes: Step S11: Construct a hierarchical fusion strategy based on the AST and PDG, remove redundant details while retaining the syntax framework, and perform structure compression; Step S12: Introduce the control and data dependencies of the PDG, dynamically model the program execution semantics, and construct a lightweight program graph representation with both syntactic integrity and semantic logic.
3. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 2, wherein The specific content of the said Step S11 includes: Establish a node fusion rule based on the minimum complete subtree MCS. Let be any subtree in the AST, and denote its leaf node set as . For each leaf node , the corresponding source code line number is . It is determined as an MCS if and only if two conditions are satisfied simultaneously. Among them, is the abstract syntax tree and , , is the node set. Each node is represented by a quadruple . represents the syntax type of the node, represents the specific syntax unit of the node, refers to the line number of the code where the node is located, represents the set of child nodes of the node, is the edge set describing the parent-child relationship between nodes. For the root node of each MCS , fold its entire subtree into a statement node , Inherit the syntax type of the root node of the subtree and the content of the corresponding code line, while retaining the parent node in the original AST and the hierarchical relationship; for high-level AST nodes that are not MCS, keep the original structure.
4. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 3, wherein, The two conditions for determining an MCS are specifically: Subtree The source code line numbers corresponding to all leaf nodes are exactly the same, that is, there exists a certain code line number , such that for any leaf node , all satisfy ; On the premise of meeting the line number consistency, the subtree should not contain a smaller proper subtree that meets the same line number condition, that is, there does not exist any proper subtree , such that all its leaf nodes are still located entirely on the corresponding line numbers, and .
5. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 4, wherein The specific content of the said Step S12 includes: Perform node alignment operations. In the folded AST, locate the statement nodes corresponding to each statement node in the PDG according to the consistency of line numbers ; Taking the data dependency edges and control dependency edges in the PDG as units of statement nodes respectively, inject them into the semantic graph to obtain a lightweight program semantic graph.
6. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 1, wherein The multi-dimensional features of the nodes extracted in the said Step S2 specifically include: Code semantic features based on text sequences: For statement nodes , split the corresponding code text into a Token sequence , generate an initial embedding through the pre-trained CodeBERT model, and input it into a Bi-LSTM network to capture context-sensitive semantics, and finally obtain the semantic feature representation of the node ; Hierarchical syntactic features based on tree structure: Use CodeBERT to embed the content of each node in the subtree to generate the initial feature representation of the node; Combine the type information of the node to assign type features to each node; Use the Tree-LSTM model to hierarchically model the content features and type features of the node, capture the local and global syntactic dependencies in the AST subtree, and generate the node syntactic feature representation ; Context Constraint Feature Based on Scope Path: Establish a hierarchical context encoding mechanism based on the scope path. By constructing the scope nesting path of a statement node in the AST starting from the statement node, explicitly retain the syntactic structure environment where the statement is located, and provide more discriminative context features 。 7. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 6, wherein The hierarchical context encoding mechanism specifically includes: For any statement node , identify its corresponding leaf node position in the program semantic graph, and trace back along the parent node reference chain from bottom to top to the root node to obtain a complete syntax scope path; Establish a scope boundary type screening rule, only retain the node types with control or semantic constraint capabilities, as well as the type of the statement node itself; Use a bidirectional long short-term memory network (Bi-LSTM) to model the path. Treat the scope path as a sequence of node types and input it into the model. The model captures bidirectional semantics from both the start and end points of the path, learns the context interaction relationships of the nodes in the path, and takes the hidden state of the model at the last layer as the semantic vector of the path, denoted as .
8. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 7, wherein The extraction of the multi-dimensional features of the nodes also includes dynamic attention fusion of the multi-dimensional features of the nodes, specifically including: By means of the attention mechanism, calculate the mutual influence between different features to obtain the weights of each feature dimension , and the formula is: ; Among them, is a learnable query vector, is the feature dimension, is the multi-dimensional feature of the node; Generate the basic feature representation by weighted summation , and the formula is as follows: ; Using a gating mechanism to perform weighted fusion on the features, so as to strengthen the influence of important features and suppress the interference of irrelevant features, expressed as: ; Among them, is the Sigmoid activation function, represents the Hadamard product; Perform a residual connection between the weighted fusion features and the original features to obtain the feature fusion formula as: 。 9. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 8, characterized in that The edge semantic enhancement mechanism specifically includes: For the semantic graph , set the initial edge embedding matrix according to different edge types , and use MLP to dynamically update the edge attributes. The formula is as follows: ; Among them, the program semantic graph , is a set of nodes, is a set of AST edges, and represent the control dependence edge set and the data dependence edge set respectively; is the number of edge types, is the edge embedding dimension, represents the initial edge attribute. For each edge , take out the corresponding embedding vector from the embedding matrix through the edge type index, and ; ; and are the feature representations of nodes and respectively, represents the vector concatenation operation, and MLP is a multi-layer perceptron used to map the concatenated vector to a new feature space; For any node and its neighbor nodes , using the shared linear mapping W and the learnable attention vector , calculate the attention weights , and the calculation formula is: ; Using the calculated attention weights , through the message passing mechanism, jointly update the node features with the edge information and neighboring nodes. The formula for updating the node is as follows: 。 10. The code vulnerability detection method based on multi-dimensional feature fusion and edge semantic enhancement according to claim 9, characterized in that, The said Step S2 also includes: After obtaining the final features of the nodes, aggregate the node features of the whole graph into a graph-level representation to input into the classifier, and based on the attention weighted pooling mechanism, dynamically distinguish the importance of nodes through learnable parameters, and the calculation formula is: ; ; Among them is the weight matrix, is the bias term; Finally, the graph-level representation is predicted for the presence or absence of vulnerabilities through a fully connected layer and a Sigmoid function.
Citation Information
Cited By
Code searching method and system based on multi-structure chart fusion
CN121050768A
Intelligent tour guide method and system based on intelligent token and semantic fusion
CN121301533A
Abnormality assessment method based on vulnerability recognition, medium and equipment
CN121902167A
Semantic analysis and attention combined code sequence compression method, device and equipment
CN122285016A