Code multi-modal fusion representation learning method for power system software vulnerability detection
By constructing a multimodal fusion representation learning method for power system software code, combining code text, image and attribute graph modalities, the problem of underutilization of multimodal features in power system software vulnerability detection is solved, and more efficient and accurate vulnerability detection is achieved.
Patent Information
- Application Number
- CN202510630488.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-09-16
AI Technical Summary
Existing technologies have not fully explored and applied the multimodal characteristics of code in power system software vulnerability detection, which affects the comprehensiveness and accuracy of vulnerability representation.
A code multimodal fusion representation learning method is adopted. By constructing a modal alignment interaction module and a collaborative fusion framework, code text, code image and attribute graph modalities are combined to perform feature extraction and encoding, thereby enhancing the data representation completeness of the vulnerability detection model.
The adaptability and accuracy of power system software vulnerability detection have been improved, and the flexibility and detection effect of the model in actual application scenarios have been enhanced.
Smart Images

Figure CN120654242A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of power systems, and in particular relates to a code multimodal fusion representation learning method for power system software vulnerability detection. Background Art
[0002] As a vital component of national infrastructure, the stable operation of the power system is directly linked to the development of the national economy and society. However, the increasing complexity and diversity of power system software, particularly driven by emerging technologies like the Internet of Things and artificial intelligence, are placing higher demands on the stability and security of power system software in areas such as smart grids and intelligent energy management.
[0003] A key factor affecting the security and reliability of power system software is the number of vulnerabilities within the software. Software vulnerabilities are defects or weaknesses in software programs or systems that attackers can exploit to steal data or cause system damage. Software vulnerabilities are typically caused by improper software architecture design, code defects, execution errors, and vulnerabilities in the software supply chain. Integrating artificial intelligence (AI) technology to conduct in-depth search, matching, and analysis of software code and data can effectively improve the efficiency of software vulnerability discovery, thereby promoting the intelligent transformation of power system software reliability and security assurance.
[0004] Traditional software vulnerability detection methods rely primarily on pattern matching based on rules developed by experts. By checking whether the code meets these rules, they determine whether the code contains a specific vulnerability. However, rule-based matching methods are prone to generating a large number of false positives, and predefined rules and expert knowledge are difficult to adapt to emerging vulnerability types. With the development of artificial intelligence, many studies have emerged in recent years using machine learning models for software vulnerability detection, such as:
[0005] Internationally, Zhou et al. from Nanyang Technological University designed a general model based on graph neural networks that can encode source code functions from multiple syntactic and semantic representations into a joint graph structure, effectively identifying vulnerable code using the composite graph representation. Nguyen et al. proposed a method that combines control flow graphs and Solidity code call graphs, using a heterogeneous graph attention neural network to encode the structural and semantic relationships between different types of nodes and edges in the graph for vulnerability detection. Hin et al. proposed a model that combines graph neural networks and a Transformer-based model, using control and data dependencies between code statements to encode raw source code tokens for statement-level vulnerability detection. Steenhoek et al. combined data flow analysis with deep learning, leveraging graph learning frameworks and embedding techniques to improve the efficiency and effectiveness of vulnerability detection in code. Zamani et al. proposed a cross-domain control attribute graph that combines code-level and binary-level graphs and is trained using the contrastive learning method GraphCL, significantly improving vulnerability detection. In the industrial sector, Google, Microsoft, and IBM are also actively developing commercial vulnerability detection tools. For example, Microsoft's CodeQL tool can perform semantic analysis on code and detect potential vulnerabilities; Google's Tricorder project uses machine learning technology to automatically detect vulnerabilities in open source projects.
[0006] In domestic research, Zhang et al. proposed decomposing the syntactic control flow graph of a code snippet into multiple execution paths, using a pre-trained code model and convolutional neural networks to learn the path representations, and combining path feature vectors to improve vulnerability detection in long code. Ni et al. proposed a function-level vulnerability detection method, MVulD, which significantly improved vulnerability detection performance by leveraging the pre-trained model UniXcoder, graph neural networks, and computer vision techniques. Wu et al. proposed converting the program dependency graph of function source code into images and using computer vision techniques to achieve efficient and accurate large-scale vulnerability detection. Xiao et al. proposed an efficient and accurate contrastive value stream embedding method, which uses self-supervised contrastive learning to pre-train a path embedding model, retaining feasible program dependency paths and improving vulnerability detection accuracy and efficiency. Wen et al. addressed the limitations of existing methods in handling long-distance node connections and multiple edge types in code structure graphs through graph simplification and enhanced graph representation learning, significantly improving vulnerability detection accuracy. Yuan et al. constructed a code behavior graph to extract the abstract behavior of functions and the relationships between them. They leveraged this global information to improve the performance of deep learning-based vulnerability detection systems on real datasets, thereby enhancing the overall performance of various baseline models in detecting real vulnerabilities. In the industrial sector, companies like Huawei and Alibaba are also actively developing intelligent vulnerability detection tools. Huawei's CodeArts platform and Alibaba's Guard project leverage artificial intelligence to automate software vulnerability detection and remediation. These tools significantly improve detection efficiency, reduce human error, and enhance software security and stability.
[0007] In summary, while some progress has been made in vulnerability detection research, research specifically targeting power system vulnerability detection remains insufficient. Currently, research efforts have yet to fully explore and utilize the multimodal characteristics of code, hindering the comprehensiveness and accuracy of vulnerability representation. Therefore, new approaches to in-depth analysis and detection of power system software vulnerabilities are urgently needed, leveraging multimodal forms of data, such as source code, annotations, documentation, and code graphs. Summary of the Invention
[0008] The main purpose of the present invention is to overcome the shortcomings and deficiencies of the existing technology and provide a code multimodal fusion representation learning method for power system software vulnerability detection. Starting from the consistency analysis of code text and code image modal representation, the interaction between code line-level representation and attribute graph modality and the collaborative fusion coding of multimodal representation, a representation learning method for code multimodal interaction fusion is constructed, thereby enhancing the completeness of the modeling data representation of the power system software vulnerability detection model.
[0009] In order to achieve the above object, the present invention adopts the following technical solutions:
[0010] In a first aspect, the present invention provides a code multimodal fusion representation learning method for power system software vulnerability detection, comprising the following steps:
[0011] S1. Given a data set of a software project, use the analysis tools corresponding to each modality to parse each data set into multiple modal representations, and obtain multiple modal representation data sets, including text sequence data sets, code pixel map data sets, program property map data sets, and static complexity data sets;
[0012] S2. Construct a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network, and use the modality alignment interaction module to extract modality interaction features and obtain multiple modality interaction features;
[0013] S3. Use the collaborative fusion framework to encode multiple modal interaction features to perform the reconstruction task. By calculating the set loss constraints, the implicit representation of each set of features is obtained and fused to obtain the final multimodal feature representation of the power system software code, which is used to build a vulnerability detection model for power system software.
[0014] As a preferred technical solution, step S1 is specifically as follows:
[0015] Given a software project as a file, read the text content of the file and preprocess it, where the preprocessed content includes spaces, comments, variable names, and method names;
[0016] By embedding the preprocessed text content, a text sequence representation set is obtained;
[0017] Segment and locate the text, obtain the semantics and position information of each word, map the semantics and position of each word to the corresponding pixel value, and obtain a pixel image representation set;
[0018] Modeling structural information within the text, parsing the structural information into multiple attribute graph representations, and integrating the attribute graph representations to obtain an attribute graph representation set; the attribute graph representations include an abstract syntax tree, a data flow graph, and a control flow graph;
[0019] Use program static analysis tools to extract complexity quantitative indicators in the code and obtain a set of static complexity representations.
[0020] As a preferred technical solution, step S2 includes:
[0021] Use the text embedding model to embed the elements in the text sequence set to obtain the text feature matrix;
[0022] The elements in the code pixel map set are processed by the image feature extraction model to obtain the image feature matrix;
[0023] The dual-channel convolution layer is used to extract and interact the text feature matrix and the image feature matrix to obtain the text-image interaction features, as shown in the following formula:
[0024] Z 1 =vech(W1*X S +b1,W2*X U +b2)
[0025] Among them, W1 represents the text feature matrix X S The convolution kernel of the corresponding channel, W2 represents the code pixel map feature matrix X U The convolution kernel of the corresponding channel, * represents the convolution operation, b1 and b2 represent the bias terms, vech(·) represents the feature interaction operation, Z 1 Represents text-image interaction features.
[0026] As a preferred technical solution, step S2 includes:
[0027] Given a software project as a file, the nodes in the file graph representation include multiple types, and the type is denoted as t;
[0028] Perform level segmentation on the text content of file j to obtain a line-level text sequence set of file j, and perform a transformation operation on the pixel map corresponding to file j in the code pixel map set to obtain a line-level pixel map set of file j;
[0029] Use the text embedding model to process the row-level text sequence set of file j, embed the graph node type t to be initialized into the row-level text sequence of file j, obtain the row-level text feature matrix, and use the row-level convolutional neural network to extract features from the elements in the row-level pixel map set of file j to obtain the row-level image feature matrix;
[0030] Use the autoencoder to fuse the row-level text feature matrix and the row-level image feature matrix to obtain the row-level fused feature matrix;
[0031] The row-level fusion feature matrix is used to initialize the nodes of the program attribute graph dataset, and the initialized program attribute graph is input into the graph neural network to obtain the structural-semantic interaction features.
[0032] As a preferred technical solution, step S2 includes:
[0033] Static analysis software is used to collect statistics on complexity quantification indicators to obtain static complexity features; the complexity quantification indicators include Halstead features based on operands and operators, McCabe features based on code dependencies, and CK features based on object-oriented concepts.
[0034] As a preferred technical solution, step S3 includes:
[0035] Inputting multiple modal interaction features into their respective collaborative fusion frameworks, mapping the modal interaction features to high-dimensional latent space representations using an encoder, and reconstructing the high-dimensional latent space representations using a decoder; the collaborative fusion framework includes an encoder and a decoder;
[0036] In the process of performing the reconstruction task, the modality reconstruction loss and feature mapping loss are calculated to constrain and obtain accurate latent representation; the modality reconstruction loss includes single modality reconstruction loss and cross-modality reconstruction loss, as shown in the following formula:
[0037]
[0038] Among them, k is the number of modes, ||·||2 represents the L2 norm, is the single modality reconstruction loss, for cross-modal reconstruction loss;
[0039] The feature mapping loss aggregates the feature implicit representations of different modalities in a high-dimensional space as follows:
[0040]
[0041] Among them, h i represents the implicit representation of the interaction feature of the i-th modality, h j represents the latent representation of the j-th modality interaction feature.
[0042] As a preferred technical solution, it includes:
[0043] Through the single modality reconstruction loss, the encoder learns to reconstruct the feature implicit representation of the modal interaction features; through the cross-modal reconstruction loss, feature reconstruction is performed through different modality decoders to fuse the information between the modalities.
[0044] In a second aspect, the present invention further provides a code multimodal fusion representation learning system for power system software vulnerability detection, which is applied to the code multimodal fusion representation learning method for power system software vulnerability detection, including a data processing module, a feature extraction module, and a task execution module;
[0045] The data processing module is used to analyze the data sets of a given software project into multiple modal representations using analysis tools corresponding to each modality, and obtain multiple modal representation data sets, including text sequence data sets, code pixel map data sets, program attribute map data sets, and static complexity data sets;
[0046] The feature extraction module is used to build a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network. The modality alignment interaction module is used to extract modality interaction features and obtain multiple modality interaction features.
[0047] The task execution module is used to use the collaborative fusion framework to encode multiple modal interaction features to perform reconstruction tasks. By calculating the set loss constraints, the implicit representation of each set of features is obtained and fused, and the final multimodal feature representation of the power system software code is obtained, which is used to build a vulnerability detection model for power system software.
[0048] In a third aspect, the present invention provides an electronic device, comprising:
[0049] at least one processor; and,
[0050] a memory communicatively connected to the at least one processor; wherein,
[0051] The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor to enable the at least one processor to execute the code multimodal fusion representation learning method for power system software vulnerability detection.
[0052] In a fourth aspect, the present invention provides a computer-readable storage medium storing a program, which, when executed by a processor, implements the code multimodal fusion representation learning method for power system software vulnerability detection.
[0053] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0054] The present invention innovatively proposes a representation learning method for code multimodal interaction and collaborative fusion. It combines the multimodal characteristics of code, designs feature interaction and alignment modules to enhance information exchange between different modalities, and finally improves the code representation through a multimodal feature collaborative fusion model. Among them, unlike most code feature representation learning methods (based on a single modality or feature splicing), this method starts from the consistency analysis of code text and code image modal representation, the interaction between code line-level representation and attribute graph modality, and the collaborative fusion coding of multimodal representation, and constructs a representation learning method for code multimodal interaction and fusion, thereby enhancing the completeness of the modeling data representation of the power system software vulnerability detection model and improving the flexibility of adapting to the power system software quality assurance needs in actual application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0056] Figure 1 This is a flowchart of a code multimodal fusion representation learning method for power system software vulnerability detection according to an embodiment of the present invention;
[0057] Figure 2 This is a schematic diagram of the structure of a code multimodal fusion representation learning system for power system software vulnerability detection according to an embodiment of the present invention;
[0058] Figure 3 2 is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0060] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments.
[0061] See also Figure 1 This embodiment provides a code multimodal fusion representation learning method for power system software vulnerability detection, including the following steps:
[0062] S1. Multimodal analysis of code.
[0063] Depending on the actual power system software code task requirements, data objects can be granularized at the package, file, class, or method level. This method uses the power system software code file granularity as an example. Given a set of n code files in a software project, each code file is parsed into four modal representations using analysis tools corresponding to each modality.
[0064] First, the code is converted into text mode. As the most basic form of program expression, code text contains rich semantic and logical information. This method intends to write a script to read the text content of the code file and preprocess the spaces, comments, variable names, and method names in the code. By embedding the preprocessed text content, a set of power system software code text sequence representations can be obtained, denoted as S = {s1, s2, ..., s n}.
[0065] Then, the code is converted into a visual pixel map. By converting text into a visual pixel map, the structural semantic differences of the program can be more intuitively displayed. The code text is segmented and located to obtain the semantic and position information of each word. The semantic and position of each word is mapped to the corresponding pixel value, thereby obtaining the pixel image representation set of the power system software code, which is denoted as U = {u1,u2,…,u n}.
[0066] Next, the code is converted into a property graph mode. Statements such as data operations and loop control between different elements in the program (such as variables, operators, and control statements) all reflect the internal structured information. This embodiment models the structural information in the program, parses it into an abstract syntax tree, a data flow graph, and a control flow graph, and integrates the three into a unified power system software program property graph representation set, denoted as G = {g1, g2, ..., g n}.
[0067] Finally, the code is converted into a complexity metric representation: the program static analysis tool is used to extract the Halstead features based on operands and operators, the McCabe features based on code dependencies, and the CK features based on object-oriented concepts in the code to obtain the static complexity representation set of the power system software code, denoted as Q = {q1,q2,…,q n}.
[0068] S2. Extraction of inter-modal interaction information.
[0069] Through the above process, we obtain data sets of four power system software code modalities: text sequence data set S, code pixel map data set U, program attribute graph data set G, and static complexity data set Q. This step will construct a modal alignment interaction module to enhance information exchange between modalities.
[0070] First, we use the code text embedding model M S Embed the elements in the text sequence set S to obtain the text feature matrix Represents the text feature vector of the nth file. Through the image feature extraction model M U Process the elements in the code pixel map set U to obtain the image feature matrix Represents the pixel map feature vector of the nth file. Therefore, a dual-channel convolution layer can be used to realize the text feature X S With image feature X U The alignment interaction is expressed as follows:
[0071] Z 1 =vech(W1*X S +b1,W2*X U +b2)
[0072] Among them, W1 represents the text feature matrix X S The convolution kernel of the corresponding channel, W2 represents the code pixel map feature matrix X U The convolution kernel of the corresponding channel, * represents the convolution operation, b1 and b2 represent the bias terms, vech(·) represents the feature interaction operation, and finally the text-image interaction feature representation Z is obtained. 1 .
[0073] Then, the text content of the power system software file j (1≤j≤n) is segmented at the line level to obtain the line-level text sequence set Where n is the number of rows. At the same time, based on the pixel map conversion operation in step S1, the row-level pixel map set of file j can be obtained.
[0074] Next, use the text embedding model M S To S j Operate the elements in to obtain the row-level text feature matrix Use row-level convolutional neural network M l U j Extract features from the elements to obtain row-level image feature matrix
[0075] Then, an autoencoder is used to and Perform fusion to obtain the row-level fusion feature matrix of file j
[0076] Next, based on the attribute graph conversion operation in step S1, file j is parsed into code attribute graph g j =(A,X), where A represents the adjacency matrix and X represents the node feature set. Use the row-level fusion feature matrix L j Internal element code attribute diagram g j Initialize the node, even if
[0077] Thus, the initialized code attribute graph g j Input to the graph neural network MG Extract the structural-semantic interaction feature Z 2 About the text embedding model M S , image feature extraction model M U , row-level convolutional neural network M l and graph neural network M G ,This embodiment will adopt the method of empirical research for selection and improvement.
[0078] Finally, the static analysis software is used to perform statistics on the code Halstead features, McCabe features, and CK features to obtain the static complexity feature Z 3 . It includes characteristics such as inheritance tree depth, program length, and coupling between objects. 3 It will be used as an additional set of supplementary features as input to the next step.
[0079] S3. Code multimodal collaborative fusion coding.
[0080] This step aims to integrate the three modal interaction features Z of the power system software code extracted in step S2 i ,i∈{1,2,3}, that is: “text-image” interaction feature Z 1 , "Structure-semantics" interaction feature Z 2 and code complexity characteristic Z 3 , used to build vulnerability detection modeling data. This embodiment builds a collaborative fusion framework to encode each feature representation to perform the reconstruction task, and uses the modal reconstruction loss and feature map loss Constraints are imposed to obtain the implicit representation of each set of features and fuse them to obtain the final multimodal feature representation of the power system software code.
[0081] First, the three interactive feature vectors Z 1 、Z 2 and Z 3 Input to three groups of codecs. i The eigenvector Z i Mapped to a high-dimensional latent space representation, denoted as h i =E i (Z i ). By decoder D j The feature implicit representation h i Reconstruction is recorded as Then, when each codec performs representation reconstruction, the modal reconstruction loss is introduced and feature map loss Constrained, the modal reconstruction loss function It is expressed as follows:
[0082]
[0083] Among them, k is the number of modes, ||·||2 represents the L2 norm, It is a single modality reconstruction loss, that is, to ensure that the encoder E is i Learning can accurately reconstruct Z i The characteristic latent representation h j , For cross-modal reconstruction loss, through different modality decoders D i Feature reconstruction is performed to fuse information between modalities to enhance the interactivity of each modality in the latent space.
[0084] In order to gather the implicit representations of features of different modalities in high-dimensional space, this embodiment introduces feature mapping loss Constraints are expressed as follows:
[0085]
[0086] Finally, the latent representation feature vectors h of the three modalities are i As the input of the autoencoder, the fused latent representation Z is obtained as the representation of the final code instance to support vulnerability detection modeling.
[0087] In the process of implementing this embodiment, an empirical research approach is proposed to input power system software code instances into a multimodal interaction and collaborative fusion representation learning model to obtain code representation. The code representation learning baseline method using a single code modality or multimodal fusion is compared in the vulnerability detection task to verify the effectiveness of the proposed method.
[0088] It should be noted that, for the sake of convenience, the aforementioned method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions, because according to the present invention, certain steps can be performed in other orders or simultaneously.
[0089] Based on the same concept as the multimodal fusion representation learning method for power system software vulnerability detection in the above-mentioned embodiment, the present invention also provides a multimodal fusion representation learning system for power system software vulnerability detection, which can be used to execute the above-mentioned multimodal fusion representation learning method for power system software vulnerability detection. For ease of explanation, the structural diagram of the embodiment of the multimodal fusion representation learning system for power system software vulnerability detection only shows the parts related to the embodiment of the present invention. Those skilled in the art will understand that the illustrated structure does not constitute a limitation of the device, and it may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0090] See also Figure 2 In another embodiment of the present application, a code multimodal fusion representation learning system 10 for power system software vulnerability detection is provided, the system comprising a data processing module 11, a feature extraction module 12 and a task execution module 13;
[0091] The data processing module 11 is used to analyze the data sets of a given software project into multiple modal representations using analysis tools corresponding to each modality, and obtain multiple modal representation data sets, including text sequence data sets, code pixel map data sets, program attribute map data sets, and static complexity data sets;
[0092] The feature extraction module 12 is used to construct a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network, and uses the modality alignment interaction module to extract modality interaction features to obtain multiple modality interaction features;
[0093] The task execution module 13 is used to use the collaborative fusion framework to encode multiple modal interaction features to perform the reconstruction task, calculate the set loss constraints, obtain the implicit representation of each set of features and fuse them, and obtain the final multimodal feature representation of the power system software code for building a vulnerability detection model for power system software.
[0094] It should be noted that the code multimodal fusion representation learning system for power system software vulnerability detection of the present invention corresponds one-to-one to the code multimodal fusion representation learning method for power system software vulnerability detection of the present invention. The technical features and beneficial effects described in the above-mentioned embodiment of the code multimodal fusion representation learning method for power system software vulnerability detection are all applicable to the embodiment of the code multimodal fusion representation learning method for power system software vulnerability detection. For specific contents, please refer to the description in the embodiment of the method of the present invention, which will not be repeated here. This is hereby declared.
[0095] In addition, in the implementation of the code multimodal fusion representation learning system for power system software vulnerability detection in the above-mentioned embodiment, the logical division of each program module is only an example. In actual application, the above-mentioned functions can be assigned to different program modules as needed, for example, for the configuration requirements of the corresponding hardware or the convenience of software implementation. That is, the internal structure of the code multimodal fusion representation learning system for power system software vulnerability detection is divided into different program modules to complete all or part of the functions described above.
[0096] See also Figure 3In one embodiment, an electronic device is provided for implementing a code multimodal fusion representation learning method for power system software vulnerability detection. The electronic device 20 may include a first processor 21, a first memory 22 and a bus, and may also include a computer program stored in the first memory 22 and executable on the first processor 21, such as a code multimodal fusion representation learning program 23 for power system software vulnerability detection.
[0097] The first memory 22 includes at least one type of readable storage medium, including flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the first memory 22 may be an internal storage unit of the electronic device 20, such as a mobile hard disk of the electronic device 20. In other embodiments, the first memory 22 may also be an external storage device of the electronic device 20, such as a plug-in mobile hard disk, a smart memory card (SMC), a secure digital (SD) card, a flash memory card, etc. equipped on the electronic device 20. Furthermore, the first memory 22 may include both an internal storage unit of the electronic device 20 and an external storage device. The first memory 22 can be used not only to store application software installed in the electronic device 20 and various types of data, such as the code of the code multimodal fusion representation learning program 23 for power system software vulnerability detection, but also to temporarily store data that has been output or is about to be output.
[0098] In some embodiments, the first processor 21 may be composed of an integrated circuit, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and a combination of various control chips. The first processor 21 is the control core (Control Unit) of the electronic device, connecting the various components of the entire electronic device using various interfaces and lines, and executing or executing programs or modules stored in the first memory 22, as well as calling data stored in the first memory 22, to perform various functions of the electronic device 20 and process data.
[0099] Figure 3 Only the electronic device with components is shown, and it can be understood by those skilled in the art that Figure 3The structure shown does not constitute a limitation on the electronic device 20 , and the electronic device 20 may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0100] The code multimodal fusion representation learning program 23 for power system software vulnerability detection stored in the first memory 22 of the electronic device 20 is a combination of multiple instructions. When running in the first processor 21, it can achieve the following:
[0101] S1. Given a data set of a software project, use the analysis tools corresponding to each modality to parse each data set into multiple modal representations, and obtain multiple modal representation data sets, including a text sequence data set, a code pixel map data set, a program property map data set, and a static complexity data set;
[0102] S2. Construct a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network, and use the modality alignment interaction module to extract modality interaction features and obtain multiple modality interaction features;
[0103] S3. Use the collaborative fusion framework to encode multiple modal interaction features to perform the reconstruction task. By calculating the set loss constraints, the implicit representation of each set of features is obtained and fused to obtain the final multimodal feature representation of the power system software code, which is used to build a vulnerability detection model for power system software.
[0104] Furthermore, if the modules / units integrated in the electronic device 20 are implemented as software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium. The computer-readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard drive, a magnetic disk, an optical disk, a computer memory, or a read-only memory (ROM).
[0105] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0106] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0107] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be considered as equivalent replacement methods and are included in the scope of protection of the present invention.
Claims
1. A code multimodal fusion representation learning method for power system software vulnerability detection, characterized by: The steps include: S1. Given a data set of a software project, use the analysis tools corresponding to each modality to parse each data set into multiple modal representations, and obtain multiple modal representation data sets, including a text sequence data set, a code pixel map data set, a program property map data set, and a static complexity data set; S2. Construct a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network, and use the modality alignment interaction module to extract modality interaction features and obtain multiple modality interaction features; S3. Use the collaborative fusion framework to encode multiple modal interaction features to perform the reconstruction task. By calculating the set loss constraints, the implicit representation of each set of features is obtained and fused to obtain the final multimodal feature representation of the power system software code, which is used to build a vulnerability detection model for power system software.
2. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 1 is characterized in that: The step S1 is specifically as follows: Given a software project as a file, read the text content of the file and preprocess it, where the preprocessed content includes spaces, comments, variable names, and method names; By embedding the preprocessed text content, a text sequence representation set is obtained; Segment and locate the text, obtain the semantics and position information of each word, map the semantics and position of each word to the corresponding pixel value, and obtain a pixel image representation set; Modeling structural information within the text, parsing the structural information into multiple attribute graph representations, and integrating the attribute graph representations to obtain an attribute graph representation set; the attribute graph representations include an abstract syntax tree, a data flow graph, and a control flow graph; Use program static analysis tools to extract complexity quantitative indicators in the code and obtain a set of static complexity representations.
3. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 1 is characterized in that: The step S2 includes: Use the text embedding model to embed the elements in the text sequence set to obtain the text feature matrix; The elements in the code pixel map set are processed by the image feature extraction model to obtain the image feature matrix; The dual-channel convolution layer is used to extract and interact the text feature matrix and the image feature matrix to obtain the text-image interaction features, as shown in the following formula: From 1 =all(W1*X S +b1,W2*X U +b2) Among them, W1 represents the text feature matrix X S The convolution kernel of the corresponding channel, W2 represents the code pixel map feature matrix X U The convolution kernel of the corresponding channel, * represents the convolution operation, b1 and b2 represent the bias terms, vech(·) represents the feature interaction operation, Z 1 Represents text-image interaction features.
4. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 1 is characterized in that: The step S2 includes: Given a software project as a file, the nodes in the file graph representation include multiple types, and the type is denoted as t; Perform level segmentation on the text content of file j to obtain a line-level text sequence set of file j, and perform a transformation operation on the pixel map corresponding to file j in the code pixel map set to obtain a line-level pixel map set of file j; Use the text embedding model to process the row-level text sequence set of file j, embed the graph node type t to be initialized into the row-level text sequence of file j, obtain the row-level text feature matrix, and use the row-level convolutional neural network to extract features from the elements in the row-level pixel map set of file j to obtain the row-level image feature matrix; Use the autoencoder to fuse the row-level text feature matrix and the row-level image feature matrix to obtain the row-level fused feature matrix; The row-level fusion feature matrix is used to initialize the nodes of the program attribute graph dataset, and the initialized program attribute graph is input into the graph neural network to obtain the structural-semantic interaction features.
5. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 1 is characterized in that: The step S2 includes: Static analysis software is used to collect statistics on complexity quantification indicators to obtain static complexity features; the complexity quantification indicators include Halstead features based on operands and operators, McCabe features based on code dependencies, and CK features based on object-oriented concepts.
6. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 1 is characterized in that: The step S3 comprises: Inputting multiple modal interaction features into their respective collaborative fusion frameworks, mapping the modal interaction features to high-dimensional latent space representations using an encoder, and reconstructing the high-dimensional latent space representations using a decoder; the collaborative fusion framework includes an encoder and a decoder; In the process of performing the reconstruction task, the modality reconstruction loss and feature mapping loss are calculated to constrain and obtain accurate latent representation; the modality reconstruction loss includes single modality reconstruction loss and cross-modality reconstruction loss, as shown in the following formula: Among them, k is the number of modes, ||·||2 represents the L2 norm, is the single modality reconstruction loss, for cross-modal reconstruction loss; The feature mapping loss aggregates the feature implicit representations of different modalities in a high-dimensional space as follows: Among them, h i represents the implicit representation of the interaction feature of the i-th modality, h j represents the latent representation of the j-th modality interaction feature.
7. The code multimodal fusion representation learning method for power system software vulnerability detection according to claim 6 is characterized in that: include: Through the single modality reconstruction loss, the encoder learns to reconstruct the latent representation of the modality interaction features; Through cross-modal reconstruction loss, feature reconstruction is performed through different modality decoders to fuse information between modalities.
8. A code multimodal fusion representation learning system for power system software vulnerability detection, characterized by: A code multimodal fusion representation learning method for power system software vulnerability detection applied to any one of claims 1-7, comprising a data processing module, a feature extraction module, and a task execution module; The data processing module is used to analyze the data sets of a given software project into multiple modal representations using analysis tools corresponding to each modality, and obtain multiple modal representation data sets, including text sequence data sets, code pixel map data sets, program attribute map data sets, and static complexity data sets; The feature extraction module is used to build a modality alignment interaction module, including a dual-channel convolutional layer and a graph neural network. The modality alignment interaction module is used to extract modality interaction features and obtain multiple modality interaction features. The task execution module is used to use the collaborative fusion framework to encode multiple modal interaction features to perform reconstruction tasks. By calculating the set loss constraints, the implicit representation of each set of features is obtained and fused, and the final multimodal feature representation of the power system software code is obtained, which is used to build a vulnerability detection model for power system software.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores computer program instructions that can be executed by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the code multimodal fusion representation learning method for power system software vulnerability detection as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the code multimodal fusion representation learning method for power system software vulnerability detection as described in any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Code architecture drift repair method and system, electronic equipment and computer storage medium
CN121742894A