Heterogeneous code analysis method, apparatus, device, storage medium, and product
By generating natural language intermediate representation information from heterogeneous code and analyzing it using a large language model, the problem of low efficiency in heterogeneous code anomaly analysis is solved, and efficient cross-language security detection and code optimization are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2026-03-17
AI Technical Summary
Existing heterogeneous code anomaly analysis is inefficient and struggles to effectively detect cross-language security vulnerabilities.
By performing structural analysis on heterogeneous code, intermediate representation information in natural language is generated, and code anomaly analysis, including data flow, control flow, and vulnerability analysis, is performed using a large language model.
It improves the efficiency of anomaly detection in heterogeneous code, can comprehensively identify potential security issues and optimize code structure, and enhance the overall security and analysis efficiency of the system.
Smart Images

Figure CN120197179B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to heterogeneous code analysis methods, apparatus, devices, storage media, and products. Background Technology
[0002] Most existing software systems are multilingual, consisting of complete code units written in different programming languages. When performing anomaly detection, it's necessary to check for anomalies in the code for each language separately. Even if each single-language unit in a multilingual system is secure, the entire system may still have certain security vulnerabilities. Therefore, improving anomaly analysis for heterogeneous code across languages is crucial. Summary of the Invention
[0003] The main objective of this application is to provide a heterogeneous code analysis method, apparatus, device, storage medium, and product, aiming to solve the problem of low efficiency in existing technologies for anomaly analysis of heterogeneous code.
[0004] To achieve the above objectives, this application proposes a heterogeneous code analysis method, which includes:
[0005] In response to a code analysis request, structural analysis is performed on the heterogeneous code to obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0006] The natural language intermediate representation information of the heterogeneous code is determined based on the structural analysis results;
[0007] Code anomaly analysis is performed on the intermediate representation information of the natural language based on the large language model, and the code anomaly analysis results are obtained.
[0008] Optionally, the step of determining the natural language intermediate representation information of the heterogeneous code based on the structural analysis results includes:
[0009] The data transmission mode of the heterogeneous code is determined based on the structural analysis results;
[0010] Based on the structural analysis results, interface information analysis is performed on the heterogeneous code to obtain interface analysis results;
[0011] The natural language intermediate representation information of the heterogeneous code is determined based on the data transmission mode and the interface analysis results.
[0012] Optionally, the step of determining the data transmission mode of the heterogeneous code based on the structural analysis results includes:
[0013] The data in / out points corresponding to the heterogeneous code are determined based on the structural analysis results.
[0014] Identify the encoding and protocol information of the heterogeneous code;
[0015] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0016] Optionally, the step of determining the data transmission mode of the heterogeneous code based on the data ingress / egress point, the encoding information, and the protocol information includes:
[0017] Construct the data flow path corresponding to the heterogeneous code based on the data in / out points, the encoding information, and the protocol information;
[0018] The data transmission mode of the heterogeneous code is determined based on the data flow path.
[0019] Optionally, the step of performing interface information analysis on the heterogeneous code based on the structural analysis results to obtain interface analysis results includes:
[0020] The structural analysis results are input into a large language model, and the interface information of the structural analysis results is analyzed by the large language model to obtain the interface analysis results.
[0021] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0022] Optionally, the step of performing structural analysis on heterogeneous code to obtain structural analysis results includes:
[0023] Language and framework identification is performed on heterogeneous code to obtain language identification results;
[0024] Based on the language recognition results, cross-framework interaction points are identified in the heterogeneous code to obtain data interaction recognition results.
[0025] Dependency analysis was performed on the heterogeneous code to obtain the dependency analysis results;
[0026] The structural analysis results of the heterogeneous code are determined based on the language recognition results, the data interaction recognition results, and the dependency analysis results.
[0027] Optionally, the step of performing dependency analysis on the heterogeneous code to obtain the dependency analysis results includes:
[0028] Scan the heterogeneous code to determine its configuration information;
[0029] The dependency information of the heterogeneous code is determined based on the configuration information;
[0030] The dependency analysis results are determined based on the dependency information.
[0031] Optionally, the step of performing code anomaly analysis on the intermediate representation information of the natural language based on a large language model to obtain the code anomaly analysis results includes:
[0032] Based on the large language model, data flow analysis, control flow analysis, and vulnerability analysis are performed on the intermediate representation information of the natural language to obtain code anomaly analysis results.
[0033] Optionally, the step of performing data flow analysis on the intermediate representation information of the natural language based on a large language model includes:
[0034] Based on a large language model, the data flow path in the intermediate representation information of the natural language is tracked;
[0035] The data flow analysis results are determined based on the data flow path.
[0036] Optionally, the step of performing control flow analysis on the intermediate representation information of the natural language based on a large language model includes:
[0037] Based on the large language model, the execution path of the code in the intermediate representation information of the natural language is traced to obtain the execution path information of the code;
[0038] The control flow analysis results are determined based on the execution path information.
[0039] Optionally, the step of performing vulnerability analysis on the intermediate representation information of the natural language based on a large language model includes:
[0040] Based on the large language model, the code semantic information of the intermediate representation information of the natural language is understood to obtain the code semantic information;
[0041] Vulnerability information in the heterogeneous code is identified based on the semantic information of the code.
[0042] The vulnerability analysis results are determined based on the vulnerability information.
[0043] Furthermore, to achieve the above objectives, this application also proposes a heterogeneous code analysis device, which includes:
[0044] The response module is used to respond to code analysis requests, perform structural analysis on heterogeneous code, and obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0045] An intermediate representation information generation module is used to determine the natural language intermediate representation information of the heterogeneous code based on the structural analysis results;
[0046] The anomaly analysis module is used to perform code anomaly analysis on the intermediate representation information of the natural language based on the large language model, and obtain the code anomaly analysis results.
[0047] Optionally, the intermediate representation information generation module is further configured to determine the data transmission mode of the heterogeneous code based on the structural analysis results;
[0048] Based on the structural analysis results, interface information analysis is performed on the heterogeneous code to obtain interface analysis results;
[0049] The natural language intermediate representation information of the heterogeneous code is determined based on the data transmission mode and the interface analysis results.
[0050] Optionally, the intermediate representation information generation module is further configured to determine the data input / output points corresponding to the heterogeneous code based on the structural analysis results;
[0051] Identify the encoding and protocol information of the heterogeneous code;
[0052] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0053] Optionally, the intermediate representation information generation module is further configured to construct a data flow path corresponding to the heterogeneous code based on the data inlet / outlet points, the encoding information, and the protocol information;
[0054] The data transmission mode of the heterogeneous code is determined based on the data flow path.
[0055] Optionally, the intermediate representation information generation module is further configured to input the structural analysis results into a large language model, and perform interface information analysis on the structural analysis results through the large language model to obtain interface analysis results;
[0056] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0057] Optionally, the response module is further configured to perform language and framework recognition on the heterogeneous code to obtain language recognition results;
[0058] Based on the language recognition results, cross-framework interaction points are identified in the heterogeneous code to obtain data interaction recognition results.
[0059] Dependency analysis was performed on the heterogeneous code to obtain the dependency analysis results;
[0060] The structural analysis results of the heterogeneous code are determined based on the language recognition results, the data interaction recognition results, and the dependency analysis results.
[0061] Optionally, the response module is further configured to scan the heterogeneous code and determine the configuration information of the heterogeneous code;
[0062] The dependency information of the heterogeneous code is determined based on the configuration information;
[0063] The dependency analysis results are determined based on the dependency information.
[0064] Optionally, the anomaly analysis module is further configured to perform data flow analysis, control flow analysis, and vulnerability analysis on the natural language intermediate representation information based on a large language model, to obtain code anomaly analysis results.
[0065] Optionally, the anomaly analysis module is also used to track the data flow path in the intermediate representation information of the natural language based on a large language model;
[0066] The data flow analysis results are determined based on the data flow path.
[0067] Optionally, the anomaly analysis module is further configured to perform execution path tracing on the code in the intermediate representation information of the natural language based on the large language model, so as to obtain the execution path information of the code;
[0068] The control flow analysis results are determined based on the execution path information.
[0069] Optionally, the anomaly analysis module is further configured to understand the code semantic information of the natural language intermediate representation information based on the large language model, and obtain the code semantic information;
[0070] Vulnerability information in the heterogeneous code is identified based on the semantic information of the code.
[0071] The vulnerability analysis results are determined based on the vulnerability information.
[0072] In addition, to achieve the above objectives, this application also proposes a heterogeneous code analysis device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the heterogeneous code analysis method described above.
[0073] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the heterogeneous code analysis method described above.
[0074] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the heterogeneous code analysis method described above.
[0075] This application, in response to a code analysis request, performs structural analysis on heterogeneous code to obtain structural analysis results. The heterogeneous code includes code from multiple programming languages. Based on the structural analysis results, it determines the natural language intermediate representation information of the heterogeneous code. Then, it performs code anomaly analysis on the natural language intermediate representation information based on a large language model to obtain code anomaly analysis results. Because this application transforms heterogeneous code into a unified natural language intermediate representation information before performing code anomaly analysis, compared to existing methods that separately detect anomalies in each single language within the heterogeneous code, the above method of this application can improve the efficiency of anomaly detection for heterogeneous code. Attached Figure Description
[0076] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0077] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0078] Figure 1 This is a flowchart illustrating an embodiment of the heterogeneous code analysis method of this application.
[0079] Figure 2 This is a schematic diagram of the module framework provided in Embodiment 1 of the heterogeneous code analysis method of this application;
[0080] Figure 3 This is a flowchart illustrating Embodiment 2 of the heterogeneous code analysis method of this application;
[0081] Figure 4 This is a flowchart illustrating Embodiment 3 of the heterogeneous code analysis method of this application;
[0082] Figure 5 This is a schematic diagram of the module structure of the heterogeneous code analysis device according to an embodiment of this application;
[0083] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the heterogeneous code analysis method in this application embodiment.
[0084] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0085] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0086] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0087] The main solution of this application embodiment is as follows: In response to a code analysis request, structural analysis is performed on heterogeneous code to obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages; natural language intermediate representation information of the heterogeneous code is determined based on the structural analysis results; code anomaly analysis is performed on the natural language intermediate representation information based on a large language model to obtain code anomaly analysis results. Since this application transforms heterogeneous code into unified natural language intermediate representation information before performing code anomaly analysis, compared to existing methods that separately detect anomalies in each single language within the heterogeneous code, the above method of this application can improve the efficiency of anomaly detection for heterogeneous code.
[0088] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or heterogeneous code analysis device capable of performing the above functions. The following description uses a heterogeneous code analysis device as an example to illustrate this embodiment and the subsequent embodiments.
[0089] Based on this, embodiments of this application provide a heterogeneous code analysis method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the heterogeneous code analysis method of this application.
[0090] In this embodiment, the heterogeneous code analysis method includes the following steps:
[0091] Step S10: In response to the code analysis request, perform structural analysis on the heterogeneous code to obtain the structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0092] It should be noted that heterogeneous programming refers to the combined use of multiple programming languages, computing architectures, or computing resources within a single software development environment to optimize performance, improve flexibility, or enhance productivity. The heterogeneous code refers to code using multiple programming languages during the heterogeneous programming process. The code analysis request can be a command to perform anomaly analysis on the code within the heterogeneous code. The structural analysis of the heterogeneous code can involve identifying and analyzing the interaction interfaces of the heterogeneous code, specifically including analyzing interfaces such as RESTful API endpoints, GraphQL queries, and RPC service definitions in the heterogeneous code using a Large Language Model (LLM). Static code analysis based on LLM can identify cross-language interfaces and data interaction points, which is crucial for understanding the collaboration between different language modules. By analyzing interfaces such as RESTful API endpoints, GraphQL queries, and RPC service definitions, LLM can construct a comprehensive dependency graph, identify potential dependency conflicts and security vulnerabilities in the system, and obtain the structural analysis results output by LLM.
[0093] Step S20: Determine the natural language intermediate representation information of the heterogeneous code based on the structural analysis results;
[0094] It should be noted that Natural Language Intermediate Representation (NLIR) is a concept in Natural Language Processing (NLP). It refers to converting natural language text into a structured, intermediate-level representation that retains the essential information of the original text while facilitating further processing and understanding by the computer. NLIR typically sits between the original text and the final application output, acting as a bridge between the two. The determination of the NLIR information for the heterogeneous code based on the structural analysis results can be generated using LLM and structural analysis results. As an abstract representation independent of specific programming languages, NLIR preserves the structure and semantics of the original code while removing language-specific syntactic details. NLIR can describe in detail the data flow path within the system, including the data entry points, exit points, and transformation processes, thus providing a solid foundation for subsequent in-depth analysis. Furthermore, the NLIR generation process is fully supported by LLM, ensuring the accuracy and consistency of the intermediate representation. This not only improves the efficiency of static analysis, but also greatly reduces the blind spots in traditional methods caused by language differences, ensuring that every detail of a multilingual system can be fully covered and evaluated.
[0095] Step S30: Perform code anomaly analysis on the intermediate representation information of the natural language based on the large language model to obtain the code anomaly analysis results.
[0096] It should be noted that the code anomaly analysis based on the natural language intermediate representation information, obtained by inputting the natural language intermediate representation information into the large language model, and then performing anomaly analysis on the natural language intermediate representation information through the large language model, yields the code anomaly analysis results. This anomaly analysis can include semantically understanding code logic, tracing data transmission, and identifying potential security issues, such as detecting unused variables, potential null pointer references, and the risk of information leakage. Furthermore, LLM can not only identify common vulnerability patterns, such as SQL injection, cross-site scripting attacks, and insecure data storage, but also discover complex, application-specific security issues through contextual understanding. This intelligent vulnerability identification capability enables development teams to discover and resolve potential security risks early in development, significantly improving the overall security of the system.
[0097] In specific implementation, it can be referred to Figure 2 , Figure 2 This is a schematic diagram of the module framework provided in Embodiment 1 of the heterogeneous code analysis method of this application; this embodiment mainly consists of three modules: a basic information acquisition module, a language-independent intermediate language generation module, and a... Figure 2 The nlir module and the analysis module.
[0098] The basic information acquisition module is primarily responsible for deeply understanding and analyzing the structure and characteristics of the target codebase (i.e., heterogeneous code), providing a data foundation for subsequent NLIR generation. First, this module receives source code files as input. LLM can assist in identifying programming languages and frameworks within the codebase, recognizing subtle features of different programming languages and usage patterns of the latest frameworks. It can also help discover interfaces and data interaction points between different technology stacks. Furthermore, LLM can help understand and interpret complex dependencies and even predict potential dependency conflicts. The output of this module not only provides necessary contextual information for subsequent NLIR generation but also lays a solid foundation for the entire analysis process.
[0099] The NLIR generation module is the core of the entire architecture. Its main function is to transform code from various programming languages into a unified, abstract intermediate representation. This module receives detailed codebase reports from the basic information acquisition module as input, and through a series of abstraction and transformation steps, ultimately outputs NLIR (Natural Language Intermediate Representation). Internally, the module contains three important processing units: data transmission pattern recognition, interface information analysis and mapping, and general code representation generation. Data transmission pattern recognition analyzes the data flow patterns in the system, revealing how data is transferred between different components. Interface information analysis and mapping focuses on understanding and unifying various programming interfaces, creating conditions for cross-language analysis. Finally, the general code representation generation unit integrates all this information to create the NLIR. As a representation independent of specific programming languages, NLIR preserves the structure and semantics of the original code while providing a unified analytical foundation. The output of this module provides a powerful and flexible tool for subsequent in-depth analysis.
[0100] The analysis module is the final stage of the entire system. It utilizes the unified representation provided by NLIR to perform a series of in-depth code analysis tasks. This module takes NLIR as input and outputs comprehensive code quality, security, and performance reports through multi-dimensional analysis. Internally, the module contains three core analysis units: data flow analysis, control flow analysis, and vulnerability analysis. Data flow analysis tracks the flow of data throughout the system, revealing potential data processing problems and optimization opportunities. Control flow analysis delves into the program's execution path, identifying logical flaws and performance bottlenecks. Vulnerability analysis focuses on discovering potential security vulnerabilities, assessing code security from multiple perspectives. The output of this module is a detailed analysis report, which includes a comprehensive assessment of code quality, specific optimization suggestions, and warnings of potential risks, enabling more comprehensive static analysis of heterogeneous code.
[0101] Furthermore, in order to improve code analysis efficiency, step S30 may include: performing data flow analysis, control flow analysis, and vulnerability analysis on the natural language intermediate representation information based on a large language model to obtain code anomaly analysis results.
[0102] It should be noted that data flow analysis of the intermediate representation information of natural language based on a large language model can be performed using NLIR. LLM can track the flow path of data throughout the system, identifying the data source, transformation process, and final usage point. This process can also identify unused variables, potential null pointer references, and possible information leakage issues.
[0103] It should be noted that control flow analysis of the intermediate natural language representation information based on a large language model can utilize LLM analysis to analyze the code's execution path, including information such as conditional statements, loops, and function calls. This allows for understanding the program's logical structure, identifying potential dead code, infinite loops, and complex decision paths. Control flow analysis can help optimize code structure, improving readability and maintainability. It can also identify potential logical errors, such as unreachable code or resource leaks.
[0104] Vulnerability analysis based on the intermediate representation information of natural language using a large language model (LLM) can combine the results of previous analyses (data flow analysis and control flow analysis) to identify potential security vulnerabilities in the code. These include, but are not limited to, SQL injection, cross-site scripting attacks, insecure data storage, or improper error handling. LLM not only identifies common vulnerability patterns but also understands context, uncovering complex, application-specific security issues. Vulnerability analysis can help development teams discover and resolve potential security problems early in development, improving the overall security of the system.
[0105] In this embodiment, in response to a code analysis request, structural analysis is performed on heterogeneous code to obtain structural analysis results. The heterogeneous code includes code from multiple programming languages. Based on the structural analysis results, natural language intermediate representation information of the heterogeneous code is determined. Code anomaly analysis is then performed on the natural language intermediate representation information based on a large language model to obtain code anomaly analysis results. Since this embodiment transforms heterogeneous code into unified natural language intermediate representation information before performing code anomaly analysis, compared to existing methods that separately detect anomalies in each single language within the heterogeneous code, this embodiment improves the efficiency of anomaly detection for heterogeneous code.
[0106] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 , Figure 3 This is a flowchart illustrating Embodiment 2 of the heterogeneous code analysis method of this application. Step S20 further includes the following steps:
[0107] Step S201: Determine the data transmission mode of the heterogeneous code based on the structural analysis results;
[0108] It should be noted that determining the data transmission mode of the heterogeneous code based on the structural analysis results can be achieved by identifying the data flow mode and path of the heterogeneous code based on the structural analysis results, revealing how data is transferred between different components. This yields the data transmission mode of the heterogeneous code.
[0109] Furthermore, in order to improve the analysis efficiency of heterogeneous code, step S201 may include: determining the data in / out points corresponding to the heterogeneous code based on the structural analysis results;
[0110] Identify the encoding and protocol information of the heterogeneous code;
[0111] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0112] It should be noted that determining the data ingress / egress points corresponding to the heterogeneous code based on the structural analysis results can involve inputting the structural analysis results into the LLM (Local Management Model), using the LLM to identify all data entry points (such as API endpoints, database read operations, file I / O, etc.) and data exit points (such as response sending, database writing, file output, etc.) of the heterogeneous code. Identifying the encoding and protocol information of the heterogeneous code can be achieved by using the LLM to identify the encoding method (such as JSON, XML, Protocol Buffers, etc.) and decoding process of the data before transmission. Simultaneously, it involves analyzing the network protocols that may be used (such as HTTP, WebSocket, gRPC, etc.) and related configurations to obtain the encoding and protocol information. Determining the data transmission mode of the heterogeneous code based on the data ingress / egress points, the encoding information, and the protocol information can be achieved by constructing a complete data flow path in the system, including intermediate processing steps. These processes help generate accurate NLIRs and provide a crucial foundation for subsequent in-depth analysis.
[0113] Step S202: Based on the structural analysis results, perform interface information analysis on the heterogeneous code to obtain interface analysis results;
[0114] It should be noted that the interface information analysis of the heterogeneous code based on the structural analysis results can be aimed at understanding and unifying various programming interfaces, creating conditions for cross-language analysis, and generating interface analysis results for each interface.
[0115] Furthermore, in order to improve the analysis efficiency of heterogeneous code, step S202 may include: inputting the structural analysis results into a large language model, and performing interface information analysis on the structural analysis results through the large language model to obtain interface analysis results;
[0116] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0117] It should be noted that the interface information analysis includes interface analysis and mapping. Interface analysis and mapping focus on understanding and unifying the various programming interfaces in the system, creating conditions for cross-language and cross-framework analysis. First, with the help of structural analysis results, LLM can collect all interface definitions in the system from source code, comments, and documentation, including function signatures, class methods, API endpoints, etc. At the same time, it analyzes the function and purpose of the interface, including side effects and state changes. Next, it analyzes the input parameters and return value types of the interface, including complex data structures. Then, it establishes the correspondence between interfaces in different programming languages to obtain the interface analysis results.
[0118] Step S203: Determine the natural language intermediate representation information of the heterogeneous code based on the data transmission mode and the interface analysis results.
[0119] It should be noted that determining the natural language intermediate representation information of the heterogeneous code based on the data transmission pattern and the interface analysis results can be achieved by combining the data transmission pattern and the interface analysis results to generate an abstract, language-independent, general code representation (NLI R). The design of NLIR preserves the structure and semantics of the code but removes the syntactic details of specific languages. The design of NLI R includes the following key features:
[0120] Basic structure: It uses a structure similar to an abstract syntax tree (AST), where each node represents a program concept.
[0121] Node types include the root node Program, function or method definition Function, variable declaration and usage Variable, expression Expression, statement Statement, control flow structure (such as condition, loop) Control, data type DataType, module or namespace Module, interface definition Interface, and important comments Comment, etc.
[0122] Attribute system: Each node can have multiple attributes to capture additional information, such as source code location, visibility, modifiers, etc.
[0123] Type system: Use a unified type system to represent the types of different languages, including basic types, composite types, and generics.
[0124] Expressive ability: Able to express functional and object-oriented programming paradigms, asynchronous programming models, error handling mechanisms, and the concepts of modularity and encapsulation.
[0125] Metadata: Supports additional metadata for storing language-specific information or analysis results.
[0126] In practice, the JavaScript function for calculating the area of a circle is:
[0127]
[0128]
[0129] This embodiment determines the data transmission mode of the heterogeneous code based on the structural analysis results; performs interface information analysis on the heterogeneous code based on the structural analysis results to obtain interface analysis results; and determines the natural language intermediate representation information of the heterogeneous code based on the data transmission mode and the interface analysis results. By converting heterogeneous code into natural language intermediate representation information, this embodiment not only effectively performs static analysis on single-language units in multilingual programs, but also comprehensively analyzes the interfaces between different languages and cross-language security vulnerabilities, providing strong support for comprehensively improving software security.
[0130] Based on the above embodiments of this application, in the third embodiment of this application, the same or similar content as the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 4 , Figure 4 This is a flowchart illustrating Embodiment 2 of the heterogeneous code analysis method of this application. Step S10 further includes the following steps:
[0131] Step S101: Perform language and framework recognition on the heterogeneous code to obtain the language recognition results;
[0132] It should be noted that the language and framework identification of heterogeneous code, and the resulting language identification, can be achieved by using a trained large language model to identify the characteristics of various programming languages and common framework patterns within the heterogeneous code. This large language model can quickly scan codebases to determine the programming languages used (such as Java, Python, JavaScript, etc.) and the relevant front-end and back-end frameworks (such as Spring, Django, React, etc.). This identification goes beyond simple keyword matching; it involves a deeper understanding of the code's structure and characteristics. For example, the framework used can be determined by identifying specific import statements (in computer programming, import statements are mainly used to import external modules or libraries into the current script or program to use their functions, classes, variables, etc.), configuration files, or the execution patterns of the computer code.
[0133] Step S102: Based on the language recognition results, perform cross-framework interaction point recognition on the heterogeneous code to obtain data interaction recognition results;
[0134] It should be noted that in complex systems, heterogeneous code needs to interact with each other. Identifying cross-framework interaction points based on the language recognition results can be achieved by using an LLM to scan the entire heterogeneous codebase and search for possible external interface definitions. These include, but are not limited to, RESTful API endpoints, GraphQL queries, RPC service definitions, message queue producers and consumers, etc. In this process, the large language model accurately identifies these interfaces by understanding the code context and comments.
[0135] Step S103: Perform dependency analysis on the heterogeneous code to obtain the dependency analysis results;
[0136] It should be noted that the dependency analysis of the heterogeneous code can be performed by using LLM to identify dependency information introduced in the heterogeneous code, such as dependency files and dependency declarations.
[0137] Furthermore, in order to improve the efficiency of code analysis, step S103 may include: scanning the heterogeneous code and determining the configuration information of the heterogeneous code;
[0138] The dependency information of the heterogeneous code is determined based on the configuration information;
[0139] The dependency analysis results are determined based on the dependency information.
[0140] It should be noted that the configuration information may include import information in the code, package management configuration files, and other dependency declarations. Determining the dependency information of the heterogeneous code based on the configuration information may involve determining direct and indirect dependencies, transitive dependencies, etc., in the heterogeneous code based on the configuration information.
[0141] In practice, LLM can analyze import statements, package management configuration files, and other dependency declarations in the code to build a comprehensive dependency graph. This dependency graph includes not only direct dependencies but also transitive dependencies, which helps in understanding the overall system structure and potential vulnerabilities. Dependency analysis can help identify outdated libraries, version conflicts, and potential security vulnerabilities.
[0142] Step S104: Determine the structural analysis result of the heterogeneous code based on the language recognition result, the data interaction recognition result, and the dependency analysis result.
[0143] It should be noted that the structural analysis result of determining the heterogeneous code based on the language recognition result, the data interaction recognition result, and the dependency analysis result can be obtained by summarizing and integrating the above recognition results according to LLM, to obtain a comprehensive framework and dependency graph corresponding to the heterogeneous code, i.e., the structural analysis result.
[0144] This embodiment performs language and framework identification on heterogeneous code to obtain language identification results; based on the language identification results, it identifies cross-framework interaction points in the heterogeneous code to obtain data interaction identification results; it performs dependency analysis on the heterogeneous code to obtain dependency analysis results; and it determines the structural analysis results of the heterogeneous code based on the language identification results, the data interaction identification results, and the dependency analysis results. This embodiment, by performing structural analysis on heterogeneous code, lays the foundation for subsequent code analysis, ensuring the correct understanding and handling of different programming languages and frameworks.
[0145] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the heterogeneous code analysis method of this application. Any simple transformations based on this technical concept are within the protection scope of this application.
[0146] This application also provides a heterogeneous code analysis device; please refer to [reference needed]. Figure 5 The heterogeneous code analysis device includes:
[0147] The response module 10 is used to respond to a code analysis request, perform structural analysis on the heterogeneous code, and obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0148] The intermediate representation information generation module 20 is used to determine the natural language intermediate representation information of the heterogeneous code based on the structural analysis results;
[0149] The anomaly analysis module 30 is used to perform code anomaly analysis on the intermediate representation information of the natural language based on the large language model, and obtain code anomaly analysis results.
[0150] In this embodiment, in response to a code analysis request, structural analysis is performed on heterogeneous code to obtain structural analysis results. The heterogeneous code includes code from multiple programming languages. Based on the structural analysis results, natural language intermediate representation information of the heterogeneous code is determined. Code anomaly analysis is then performed on the natural language intermediate representation information based on a large language model to obtain code anomaly analysis results. Since this embodiment transforms heterogeneous code into unified natural language intermediate representation information before performing code anomaly analysis, compared to existing methods that separately detect anomalies in each single language within the heterogeneous code, this embodiment improves the efficiency of anomaly detection for heterogeneous code.
[0151] Based on the first embodiment of the heterogeneous code analysis device of the present invention, a second embodiment of the heterogeneous code analysis device of the present invention is proposed.
[0152] In this embodiment, the intermediate representation information generation module 20 is further configured to determine the data transmission mode of the heterogeneous code based on the structural analysis results;
[0153] Based on the structural analysis results, interface information analysis is performed on the heterogeneous code to obtain interface analysis results;
[0154] The natural language intermediate representation information of the heterogeneous code is determined based on the data transmission mode and the interface analysis results.
[0155] Furthermore, the intermediate representation information generation module 20 is also used to determine the data input / output points corresponding to the heterogeneous code based on the structural analysis results;
[0156] Identify the encoding and protocol information of the heterogeneous code;
[0157] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0158] Furthermore, the intermediate representation information generation module 20 is also used to construct the data flow path corresponding to the heterogeneous code based on the data inlet / outlet points, the encoding information, and the protocol information;
[0159] The data transmission mode of the heterogeneous code is determined based on the data flow path.
[0160] Furthermore, the intermediate representation information generation module 20 is also used to input the structural analysis results into the large language model, and to perform interface information analysis on the structural analysis results through the large language model to obtain interface analysis results;
[0161] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0162] Furthermore, the response module 10 is also used to perform language and framework recognition on the heterogeneous code to obtain language recognition results;
[0163] Based on the language recognition results, cross-framework interaction points are identified in the heterogeneous code to obtain data interaction recognition results.
[0164] Dependency analysis was performed on the heterogeneous code to obtain the dependency analysis results;
[0165] The structural analysis results of the heterogeneous code are determined based on the language recognition results, the data interaction recognition results, and the dependency analysis results.
[0166] Furthermore, the response module 10 is also used to scan the heterogeneous code and determine the configuration information of the heterogeneous code;
[0167] The dependency information of the heterogeneous code is determined based on the configuration information;
[0168] The dependency analysis results are determined based on the dependency information.
[0169] Furthermore, the anomaly analysis module 30 is also used to perform data flow analysis, control flow analysis, and vulnerability analysis on the natural language intermediate representation information based on the large language model, so as to obtain code anomaly analysis results.
[0170] Furthermore, the anomaly analysis module 30 is also used to track the data flow path in the intermediate representation information of the natural language based on the large language model;
[0171] The data flow analysis results are determined based on the data flow path.
[0172] Furthermore, the anomaly analysis module 30 is also used to perform execution path tracking on the code in the intermediate representation information of the natural language based on the large language model, so as to obtain the execution path information of the code;
[0173] The control flow analysis results are determined based on the execution path information.
[0174] Furthermore, the anomaly analysis module 30 is also used to understand the code semantic information of the natural language intermediate representation information based on the large language model, and obtain the code semantic information;
[0175] Vulnerability information in the heterogeneous code is identified based on the semantic information of the code.
[0176] The vulnerability analysis results are determined based on the vulnerability information.
[0177] The heterogeneous code analysis apparatus provided in this application, employing the heterogeneous code analysis method in the above embodiments, can solve the problem of low efficiency in existing technologies for anomaly analysis of heterogeneous code. Compared with the prior art, the beneficial effects of the heterogeneous code analysis apparatus provided in this application are the same as those of the heterogeneous code analysis method provided in the above embodiments, and other technical features in the heterogeneous code analysis apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0178] This application provides a heterogeneous code analysis device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the heterogeneous code analysis method in the above embodiment 1.
[0179] The following is for reference. Figure 6 This document illustrates a structural diagram of a heterogeneous code analysis device suitable for implementing embodiments of this application. The heterogeneous code analysis device in these embodiments may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 6 The heterogeneous code analysis device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0180] like Figure 6 As shown, the heterogeneous code analysis device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 1002 or a program loaded from storage device 1003 into random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the heterogeneous code analysis device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the heterogeneous code analysis device to communicate wirelessly or wiredly with other devices to exchange data. Although a heterogeneous code analysis device with various systems is shown in the figure, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.
[0181] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0182] The heterogeneous code analysis device provided in this application, employing the heterogeneous code analysis method in the above embodiments, can solve the problem of low efficiency in existing technologies for anomaly analysis of heterogeneous code. Compared with the prior art, the beneficial effects of the heterogeneous code analysis device provided in this application are the same as those of the heterogeneous code analysis method provided in the above embodiments, and other technical features of this heterogeneous code analysis device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.
[0183] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0184] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0185] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the heterogeneous code analysis method in the above embodiments.
[0186] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0187] The aforementioned computer-readable storage medium may be included in the heterogeneous code analysis device; or it may exist independently and not be assembled into the heterogeneous code analysis device.
[0188] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0189] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0190] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0191] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described heterogeneous code analysis method, thereby solving the problem of low efficiency in existing technologies for anomaly analysis of heterogeneous code. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the heterogeneous code analysis method provided in the above embodiments, and will not be repeated here.
[0192] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the heterogeneous code analysis method described above.
[0193] The computer program product provided in this application can solve the problem of low efficiency in existing technologies for anomaly analysis of heterogeneous code. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the heterogeneous code analysis method provided in the above embodiments, and will not be repeated here.
[0194] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
[0195] This invention discloses A1. A heterogeneous code analysis method, which includes the following steps:
[0196] In response to a code analysis request, structural analysis is performed on the heterogeneous code to obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0197] The natural language intermediate representation information of the heterogeneous code is determined based on the structural analysis results;
[0198] Code anomaly analysis is performed on the intermediate representation information of the natural language based on the large language model, and the code anomaly analysis results are obtained.
[0199] A2. The heterogeneous code analysis method as described in A1, wherein the step of determining the natural language intermediate representation information of the heterogeneous code based on the structural analysis result includes:
[0200] The data transmission mode of the heterogeneous code is determined based on the structural analysis results;
[0201] Based on the structural analysis results, interface information analysis is performed on the heterogeneous code to obtain interface analysis results;
[0202] The natural language intermediate representation information of the heterogeneous code is determined based on the data transmission mode and the interface analysis results.
[0203] A3. The heterogeneous code analysis method as described in A2, wherein the step of determining the data transmission mode of the heterogeneous code based on the structural analysis results includes:
[0204] The data in / out points corresponding to the heterogeneous code are determined based on the structural analysis results.
[0205] Identify the encoding and protocol information of the heterogeneous code;
[0206] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0207] A4. The heterogeneous code analysis method as described in A3, wherein the step of determining the data transmission mode of the heterogeneous code based on the data ingress / egress points, the encoding information, and the protocol information includes:
[0208] Construct the data flow path corresponding to the heterogeneous code based on the data in / out points, the encoding information, and the protocol information;
[0209] The data transmission mode of the heterogeneous code is determined based on the data flow path.
[0210] A5. The heterogeneous code analysis method as described in A2, wherein the step of performing interface information analysis on the heterogeneous code based on the structural analysis results to obtain interface analysis results includes:
[0211] The structural analysis results are input into a large language model, and the interface information of the structural analysis results is analyzed by the large language model to obtain the interface analysis results.
[0212] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0213] A6. The heterogeneous code analysis method as described in any one of A1-A5, wherein the step of performing structural analysis on the heterogeneous code to obtain the structural analysis result includes:
[0214] Language and framework identification is performed on heterogeneous code to obtain language identification results;
[0215] Based on the language recognition results, cross-framework interaction points are identified in the heterogeneous code to obtain data interaction recognition results.
[0216] Dependency analysis was performed on the heterogeneous code to obtain the dependency analysis results;
[0217] The structural analysis results of the heterogeneous code are determined based on the language recognition results, the data interaction recognition results, and the dependency analysis results.
[0218] A7. The heterogeneous code analysis method as described in A6, wherein the step of performing dependency analysis on the heterogeneous code to obtain the dependency analysis results includes:
[0219] Scan the heterogeneous code to determine its configuration information;
[0220] The dependency information of the heterogeneous code is determined based on the configuration information;
[0221] The dependency analysis results are determined based on the dependency information.
[0222] A8. The heterogeneous code analysis method as described in any one of A1-A5, wherein the step of performing code anomaly analysis on the intermediate representation information of the natural language based on a large language model to obtain the code anomaly analysis result includes:
[0223] Based on the large language model, data flow analysis, control flow analysis, and vulnerability analysis are performed on the intermediate representation information of the natural language to obtain code anomaly analysis results.
[0224] A9. The heterogeneous code analysis method as described in A8, wherein the step of performing data flow analysis on the intermediate representation information of the natural language based on a large language model includes:
[0225] Based on a large language model, the data flow path in the intermediate representation information of the natural language is tracked;
[0226] The data flow analysis results are determined based on the data flow path.
[0227] A10. The heterogeneous code analysis method as described in A8, wherein the step of performing control flow analysis on the intermediate representation information of the natural language based on a large language model includes:
[0228] Based on the large language model, the execution path of the code in the intermediate representation information of the natural language is traced to obtain the execution path information of the code;
[0229] The control flow analysis results are determined based on the execution path information.
[0230] A11. The heterogeneous code analysis method as described in A8, wherein the step of performing vulnerability analysis on the intermediate representation information of the natural language based on a large language model includes:
[0231] Based on the large language model, the code semantic information of the intermediate representation information of the natural language is understood to obtain the code semantic information;
[0232] Vulnerability information in the heterogeneous code is identified based on the semantic information of the code.
[0233] The vulnerability analysis results are determined based on the vulnerability information.
[0234] This invention discloses B12. A heterogeneous code analysis device, the heterogeneous code analysis device comprising:
[0235] The response module is used to respond to code analysis requests, perform structural analysis on heterogeneous code, and obtain structural analysis results, wherein the heterogeneous code includes code from multiple programming languages;
[0236] An intermediate representation information generation module is used to determine the natural language intermediate representation information of the heterogeneous code based on the structural analysis results;
[0237] The anomaly analysis module is used to perform code anomaly analysis on the intermediate representation information of the natural language based on the large language model, and obtain the code anomaly analysis results.
[0238] B13. The heterogeneous code analysis device as described in B12, wherein the intermediate representation information generation module is further configured to determine the data transmission mode of the heterogeneous code based on the structural analysis results;
[0239] Based on the structural analysis results, interface information analysis is performed on the heterogeneous code to obtain interface analysis results;
[0240] The natural language intermediate representation information of the heterogeneous code is determined based on the data transmission mode and the interface analysis results.
[0241] B14. The heterogeneous code analysis device as described in B13, wherein the intermediate representation information generation module is further configured to determine the data input / output points corresponding to the heterogeneous code based on the structural analysis results;
[0242] Identify the encoding and protocol information of the heterogeneous code;
[0243] The data transmission mode of the heterogeneous code is determined based on the data ingress / exgress points, the encoding information, and the protocol information.
[0244] B15. The heterogeneous code analysis device as described in B14, wherein the intermediate representation information generation module is further configured to construct a data flow path corresponding to the heterogeneous code based on the data inlet / outlet points, the encoding information, and the protocol information;
[0245] The data transmission mode of the heterogeneous code is determined based on the data flow path.
[0246] B16. The heterogeneous code analysis device as described in B13, wherein the intermediate representation information generation module is further configured to input the structural analysis result into a large language model, and perform interface information analysis on the structural analysis result through the large language model to obtain the interface analysis result;
[0247] The interface information analysis includes at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis, and interface correspondence analysis.
[0248] B17. The heterogeneous code analysis apparatus as described in any one of B12-B16, wherein the response module is further configured to perform language and frame recognition on the heterogeneous code to obtain language recognition results;
[0249] Based on the language recognition results, cross-framework interaction points are identified in the heterogeneous code to obtain data interaction recognition results.
[0250] Dependency analysis was performed on the heterogeneous code to obtain the dependency analysis results;
[0251] The structural analysis results of the heterogeneous code are determined based on the language recognition results, the data interaction recognition results, and the dependency analysis results.
[0252] This invention discloses C18. A heterogeneous code analysis device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the heterogeneous code analysis method as described in any one of A1 to A11.
[0253] This invention discloses D19. A storage medium, which is a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, it implements the steps of the heterogeneous code analysis method as described in any one of A1 to A11.
[0254] This invention discloses E20. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the heterogeneous code analysis method as described in any one of A1 to A11.
Claims
1. A method of heterogeneous code analysis, characterized by, The heterogeneous code analysis method comprises the following steps: In response to a code analysis request, the heterogeneous code is structurally analyzed to obtain a structural analysis result, wherein the heterogeneous code comprises codes in multiple programming languages; Natural language intermediate representation information of the heterogeneous code is determined according to the structural analysis result; Code anomaly analysis is performed on the natural language intermediate representation information based on a large language model to obtain a code anomaly analysis result; The natural language intermediate representation information uniformly describes the data transmission mode and the interface calling relationship between different programming language codes and is a code general representation independent of specific programming languages; The code anomaly analysis based on the large language model comprises: Data flow analysis, control flow analysis and vulnerability analysis are performed on the natural language intermediate representation information based on the large language model to obtain a code anomaly analysis result, wherein the data flow analysis is used to track the data flow path, reveal potential data processing problems and optimization opportunities, the control flow analysis is used to analyze the execution path of the heterogeneous code, identify logical defects and performance bottlenecks, and the vulnerability analysis is used to find potential security vulnerabilities.
2. The heterogeneous code analysis method of claim 1, wherein, The step of determining the natural language intermediate representation information of the heterogeneous code according to the structural analysis result comprises: A data transmission mode of the heterogeneous code is determined according to the structural analysis result; Interface information analysis is performed on the heterogeneous code based on the structural analysis result to obtain an interface analysis result; The natural language intermediate representation information of the heterogeneous code is determined according to the data transmission mode and the interface analysis result.
3. The heterogeneous code analysis method of claim 2, wherein, The step of determining the data transmission mode of the heterogeneous code according to the structural analysis result comprises: Data in-out points corresponding to the heterogeneous code are determined according to the structural analysis result; Encoding information and protocol information of the heterogeneous code are identified; The data transmission mode of the heterogeneous code is determined according to the data in-out points, the encoding information and the protocol information.
4. The heterogeneous code analysis method of claim 3, wherein, The step of determining the data transmission mode of the heterogeneous code according to the data in-out points, the encoding information and the protocol information comprises: A data flow path corresponding to the heterogeneous code is constructed according to the data in-out points, the encoding information and the protocol information; The data transmission mode of the heterogeneous code is determined based on the data flow path.
5. The heterogeneous code analysis method of claim 2, wherein, The step of performing interface information analysis on the heterogeneous code based on the structural analysis result to obtain an interface analysis result comprises: The structural analysis result is input into a large language model, and interface information analysis is performed on the structural analysis result by the large language model to obtain an interface analysis result; The interface information analysis comprises at least one of the following: interface definition analysis, interface function analysis, interface return value information analysis and interface corresponding relationship analysis.
6. The heterogeneous code analysis method of any one of claims 1-5, wherein, The step of performing structural analysis on the heterogeneous code to obtain a structural analysis result comprises: Language and framework recognition is performed on the heterogeneous code to obtain a language recognition result; Cross-framework interaction point recognition is performed on the heterogeneous code based on the language recognition result to obtain a data interaction recognition result; Perform dependency analysis on the heterogeneous code to obtain a dependency analysis result; Determine a structure analysis result of the heterogeneous code according to the language recognition result, the data interaction recognition result, and the dependency analysis result.
7. A heterogeneous code analysis apparatus, characterized by comprising: The heterogeneous code analysis apparatus includes: In response to a code analysis request, perform structure analysis on the heterogeneous code to obtain a structure analysis result, wherein the heterogeneous code includes code in multiple programming languages; Determine natural language intermediate representation information of the heterogeneous code according to the structure analysis result; Perform code exception analysis on the natural language intermediate representation information based on a large language model to obtain a code exception analysis result; The natural language intermediate representation information uniformly describes data transmission modes and interface calling relationships between different programming language codes and is a code general representation independent of specific programming languages; The exception analysis module is further configured to perform data flow analysis, control flow analysis, and vulnerability analysis on the natural language intermediate representation information based on the large language model to obtain the code exception analysis result, wherein the data flow analysis is used to track a data flow path to reveal potential data processing problems and optimization opportunities, the control flow analysis is used to analyze an execution path of the heterogeneous code to identify logical defects and performance bottlenecks, and the vulnerability analysis is used to find potential security vulnerabilities.
8. A heterogeneous code analysis device, characterized by, The device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the heterogeneous code analysis method according to any one of claims 1 to 6.
9. A storage medium, characterized by The storage medium is a computer readable storage medium, and the storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the heterogeneous code analysis method according to any one of claims 1 to 6.
10. A computer program product, characterised in that, The computer program product includes a computer program, and the computer program is executed by the processor to implement the steps of the heterogeneous code analysis method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Vulnerability detection method, device and system for open source software
CN110543770A
Web malicious program detection method and system based on cross-language semantic analysis
CN116432176A
Hybrid software vulnerability analysis method and system
CN117556431A
Security vulnerability analysis method based on intermediate language and electronic device including the same
KR102367196B1