A software modeling-based identification and analysis method
By using lexical analysis, multilingual syntax parsing, and cross-language node semantic mapping, a unified abstract syntax tree is generated. Combined with control flow graph generation and path traversal algorithms, the problem of tracing cross-language call relationships in a multilingual environment is solved, enabling accurate analysis and verification of multilingual software systems.
Patent Information
- Application Number
- CN202611395827.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-09
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies struggle to accurately extract the unique grammatical structures of each language in a multilingual environment and convert them into a unified analyzable form. This results in fragmented analysis results for cross-language software systems, failing to reflect the calling relationships and data flow processes between multilingual modules.
By extracting reserved keywords and custom identifiers from multilingual mixed programs using a lexical analyzer, recognizing statement structures and expression forms using a multilingual syntax parser, generating a heterogeneous set of syntax trees, and performing standardized transformation through a cross-language node semantic mapper to construct a unified abstract syntax tree, and combining control flow graph generation algorithms and path traversal algorithms, the tracking of cross-language call relationships and the verification of execution paths can be realized.
It enables accurate tracking of cross-language call relationships and effective verification of execution paths in multilingual mixed programs, improving the accuracy and reliability of software modeling, and accurately analyzing the complete execution path and branch logic of code.
Smart Images

Figure CN123157265A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology, and in particular to a recognition and analysis method based on software modeling. Background Technology
[0002] The structural and behavioral analysis of software systems is a crucial step in ensuring the quality and maintainability of large-scale applications. As enterprise applications continue to expand, individual software systems are often built collaboratively using multiple programming languages; for example, the front-end might use JavaScript, the back-end Java, and data processing modules Python, forming a complex multi-language hybrid architecture. This cross-language collaborative development model has become the mainstream practice in modern software engineering, and accurately grasping the internal logic of such systems has become a core challenge in software quality management.
[0003] Current software system analysis methods primarily focus on code inspection within a single language environment. When dealing with multi-language mixed systems, these methods struggle to establish a unified analytical perspective. Different programming languages exhibit significant differences in syntax rules and execution mechanisms. Java's strongly typed system differs drastically from JavaScript's dynamic characteristics, and Python's indentation syntax and C's curly brace structure each have their own unique features. Existing tools are typically designed for specific languages and cannot capture the overall execution logic of the system across language boundaries. This results in fragmented analysis results, failing to reflect the call relationships and data flow processes between multi-language modules.
[0004] The fundamental challenge of multilingual systems lies in the essential differences in the lexical rules and syntactic structures of various programming languages. At the lexical level, different languages define keywords, identifiers, and operators in significantly different ways; the same symbol may carry completely different semantics in different languages. This heterogeneity at the lexical level directly affects the accuracy of syntax parsing. When analysis tools scan source code, they must dynamically switch recognition rules according to the specific language; otherwise, they may misinterpret the syntactic structure of one language as a statement of another. For example, in a system containing a Java server and a JavaScript client, Java's class definition statements and JavaScript's object literals may appear similar, but their syntax tree structures and execution flows are fundamentally different. If a unified parsing rule is used, the control flow branches of the two will be confused, making it impossible to accurately identify the actual execution order of code blocks. Therefore, how to accurately extract the unique grammatical structures of each language in a multilingual environment and convert these heterogeneous language elements into a unified analyzable form, thereby clearly depicting the complete path and branch logic of code execution, has become a key issue in achieving accurate analysis of cross-language software systems. Summary of the Invention
[0005] This invention provides a software-based modeling-based identification and analysis method, mainly comprising: A source code library for a multi-language mixed program is obtained. A lexical analyzer is used to identify lexical units in the source code library, extracting reserved keywords and custom identifiers for each programming language to obtain a mixed lexical tag sequence containing grammatical elements of different languages. Based on the mixed lexical tag sequence, a multi-language syntax parser is used to distinguish language types and extract grammatical structures. Statement structures and expression forms are identified based on the grammatical rules of each programming language, resulting in a heterogeneous syntax tree set corresponding to the grammatical rules of each programming language. For the heterogeneous syntax tree set, a cross-language node semantic mapper is used to perform semantic consistency analysis and standardization transformation on language-specific grammatical nodes in the heterogeneous syntax tree set. A unified intermediate representation node mapping process is performed on the grammatical nodes of different languages to generate a unified abstract syntax tree. The unified abstract syntax tree is obtained, and a control flow graph generation algorithm based on statement dependencies is used to parse the control transfer relationships of conditional branch statements and loop structure statements in the unified abstract syntax tree to determine an initial control flow graph containing branch jump logic and loop loop structures. For the initial control flow graph, chain analysis is used to trace variable assignment and reference operations in the initial control flow graph through variable definition, extracting variable transitive dependencies across basic blocks to obtain an enhanced control flow graph labeled with variable lifecycle information and data dependency edges. It is then determined whether a cross-programming language call node exists in the enhanced control flow graph. If such a node exists, control flow edges between the caller and callee are connected according to a pre-built cross-language interface mapping rule table, establishing cross-language boundary control flow transition relationships to obtain a global control flow graph covering multi-language call chains. Based on the global control flow graph, a path enumeration algorithm is used to enumerate the basic block nodes and transition edges in the global control flow graph, extracting complete node access sequences from program entry point to program exit point, and obtaining a complete set of execution paths including cross-language call boundary transitions. For the complete set of execution paths, a path verification algorithm based on temporal logic rules is used to perform a legality comparison of the execution order of nodes in the complete set of execution paths. Based on the preset resource access temporal constraint rules and function call order dependency rules, legal paths that conform to the execution semantics are selected, and the target execution path that meets the preset execution rules is determined.
[0006] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: This invention discloses a software modeling-based identification and analysis method that solves the technical problems of accurately tracking cross-language call relationships and effectively verifying execution paths in multi-language mixed programs. For complex code libraries containing multiple programming languages, this invention extracts reserved keywords and custom identifiers from each language using a lexical analyzer to form a mixed lexical tag sequence. Then, a multi-language syntax parser identifies the statement structure and expression form of each language to construct a heterogeneous syntax tree set. Finally, a cross-language node semantic mapper converts the syntax nodes of different languages into a unified abstract syntax tree, achieving a standardized representation of heterogeneous languages. Based on this, this invention employs a control flow graph generation algorithm based on statement dependencies to parse the control transfer relationships of conditional branches and loop structures. Furthermore, it uses chain analysis to trace variable transit dependencies across basic blocks through variable definitions, constructing an enhanced control flow graph labeled with variable lifetime information and data dependency edges. For cross-programming language call nodes, this invention establishes control flow transfer relationships across language boundaries based on a pre-built cross-language interface mapping rule table, forming a global control flow graph covering multi-language call links. Finally, a path traversal algorithm is used to extract complete node access sequences, and a path verification algorithm based on temporal logic rules is used to filter out legal paths that meet execution semantics according to resource access temporal constraints and function call order dependency rules. This achieves accurate execution path analysis and verification for multi-language mixed programs, effectively improving the accuracy and reliability of software modeling. Attached Figure Description
[0007] Figure 1 This is a flowchart of a software modeling-based identification and analysis method according to the present invention.
[0008] Figure 2 This is a schematic diagram of a software modeling-based identification and analysis method according to the present invention.
[0009] Figure 3 This is another schematic diagram of a software modeling-based identification and analysis method according to the present invention. Detailed Implementation
[0010] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0011] like Figures 1-3 This embodiment of a software modeling-based identification and analysis method may specifically include: S101. Obtain the source code library of the multi-language mixed program, perform lexical unit recognition processing on the source code library through a lexical analyzer, extract the reserved keywords and custom identifiers of each programming language, and obtain a mixed lexical tag sequence containing grammatical elements of different languages.
[0012] A multilingual hybrid source code library is acquired, and its character stream is read using a character scanning tool to obtain the original code string. Based on the original code string, a Conditional Random Field (CRF) algorithm is used to segment the original code string into language fragments, resulting in multiple single-language code fragments. These single-language code fragments are then matched against a pre-defined language vocabulary to determine the target programming language type for each fragment. For each target programming language type, a corresponding finite state machine is used to identify lexical units in the single-language code fragments, extracting retained keywords and custom identifiers. If the custom identifier contains a pre-defined delimiter, it is split using a string splitting function to obtain basic vocabulary units. Based on the retained keywords and basic vocabulary units, a sequence concatenation operation is used to combine the retained keywords and basic vocabulary units to obtain a hybrid lexical tag string containing grammatical elements of different languages. This hybrid lexical tag string is then obtained and hierarchically parsed using an abstract syntax tree (AST) generation tool to generate a multilingual abstract syntax tree (AST).
[0013] Specifically, a hybrid source code library containing Hypertext Markup Language (HTML) and scripting languages is acquired. A character scanning tool reads the character stream in a fixed window of 1024 characters at a time to obtain the original code string. A Conditional Random Field (CRF) algorithm is then used to segment this string into language fragments. The input is the original code string, and the algorithm identifies language boundaries using contextual feature functions, outputting multiple monolingual code fragments. This approach effectively addresses the problem of traditional regular expression matching failing in complex nested structures, significantly improving the accuracy of multilingual boundary segmentation.
[0014] For example, multiple single-language code snippets obtained from the above segmentation are matched against a pre-defined language vocabulary containing 300 core words. If specific document object model (DOM) operation terms frequently appear in a snippet, its target programming language type is determined to be a scripting language. For this scripting language snippet, a corresponding finite state machine is used for lexical unit identification. Starting from an initial state, the finite state machine undergoes state transitions based on character input, extracting retained keywords and user-defined identifiers. This process accurately isolates the syntactic skeleton and user-defined content of the language, laying the foundation for subsequent in-depth analysis.
[0015] Understandably, if the extracted custom identifiers contain preset underscore delimiters, they are split using a string splitting function to obtain basic vocabulary units. Based on the extracted retained keywords and basic vocabulary units, a sequence concatenation operation is used to combine them to obtain a hybrid lexical token string containing grammatical elements of different languages. This hybrid lexical token string is then obtained and subjected to hierarchical parsing using an abstract syntax tree generation tool to construct a multilingual abstract syntax tree with five levels. This scheme can transform flat token strings into tree structures with strict logical hierarchies, significantly improving the execution efficiency of cross-language code static analysis and security vulnerability detection.
[0016] S102. Based on the mixed lexical tag sequence, a multilingual syntax parser is used to distinguish the language type and extract the syntax structure of the mixed lexical tag sequence. Based on the syntax rules of each programming language, the statement structure and expression form are identified to obtain a set of heterogeneous syntax trees corresponding to the syntax rules of each programming language.
[0017] The mixed lexical tag sequence is obtained, and a multilingual syntax parser is used to distinguish the language classes of the mixed lexical tag sequence to obtain multiple single-language tag subsequences. The multiple single-language tag subsequences are then obtained, and a recursive descent algorithm is used to extract the grammatical structure of the single-language tag subsequences to obtain initial statement blocks. For the initial statement blocks, expression form recognition is performed based on preset specification libraries for each programming language to obtain a single-language expression tree. If the single-language expression tree contains undefined syntax nodes, the types of the undefined syntax nodes are supplemented using node type inference rules to obtain a complete node set. Based on the complete node set, a graph neural network algorithm is used to perform context association analysis on the complete node set to determine the syntax dependency graph. The syntax dependency graph is obtained, and an execution path traversal is performed on the syntax dependency graph using a control flow extraction tool to obtain the program control flow. Based on the program control flow and the single-language expression tree, a tree structure merging operation is used to combine the program control flow and the single-language expression tree to obtain a heterogeneous syntax tree set corresponding to the syntax specifications of each programming language.
[0018] Specifically, the hybrid lexical token sequence obtained from the aforementioned processing is obtained and input into a multilingual parser. This parser, by reading the language identifier bits in the token sequence, splits the hybrid sequence into three independent monolingual token subsequences. For one of the monolingual token subsequences, a top-down grammatical structure extraction algorithm is used. Starting from the initial non-terminal symbol, the algorithm sequentially matches the lexical units in the subsequence. When five basic statement rules are successfully matched consecutively, they are encapsulated into an initial statement block.
[0019] In one embodiment, the initial statement block is obtained, and expression form recognition is performed based on a preset specification library containing 200 standard syntaxes. A preliminary monolingual expression tree is constructed by comparing the order of operators and operands within the statement block. If an undefined syntax node is detected in the monolingual expression tree, such as a variable declaration node lacking a data type, a node type inference rule is triggered. This rule extracts the four context nodes adjacent to the undefined node, and infers and supplements the specific type of the undefined node based on the assignment operation characteristics of the context nodes, thereby obtaining a complete node set.
[0020] It should be noted that, based on the aforementioned complete node set, a graph neural network algorithm is used for context association analysis. The complete node set is used as the vertices of the graph, and the call relationships between nodes are input as edges into the graph neural network model. After three layers of graph convolution operations, deep topological features between nodes are extracted, outputting a syntax dependency graph containing data flow directions. This syntax dependency graph is then used to perform execution path traversal using a depth-first search strategy through a control flow extraction tool, recording conditional branches and loop jump paths to obtain the program control flow. Based on this program control flow and the aforementioned single-language expression tree, a tree structure merging operation is used to map the edge information of the control flow to the corresponding nodes of the expression tree, completing the combination process and ultimately obtaining a heterogeneous set of syntax trees corresponding to the syntax specifications of each programming language.
[0021] S103. For the heterogeneous syntax tree set, a cross-language node semantic mapper is used to perform semantic consistency analysis and standardization transformation on the language-specific syntax nodes in the heterogeneous syntax tree set, and a unified intermediate representation node mapping process is performed on the syntax nodes of different languages to generate a unified abstract syntax tree.
[0022] The heterogeneous syntax tree set is obtained, and a cross-language node semantic mapper is used to traverse the nodes of the heterogeneous syntax tree set to obtain a specific language node set. The specific language node set is then obtained, and a word embedding model is used to extract semantic features from the specific language node set to obtain node semantic vectors. For the node semantic vectors, a cosine similarity calculation tool is used to compare the semantic consistency of the node semantic vectors to determine the semantic matching degree. If the semantic matching degree is greater than a preset matching threshold, the specific language node set is standardized according to preset syntax transformation rules to obtain a standard state node set. The standard state node set is obtained, and a support vector machine is used to map the standard state node set to unified intermediate representation nodes to obtain an intermediate state node set. Based on the intermediate node set, a tree structure reorganization tool is used to hierarchically concatenate the intermediate node set to generate a unified abstract syntax tree.
[0023] Specifically, the aforementioned heterogeneous syntax tree set is obtained and input into a cross-language node semantic mapper. This mapper uses a breadth-first search strategy to traverse the tree structure within the set layer by layer, identifies nodes with specific language tags, and extracts 50 class definition and method call nodes belonging to a specific object-oriented language, forming a specific language node set.
[0024] In one embodiment, a pre-trained word embedding model is used to extract semantic features for the specific language node set mentioned above. The node names and attribute strings in the node set are taken as input and processed through a continuous bag-of-words model architecture to map discrete character information into a 256-dimensional continuous dense vector, thereby obtaining a node semantic vector containing deep semantic information of the nodes.
[0025] It should be noted that after obtaining the semantic vectors of the aforementioned nodes, a cosine similarity calculation tool is used to perform semantic consistency comparison. The extracted vectors are then multiplied by a base vector in a pre-defined standard semantic vector library, and the cosine of the angle between them in vector space is calculated as the semantic matching degree. If this semantic matching degree is determined to be greater than a pre-defined matching threshold of 85, a standardization conversion mechanism is triggered. Based on pre-defined grammatical conversion rules containing 40 mapping relationships, the unique grammatical structures in the specific language node set are replaced with general grammatical structures, resulting in a standard state node set.
[0026] Specifically, the aforementioned standard state node set is obtained and input into a support vector machine (SVM) for unified intermediate representation node mapping. This SVM uses a radial basis function kernel to map the multidimensional features in the standard state node set to a high-dimensional space. By finding the optimal hyperplane, nodes from different language sources but with the same semantics are classified and mapped to a predefined unified intermediate representation node category, outputting an intermediate state node set containing 120 standardized nodes.
[0027] In one embodiment, based on the aforementioned intermediate node set, a tree structure reorganization tool is initiated to perform hierarchical splicing. Taking the main function node in the intermediate node set as the root node, and based on the control flow and data flow dependencies between nodes, a bottom-up hierarchical aggregation algorithm is used to splice each child node layer by layer to the parent node, ultimately generating a unified abstract syntax tree containing complete program logic.
[0028] S104. Obtain the unified form abstract syntax tree, and use a control flow graph generation algorithm based on statement dependencies to parse the control transfer relationships of the conditional branch statements and loop structure statements in the unified form abstract syntax tree, and determine the initial control flow graph containing branch jump logic and loop loop structure.
[0029] Obtain the unified abstract syntax tree (API). Extract conditional blocks and execution blocks from the API using a node type identification tool to obtain a set of key control flow nodes. Obtain the set of key control flow nodes and use a control flow graph generation algorithm based on statement dependencies to parse control transition relationships, obtaining a node transition relationship matrix. For the node transition relationship matrix, connect the non-zero elements using directed edge construction rules to determine an initial directed graph containing jump edges. Obtain the initial directed graph and use a depth-first search tool to traverse the closed-loop paths in the initial directed graph to obtain a set of loop body structures. If the number of loop nodes in the set of loop body structures is greater than a preset node threshold, embed the set of loop body structures into the initial directed graph according to graph structure splicing rules to obtain an initial control flow graph. Obtain the initial control flow graph and use a dead code detection tool to identify unreachable branches in the initial control flow graph to determine a simplified control flow graph.
[0030] Specifically, a unified abstract syntax tree is obtained, and the tree structure is traversed from top to bottom using a node type identification tool. Condition block nodes representing if branches and multi-way branches are identified, as well as execution block nodes representing variable assignments and method calls. Forty-five condition blocks and 120 execution blocks are extracted, and these core elements that determine the program's execution path are combined to obtain a set of key control flow nodes.
[0031] In one embodiment, the aforementioned set of key control flow nodes is obtained and parsed using a control flow graph generation algorithm based on statement dependencies. The execution order and conditional dependencies between nodes are analyzed to construct a 165x165 two-dimensional matrix. If node A's execution inevitably leads to node B's execution, a 1 is entered in the corresponding position of the matrix; otherwise, a 0 is entered, thus obtaining a node transition relationship matrix that accurately reflects the program control transfer relationships.
[0032] It should be noted that, for this node transition relation matrix, non-zero elements are handled using directed edge construction rules. The row indices in the matrix correspond to source nodes, and the column indices correspond to target nodes. Directed connections from the source to the target are established for all elements with a value of 1, generating an initial directed graph containing 210 transition edges.
[0033] Specifically, an initial directed graph is obtained, and a depth-first search tool is used to probe downwards from the entry node. When a backward edge pointing to a visited node is detected, a closed loop path is determined, and a set of loop structures containing both "while" and "until" loops is extracted. If the number of loop nodes in this set is greater than a preset node threshold of 5, then according to the graph structure splicing rules, these loop nodes and their internal transition edges are completely embedded into the corresponding branch positions of the initial directed graph to obtain the initial control flow graph.
[0034] In one embodiment, an initial control flow graph is obtained, and graph reachability analysis is performed using a dead code detection tool. A connectivity traversal is performed starting from the root node of the graph, identifying three unreachable branch points that have no predecessor nodes pointing to them. These isolated nodes, which can never be executed, and their associated edges are removed to determine the final simplified control flow graph, thereby effectively reducing the computational overhead of subsequent program analysis and improving the compactness of the graph structure.
[0035] S105. For the initial control flow graph, the variable assignment and variable reference operations in the initial control flow graph are traced and processed by the chain analysis method through variable definition, and the variable transitive dependency relationship across basic blocks is extracted to obtain an enhanced control flow graph labeled with variable life cycle information and data dependency edges.
[0036] The initial control flow graph is obtained, and variable assignment points and variable reference points are extracted from it using a node traversal tool to obtain a set of variable operation nodes. The variable operation node set is then obtained, and the start and end points are matched and traced using a variable definition usage chain analysis method to determine the initial definition usage chain. The initial definition usage chain is obtained, and the transit paths across different basic blocks in the chain are identified using path resolution rules to obtain a set of cross-block transit paths. The cross-block transit path set is obtained, and the activity of each variable in the cross-block transit path set is calculated using an active variable analysis algorithm to obtain a variable lifecycle table. The variable lifecycle table is obtained, and the initial definition usage chain is labeled with connections based on it to determine a set of data dependency edges. The data dependency edge set is obtained, and the variable lifecycle table is embedded into the initial control flow graph using graph structure merging rules to obtain an enhanced control flow graph. The enhanced control flow graph is obtained. If the number of data dependency edges in the enhanced control flow graph is greater than a preset edge number threshold, a graph segmentation tool is used to perform modular splitting of the enhanced control flow graph to obtain the target control flow graph.
[0037] Specifically, the initial control flow graph is obtained, and the basic block nodes in the graph are scanned using a node traversal tool. Variable assignment points that perform write operations on variables and variable reference points that read variable values are identified. 85 variable assignment points and 260 variable reference points are extracted, and these nodes involving memory state changes and reads are combined to obtain a set of variable operation nodes.
[0038] In one embodiment, the aforementioned set of variable operation nodes is obtained, and a variable definition usage chain analysis method is used for tracing. For each variable assignment point, the process searches downstream along the control flow path to find all variable reference points that might read the assignment result. Successfully matched starting assignment points are paired with ending reference points to determine an initial definition usage chain containing 180 mapping relationships.
[0039] It should be noted that the initial definition usage chain is obtained, and the physical distribution of the chain is checked through path resolution rules. If the starting point and ending point of a definition usage chain belong to different basic block nodes, it is determined that there is cross-block propagation behavior, thereby extracting 110 cross-block propagation paths and obtaining a set of cross-block propagation paths.
[0040] Specifically, the cross-block propagation path set is obtained, and an active variable analysis algorithm is used for reverse data flow calculation. Starting from the program's exit node, the process traces upstream, updating the active state set based on variable references. The node range from the first definition to the last reference for each variable is recorded, generating a variable lifecycle table containing the lifespan of 50 variables.
[0041] In one embodiment, a variable lifecycle table is obtained, and the initial definitions are labeled with chains based on this table. Assuming the variables remain active along the propagation path and have not been reassigned, direct connections are established between the start and end points, determining a data dependency edge set containing 145 connections.
[0042] It should be noted that the data dependency edge set is obtained, and the information of the above data dependency edge set and variable life cycle table is used as additional attributes by the graph structure merging rules. These are then superimposed and embedded onto the corresponding nodes and edges of the initial control flow graph to obtain an enhanced control flow graph that integrates control transfer and data flow information.
[0043] Specifically, the enhanced control flow graph is obtained, and the number of data dependency edges within it is counted. If this number reaches 600 and exceeds the preset edge count threshold of 500, the strongly connected component-based splitting algorithm in the graph segmentation tool is used to divide the massive enhanced control flow graph into four loosely coupled independent modules, thus obtaining the final target control flow graph.
[0044] S106. Determine whether there is a cross-programming language call node in the enhanced control flow graph. If there is a cross-programming language call node, perform control flow edge connection processing between the caller and the callee on the cross-programming language call node according to the pre-built cross-language interface mapping rule table, establish the control flow transfer relationship of the cross-language boundary, and obtain a global control flow graph covering the multi-language call chain.
[0045] The enhanced control flow graph is obtained, and cross-language call nodes are extracted from it using a node type identification tool to obtain a cross-language call node set. The cross-language call node set is then obtained, and function signature information is extracted from it using a text parsing tool to obtain a function signature string set. This function signature string set is then obtained, and compared with a cross-language interface mapping rule table to obtain an interface matching score. If the interface matching score is greater than a preset matching threshold, the corresponding caller and callee are determined based on the function signature string set to obtain cross-language caller and callee pairs. These pairs are then obtained, and a directed graph connection tool is used to connect them, generating a cross-language transition edge set. Finally, this cross-language transition edge set is inserted into the enhanced control flow graph to obtain a global control flow graph covering multi-language call chains.
[0046] Specifically, an enhanced control flow graph is obtained, and nodes in the graph are scanned using a node type identification tool. For multi-language mixed programming scenarios, nodes involving external language interface calls are identified. Forty-five object-oriented language native interface call nodes and 20 external function interface nodes are extracted, and these nodes are combined to obtain a cross-language call node set containing 65 elements.
[0047] In one embodiment, the aforementioned cross-language call node set is obtained, and the source code fragments associated with the nodes are parsed using a text parsing tool. The function names, parameter type lists, and return value types in the nodes are extracted, and this information is concatenated into a standardized string format to obtain a set of 65 function signature strings.
[0048] It should be noted that the function signature string set is obtained and compared using a cross-language interface mapping rule table. An edit distance-based string similarity algorithm is used to calculate the similarity between the extracted function signatures and preset signatures in the rule table. If the calculated interface matching score reaches 85 points and is greater than the preset matching threshold of 80 points, a successful match is determined. Based on the successfully matched function signature string set, the host language function initiating the call and the target language function receiving the call are identified, resulting in 50 pairs of cross-language caller and callee pairs.
[0049] Specifically, cross-language caller-callee pairs are obtained and connected using a directed graph connection tool. Directed edges are established with the caller node as the starting point and the callee node as the ending point, generating a cross-language transition edge set containing 50 edges. This cross-language transition edge set is then inserted into an enhanced control flow graph, connecting the originally isolated single-language control flow graph segments to obtain a global control flow graph covering the multi-language call chain.
[0050] S107. Based on the global control flow graph, the basic block nodes and transition edges in the global control flow graph are enumerated using a path traversal algorithm to extract the complete node access sequence from the program entry point to the program exit point, thereby obtaining a complete set of execution paths including cross-language call boundary transitions.
[0051] The global control flow graph is obtained, and the program entry node and program exit node in the global control flow graph are extracted using a node parsing tool to obtain start and end point pairs. The start and end point pairs are obtained, and a path traversal algorithm is used to search for basic block nodes between the start and end point pairs to obtain an initial node access sequence. The initial node access sequence is obtained, and cross-language transition edges are extracted from the initial node access sequence using a transition edge identification tool to obtain a cross-language boundary point set. The cross-language boundary point set is obtained; if the number of boundary points in the cross-language boundary point set is greater than a preset threshold, the initial node access sequence is path-segmented based on the cross-language boundary point set to obtain local execution segments. The local execution segments are obtained, and a sequence splicing tool is used to splice the local execution segments according to the direction of the cross-language transition edges to determine a complete execution path set covering cross-language boundary transitions. The complete execution path set is obtained, and duplicate paths in the complete execution path set are removed using a redundancy removal tool to obtain a unique execution path set.
[0052] Specifically, the global control flow graph is obtained, and topological analysis of the graph structure is performed using a node parsing tool. Nodes with an in-degree of 0 are identified as program entry nodes, while nodes with an out-degree of 0 or containing specific return instructions are scanned as program exit nodes. One main program entry node and four exit nodes (for exception handling and normal returns) are extracted. These nodes are then paired to obtain four pairs of start and end points.
[0053] In one embodiment, the aforementioned start and end point pairs are obtained, and a depth-first search algorithm is used to traverse the basic block nodes between the paired nodes. Starting from the start point as the root node, the search proceeds layer by layer downwards along the control flow edges, recording the identifier of each basic block node encountered, until the corresponding end point is reached. After traversal processing, an initial node access sequence containing 200 nodes is obtained.
[0054] It should be noted that, after obtaining the initial node access sequence, the relationship between adjacent nodes in the sequence is checked using a transition edge identification tool. Cross-language transition edges that jump from the object-oriented language environment to the underlying system language environment are extracted from the sequence, and the nodes at both ends of these transition edges are located, resulting in a cross-language boundary point set containing 30 elements.
[0055] Specifically, a cross-language boundary point set is obtained, with a preset threshold of 10. Since the extracted 30 boundary points exceed this threshold, the initial node access sequence is segmented based on the cross-language boundary point set. Using the boundary points as breakpoints, the long sequence is truncated into shorter sequences in a single language environment, resulting in 85 local execution segments.
[0056] In one embodiment, local execution paths are obtained and reassembled using a sequence splicing tool according to the original directions of the cross-language transfer edges. The local execution paths of the preceding language environment and the following language environment are connected end-to-end through boundary points to determine a complete set of 150 execution paths covering cross-language boundary transfers.
[0057] It should be noted that the complete set of execution paths is obtained, and the paths are processed using a hash digest algorithm through a redundancy removal tool. A unique hash value is generated for each path, and the hash values are compared to identify identical path sequences. Thirty duplicate paths caused by loop unrolling are removed, ultimately resulting in a set of 120 unique execution paths.
[0058] S108. For the complete set of execution paths, a path verification algorithm based on time-series logic rules is used to perform a legality comparison of the execution order of nodes in the complete set of execution paths. Based on the preset resource access time-series constraint rules and function call order dependency rules, legal paths that conform to the execution semantics are selected, and the target execution path that meets the preset execution rules is determined.
[0059] The complete execution path set is obtained, and the execution order of nodes in the complete execution path set is extracted using a sequence parsing tool to obtain a node access sequence. The node access sequence is obtained, and resource access operations and function call operations in the node access sequence are identified using an event extraction tool to obtain an operation event flow. The operation event flow is obtained, and a path verification algorithm based on temporal logic rules is used to perform legality comparison processing on the operation event flow to obtain a temporal state sequence. The temporal state sequence is obtained, and it is matched according to preset resource access temporal constraint rules and function call order dependency rules to obtain a rule matching result. The rule matching result is obtained; if the rule matching result indicates a temporal conflict, the corresponding conflicting path is removed from the complete execution path set to obtain a candidate legal path. The candidate legal path is obtained, and the execution semantics of the candidate legal path is extracted using a semantic analysis tool to obtain a semantic feature vector. The semantic feature vector is obtained, and a support vector machine algorithm is used to classify the semantic feature vector to determine the target execution path that satisfies the preset execution rules.
[0060] Specifically, the process involves obtaining a set of 120 complete execution paths from the aforementioned processing. A sequence parsing tool is used to analyze each basic block node within the path, extracting the node execution order according to the control flow sequence, resulting in a node access sequence containing 500 nodes. This node access sequence is then used to perform pattern matching on the instructions within each node using an event extraction tool, identifying resource access operations involving memory allocation and file read / write, as well as cross-module function call operations. These operations are then arranged chronologically to obtain an operation event stream containing 80 operation nodes.
[0061] In one embodiment, the aforementioned operation event flow is acquired, and its legality is compared using a path verification algorithm based on linear temporal logic rules. The operation event flow is transformed into a state machine model, and each state is deduced to obtain a temporal state sequence containing 80 state nodes. This temporal state sequence is acquired and matched according to preset resource access timing constraints and function call order dependency rules. The rules are set as follows: a memory allocation function must be executed before a memory write operation can be performed, and a lock resource must be acquired before a shared data modification function can be called. The rule matching results are obtained. If the results indicate a timing conflict of writing before allocation or modifying without locking, these 15 corresponding conflicting paths are removed from the complete execution path set, resulting in 105 candidate legal paths.
[0062] It should be noted that, after obtaining the aforementioned 105 candidate legal paths, semantic analysis tools were used to extract execution semantics such as control dependencies and data flow relationships contained in the paths. These semantic information were mapped into a fixed-dimensional numerical matrix, resulting in a semantic feature vector containing 64 dimensions. This semantic feature vector was then used for classification processing using a support vector machine (SVM) algorithm. The semantic feature vector was input into a pre-trained SVM classification model, and the distance between the feature vector and the classification boundary was calculated using a hyperplane to determine whether the execution logic of the path conforms to safety specifications. Finally, 90 target execution paths that meet the preset execution rules were selected.
[0063] Based on the embodiments of the present invention described above, and through the above description, those skilled in the art can make various changes and modifications without departing from the technical concept of the present invention. The technical scope of the present invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A recognition and analysis method based on software modeling, characterized in that, The method includes: A source code library of a multi-language hybrid program is obtained. A lexical analyzer is used to identify lexical units in the source code library, extracting reserved keywords and custom identifiers for each programming language to obtain a hybrid lexical tag sequence containing grammatical elements of different languages. Based on the hybrid lexical tag sequence, a multi-language syntax parser is used to distinguish language types and extract grammatical structures. Statement structures and expression forms are identified based on the grammatical rules of each programming language, resulting in a heterogeneous syntax tree set corresponding to the grammatical rules of each programming language. For the heterogeneous syntax tree set, a cross-language node semantic mapper is used to perform semantic consistency analysis and standardization transformation on the language-specific grammatical nodes in the heterogeneous syntax tree set. A unified intermediate representation node mapping process is performed on the grammatical nodes of different languages to generate a unified abstract syntax tree. The unified abstract syntax tree (API) is obtained. A control flow graph generation algorithm based on statement dependencies is used to parse the control transfer relationships of conditional branch statements and loop structures in the API, determining an initial control flow graph containing branch jump logic and loop loop structures. For the initial control flow graph, chain analysis is used to trace variable assignment and reference operations, extracting cross-block variable transit dependencies to obtain an enhanced control flow graph labeled with variable lifetime information and data dependency edges. It is determined whether a cross-language call node exists in the enhanced control flow graph. If such a node exists, control flow edges are connected between the caller and callee according to a pre-built cross-language interface mapping rule table, establishing cross-language boundary control flow transfer relationships to obtain a global control flow graph covering multi-language call links. Based on the global control flow graph, a path enumeration algorithm is used to enumerate the basic block nodes and transfer edges, extracting complete node access sequences from program entry point to program exit point, obtaining a complete set of execution paths containing cross-language call boundary transfers. For the complete set of execution paths, a path verification algorithm based on temporal logic rules is used to perform a legality comparison of the execution order of nodes in the complete set of execution paths. Based on the preset resource access temporal constraint rules and function call order dependency rules, legal paths that conform to the execution semantics are selected, and the target execution path that meets the preset execution rules is determined.
2. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process of obtaining the source code library of the multi-language hybrid program involves using a lexical analyzer to perform lexical unit recognition processing on the source code library, extracting reserved keywords and custom identifiers of each programming language, and obtaining a hybrid lexical tag sequence containing syntactic elements of different languages, including: Obtain a multilingual source code library, and use a character scanning tool to read the character stream of the multilingual source code library to obtain the original code string; Based on the original code string, the Conditional Random Field algorithm is used to segment the original code string into language segments to obtain multiple monolingual code segments. The multiple single-language code fragments are obtained, and the multiple single-language code fragments are matched with a preset language vocabulary to determine the target programming language type corresponding to each single-language code fragment; For the target programming language type, a corresponding finite state machine is used to perform lexical unit recognition on the single-language code fragment, and extract and retain keywords and custom identifiers; If the custom identifier contains a preset delimiter, the custom identifier is split using a string splitting function to obtain basic vocabulary units; Based on the reserved keywords and the basic vocabulary units, the reserved keywords and the basic vocabulary units are combined through sequence concatenation operations to obtain a mixed lexical tag string containing different language grammatical elements; The hybrid lexical tag string is obtained, and the hybrid lexical tag string is hierarchically parsed using an abstract syntax tree generation tool to obtain a multilingual abstract syntax tree.
3. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process involves using a multilingual syntax parser to distinguish language types and extract grammatical structures from the mixed lexical tag sequence, identifying statement structures and expression forms based on the grammatical rules of each programming language, and obtaining a heterogeneous set of syntax trees corresponding to the grammatical rules of each programming language, including: The hybrid lexical tag sequence is obtained, and a multilingual syntax parser is used to distinguish the language classes of the hybrid lexical tag sequence to obtain multiple single-language tag subsequences. The multiple monolingual marker subsequences are obtained, and the grammatical structure of the monolingual marker subsequences is extracted using a recursive descent algorithm to obtain an initial statement block. For the initial statement block, the expression form of the initial statement block is identified based on the preset specification library of each programming language to obtain a single-language expression tree; If the monolingual expression tree contains undefined syntax nodes, the type of the undefined syntax nodes is supplemented by the node type inference rule to obtain a complete node set; Based on the complete node set, a graph neural network algorithm is used to perform context association analysis on the complete node set to determine the syntax dependency graph; The syntax dependency graph is obtained, and the program control flow is obtained by traversing the execution path of the syntax dependency graph using a control flow extraction tool. Based on the program control flow and the single-language expression tree, the program control flow and the single-language expression tree are combined through a tree structure merging operation to obtain a heterogeneous set of syntax trees corresponding to the syntax specifications of each programming language.
4. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process involves performing semantic consistency analysis and standardization transformation on language-specific grammar nodes in the heterogeneous syntax tree set using a cross-language node semantic mapper, and mapping grammar nodes from different languages to a unified intermediate representation node to generate a unified abstract syntax tree, including: Obtain the heterogeneous syntax tree set, and perform node traversal on the heterogeneous syntax tree set through a cross-language node semantic mapper to obtain a specific language node set; Obtain the specific language node set, and use a word embedding model to extract semantic features from the specific language node set to obtain node semantic vectors; For the node semantic vector, a cosine similarity calculation tool is used to compare the semantic consistency of the node semantic vector to determine the semantic matching degree; If the semantic matching degree is greater than the preset matching threshold, the specific language node set is standardized according to the preset syntax conversion rules to obtain the standard state node set; Obtain the standard state node set, and use a support vector machine to perform a unified intermediate representation node mapping on the standard state node set to obtain an intermediate state node set; Based on the intermediate node set, a tree structure reorganization tool is used to hierarchically concatenate the intermediate node set to generate a unified abstract syntax tree.
5. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process of obtaining the unified form abstract syntax tree involves using a control flow graph generation algorithm based on statement dependencies to parse the control transfer relationships of conditional branch statements and loop structure statements in the unified form abstract syntax tree, thereby determining an initial control flow graph containing branch jump logic and loop loop structures, including: Obtain the unified form abstract syntax tree, and extract the condition blocks and execution blocks in the unified form abstract syntax tree using a node type identification tool to obtain the set of key control flow nodes; The set of key control flow nodes is obtained, and a control flow graph generation algorithm based on statement dependencies is used to parse the control flow key node set to obtain a node transition relationship matrix. For the node transition relationship matrix, the non-zero elements in the node transition relationship matrix are connected by the directed edge construction rules to determine the initial directed graph containing jump edges; Obtain the initial directed graph, and use a depth-first search tool to traverse the closed-loop paths in the initial directed graph to obtain the loop body structure set; If the number of loop nodes in the loop body structure set is greater than a preset node threshold, then the loop body structure set is embedded into the initial directed graph according to the graph structure splicing rules to obtain the initial control flow graph. The initial control flow graph is obtained, and unreachable branch points in the initial control flow graph are identified using a dead code detection tool to determine a simplified control flow graph.
6. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process involves using chain analysis to trace and process variable assignment and reference operations in the initial control flow graph through variable definitions, extracting cross-basic block variable transitive dependencies, and obtaining an enhanced control flow graph labeled with variable lifecycle information and data dependency edges. This includes: Obtain the initial control flow graph, and extract the variable assignment points and variable reference points in the initial control flow graph using a node traversal tool to obtain the variable operation node set; Obtain the set of variable operation nodes, and use the variable definition usage chain analysis method to match and trace the starting and ending points in the set of variable operation nodes to determine the initial definition usage chain; Obtain the initial definition usage chain, identify the transit paths that cross different basic blocks in the initial definition usage chain through path resolution rules, and obtain the cross-block transit path set; Obtain the cross-block transit path set, and use the active variable analysis algorithm to calculate the activity of each variable in the cross-block transit path set to obtain a variable lifecycle table; Obtain the variable lifecycle table, and perform chain-based connection annotation on the initial definition according to the variable lifecycle table to determine the data dependency edge set; The data dependency edge set is obtained, and the data dependency edge set and the variable lifecycle table are embedded into the initial control flow graph using graph structure merging rules to obtain an enhanced control flow graph. The enhanced control flow graph is obtained. If the number of data dependency edges in the enhanced control flow graph is greater than a preset edge number threshold, a graph segmentation tool is used to perform modular splitting of the enhanced control flow graph to obtain the target control flow graph.
7. The identification and analysis method based on software modeling according to claim 1, characterized in that, The determination of whether a cross-language call node exists in the enhanced control flow graph, and if such a cross-language call node exists, then according to the pre-built cross-language interface mapping rule table, the caller and callee control flow edge connection processing is performed on the cross-language call node to establish a cross-language boundary control flow transfer relationship, resulting in a global control flow graph covering multi-language call links, including: The enhanced control flow graph is obtained, and cross-language call nodes in the enhanced control flow graph are extracted using a node type identification tool to obtain a cross-language call node set; Obtain the cross-language call node set, and use a text parsing tool to extract the function signature information from the cross-language call node set to obtain a function signature string set; Obtain the set of function signature strings, compare the set of function signature strings with the cross-language interface mapping rule table, and obtain the interface matching score; Obtain the interface matching score. If the interface matching score is greater than the preset matching threshold, determine the corresponding caller and callee based on the function signature string set to obtain a cross-language caller and callee pair. Obtain the cross-language caller and callee pair, and use a directed graph connection tool to connect the cross-language caller and callee pair to generate a cross-language transition edge set; Obtain the cross-language transfer edge set, insert the cross-language transfer edge set into the enhanced control flow graph, and obtain a global control flow graph covering multi-language call links.
8. The identification and analysis method based on software modeling according to claim 1, characterized in that, The process involves enumerating the basic block nodes and transition edges in the global control flow graph using a path traversal algorithm, extracting the complete node access sequence from the program entry point to the program exit point, and obtaining a complete set of execution paths including cross-language call boundary transitions. Obtain the global control flow graph, and extract the program entry node and program exit node from the global control flow graph using a node parsing tool to obtain the start point and end point pairs; Obtain the starting point and ending point pair, and use a path traversal algorithm to search the basic block nodes between the starting point and ending point pair to obtain the initial node access sequence. Obtain the initial node access sequence, and extract the cross-language transition edges in the initial node access sequence using a transition edge identification tool to obtain the cross-language boundary point set; Obtain the cross-language boundary point set. If the number of boundary points in the cross-language boundary point set is greater than a preset threshold, then perform path segmentation on the initial node access sequence based on the cross-language boundary point set to obtain local execution segments. The local execution segments are obtained, and a sequence splicing tool is used to splice the local execution segments according to the direction of the cross-language transfer edges to determine a complete set of execution paths covering cross-language boundary transfers; Obtain the complete set of execution paths, and use a redundancy removal tool to remove duplicate paths from the complete set of execution paths to obtain a unique set of execution paths.
9. The identification and analysis method based on software modeling according to claim 1, characterized in that, For the complete set of execution paths, a path verification algorithm based on temporal logic rules is used to perform a legality comparison of the execution order of nodes in the complete set of execution paths. Based on preset resource access timing constraints and function call order dependency rules, legal paths conforming to execution semantics are selected to determine the target execution path that satisfies the preset execution rules, including: Obtain the complete execution path set, and use a sequence parsing tool to extract the node execution order in the complete execution path set to obtain the node access sequence; The node access sequence is obtained, and the resource access operations and function call operations in the node access sequence are identified by an event extraction tool to obtain the operation event stream. The operation event stream is obtained, and a path verification algorithm based on time-series logic rules is used to perform a legality comparison on the operation event stream to obtain a time-series state sequence. The time-series state sequence is obtained, and the time-series state sequence is matched according to the preset resource access timing constraint rules and function call order dependency rules to obtain the rule matching result; Obtain the rule matching result. If the rule matching result indicates that there is a timing conflict, remove the corresponding conflicting path from the complete execution path set to obtain the candidate legal path. The candidate legal paths are obtained, and the execution semantics of the candidate legal paths are extracted using semantic analysis tools to obtain semantic feature vectors; The semantic feature vector is obtained, and the semantic feature vector is classified using the support vector machine algorithm to determine the target execution path that meets the preset execution rules.
