[go: up one dir, main page]

CN113076244A - Method and device for detecting function call relationship - Google Patents

Method and device for detecting function call relationship Download PDF

Info

Publication number
CN113076244A
CN113076244A CN202110338210.1A CN202110338210A CN113076244A CN 113076244 A CN113076244 A CN 113076244A CN 202110338210 A CN202110338210 A CN 202110338210A CN 113076244 A CN113076244 A CN 113076244A
Authority
CN
China
Prior art keywords
node
function
detected
fractal
tree
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110338210.1A
Other languages
Chinese (zh)
Other versions
CN113076244B (en
Inventor
白明乾
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202110338210.1A priority Critical patent/CN113076244B/en
Publication of CN113076244A publication Critical patent/CN113076244A/en
Priority to PCT/CN2021/141990 priority patent/WO2022206062A1/en
Application granted granted Critical
Publication of CN113076244B publication Critical patent/CN113076244B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明实施例提供一种函数调用关系检测方法及装置,确定待检测代码中各待检测函数的节点信息,节点信息中包括用于表征待检测函数是否为分形节点的节点标签;根据各第一待检测函数的节点信息构建第一分形树,并根据各第二待检测函数的节点信息构建第二分形树;其中,第一待检测函数为节点标签指示为非分形节点的待检测函数;第二待检测函数为节点标签指示为分形节点的待检测函数;根据第一分形树和第二分形树,构建3D分形树;通过3D分形树确定各待检测函数是否符合函数调用关系。上述方法相比于现有技术中3D分形树中无法完整获取分形节点中的函数调用关系来说,本申请中获取的3D分形树中的函数调用关系完整,提高了检测代码的准确度。

Figure 202110338210

Embodiments of the present invention provide a method and device for detecting a function call relationship, which determine the node information of each function to be detected in the code to be detected, where the node information includes a node label used to represent whether the function to be detected is a fractal node; The node information of the function to be detected constructs a first fractal tree, and the second fractal tree is constructed according to the node information of each second function to be detected; wherein, the first function to be detected is a function to be detected whose node label indicates that it is a non-fractal node; The second function to be detected is a function to be detected whose node label indicates a fractal node; a 3D fractal tree is constructed according to the first fractal tree and the second fractal tree; and whether each function to be detected conforms to the function calling relationship is determined through the 3D fractal tree. Compared with the 3D fractal tree in the prior art, the above method cannot completely obtain the function call relationship in the fractal node, the function call relationship in the 3D fractal tree obtained in the present application is complete, and the accuracy of the detection code is improved.

Figure 202110338210

Description

Function call relation detection method and device
Technical Field
The present application relates to the field of financial technology (Fintech) network technologies, and in particular, to a method and an apparatus for detecting a function call relationship.
Background
In recent years, with the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), but higher requirements are also put on the technologies due to the requirements of the financial industry on safety and real-time performance. For example, in the current society, people can complete most of life needs of people through application software in terminals, and with the increase of the needs of people for safety, convenience and the like, the design of the application software is increasingly complex; the software in the terminal and the related system supporting the software operation are all realized by codes with corresponding functions written by developers. For example, shopping software, office software, video software, chat software, financial management software and the like can be downloaded in the terminal, and the application software brings great convenience to the life of people. Correspondingly, as the demand of people increases, the code writing of software becomes more complex, a large amount of time and cost are consumed for corresponding manual code detection, and even more complex codes cannot be detected manually.
Currently, there are three code detection methods: one method is a call hierarchy (function call hierarchical tree), and the function call hierarchical tree generated by the method can contain all functions in the code to be detected; however, the method cannot identify the if statement block, the switch statement block and the overlay rewriting function in the code to be detected, and directly represents the branch of the 'or' execution relation of the three methods as serial execution, so that the accuracy of the generated function call hierarchical tree is reduced, and the code detection accuracy is further reduced. Although the method can identify an if statement block, a switch statement block and a coverage rewriting function in a code to be detected, the execution branch of the 'or' relation of the three methods can be calculated only according to a fixed algorithm to obtain a calculation result, the calculation result is used as a called function, the original function calling sequence of the three methods in the code to be detected is lost, and the code detection accuracy is reduced. In the method, when the code to be detected comprises an execution branch with an 'or' relationship, the execution sequence of only one branch is acquired, so that the function calling sequence is incomplete, and the code detection accuracy is reduced.
Therefore, a method and an apparatus for detecting a function call relationship are needed to obtain a complete function call relationship of a code to be detected, so as to increase the accuracy of detecting the code.
Disclosure of Invention
The embodiment of the invention provides a method and a device for detecting a function call relation, which can acquire the complete function call relation of a code to be detected and increase the accuracy of detecting the code.
In a first aspect, an embodiment of the present invention provides a method for detecting a function call relationship, where the method includes:
determining node information of each function to be detected in the code to be detected, wherein the node information comprises a node label for representing whether the function to be detected is a fractal node; constructing a first fractal tree according to the node information of each first function to be detected, and constructing a second fractal tree according to the node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node; constructing a 3D fractal tree according to the first fractal tree and the second fractal tree; and determining whether each function to be detected accords with a function call relation or not through the 3D fractal tree.
In the method, the node information of each function to be detected in the code to be detected is obtained to determine the information of the function to be detected in the 3D fractal tree and whether the function to be detected contains a fractal label which is a fractal node or not; furthermore, the function to be detected is analyzed in a fractal node manner or in a non-fractal node manner. Therefore, node information of the fractal node and the fractal node can be obtained, so that the 3D fractal tree comprises a first fractal tree, namely, a calling relation between first functions to be detected of the fractal node and a calling relation between the fractal node and the fractal node; and a second fractal tree, namely, the calling relation of each second function to be detected in the fractal node. Compared with the prior art that the function call relation in the fractal node cannot be completely acquired in the 3D fractal tree, the function call relation in the 3D fractal tree acquired in the application is complete, and the accuracy of code detection is improved.
Optionally, the node information further includes child nodes; the child node is a function called by a function to be detected; the constructing of the first fractal tree according to the node information of each first function to be detected includes: aiming at any first function to be detected, taking the first function to be detected as a root node of a first fractal tree, taking the root node as a first construction node, and judging whether a child node of the first construction node is a non-fractal node; if the child node is a non-fractal node, constructing the child node as a next-layer node of the first construction node, taking the next-layer node as the first construction node, and returning to the step of judging whether the child node of the first construction node is the non-fractal node; if the child node of the first construction node is a fractal node, constructing the child node as a virtual node of the first construction node without the child node; until none of the nodes in the first fractal tree have child nodes.
In the method, a first function to be detected is taken as a root node of a first fractal tree, child nodes of non-fractal nodes of the first function to be detected are taken as first-layer nodes under the root node of the first fractal tree, and the fractal nodes are taken as virtual nodes without child nodes; constructing a second layer of nodes of the first fractal tree according to the child node set of the child nodes in the node information of the child nodes; the first fractal tree is constructed in this circular manner until none of the nodes in the first fractal tree have child nodes. Therefore, the function calling relationship hierarchy of the first function to be detected in the first fractal tree is clear, the calling relationship of the function to be detected corresponding to each node in the first fractal tree is accurately determined, and the accuracy of function calling relationship detection is improved. And if the child node is a fractal node, constructing the child node as a virtual node without the child node in the first fractal tree. Therefore, all functions contained in the fractal node or other equivalent virtual function information can be set in the virtual node, so that when a second fractal tree corresponding to each second function to be detected in the fractal node is determined in the following, the second fractal tree is supplemented at the corresponding fractal node position of the first fractal tree, and the accuracy and the integrity of the 3D fractal tree are improved.
Optionally, the constructing a second trellis tree according to node information of each second function to be detected includes: aiming at any second function to be detected, generating a virtual node of the second function to be detected as a root node of a second fractal tree; generating a virtual node corresponding to any function branch of the second function to be detected as a first-layer node under a root node of the second fractal tree;
generating the lower-layer node of the virtual node of any function branch by the following method:
taking the virtual node as a second construction node, and judging whether a child node of the second construction node is a non-fractal node; if the child node of the second construction node is a non-fractal node, constructing the child node as a next-layer node of the second construction node, taking the next-layer node as the second construction node, and returning to the step of judging whether the child node of the second construction node is the non-fractal node; if the child node of the second construction node is a fractal node, constructing the child node as a virtual node of the second construction node without the child node; until no node in the second fractal tree has a child node.
In the method, the virtual node of the second function to be detected is used as the root node of the second tree, and the virtual node corresponding to any function branch of the second function to be detected is used as the first-layer node under the root node of the second tree. Thus, the virtual node of the second function to be detected, i.e. the root node, can be used to represent the source of at least one function branch, and the virtual node corresponding to the function branch can be used to represent the number of the function branches; and then the function called in the function branch is the child node of the virtual node corresponding to the function branch. Therefore, the function called by each branch in the fractal node can be accurately and clearly characterized, the function calling relation in the second fractal tree corresponding to the fractal node is accurate, the accuracy and the integrity of the 3D fractal tree are improved, and the accuracy of function calling relation detection is further improved. And if any function branch of the second function to be detected also comprises a fractal node, constructing a second fractal tree corresponding to the fractal node according to a construction method of the second fractal tree, and supplementing the second fractal tree to the second fractal tree in which the fractal node is located, so that the function calling relationship in the second fractal tree is accurate and complete, and the accuracy and the integrity of the 3D fractal tree are further improved.
Optionally, constructing a 3D fractal tree according to the first fractal tree and the second fractal tree includes: determining a second fractal tree corresponding to the virtual node in the first fractal tree; and fusing the first fractal tree and the second fractal tree into a 3D fractal tree through virtual nodes in the first fractal tree.
In the method, the second fractal tree corresponding to the fractal node is supplemented to the first fractal tree through the virtual node corresponding to the fractal node in the first fractal tree to obtain the fused 3D fractal tree. The 3D fractal tree comprises the function call relations of all the functions to be detected in the codes to be detected, and when the function call relations in the 3D fractal tree are detected by using a function call relation principle, whether the function call relations to be detected in the codes to be detected are wrong or not can be accurately determined.
Optionally, the merging the first fractal tree and the second fractal tree into a 3D fractal tree includes:
supplementing a second fractal tree corresponding to the virtual node into the virtual node of the first fractal tree to obtain a 3D fractal tree fused with the first fractal tree and the second fractal tree; or for each branch of a second fractal tree corresponding to the virtual node, respectively supplementing the branch into the virtual node of the first fractal tree, so as to obtain at least one 3D fractal tree with different branches, wherein the branches of the first fractal tree and the second fractal tree are fused.
In the method, the second fractal tree corresponding to the virtual node is supplemented to the virtual node corresponding to the first fractal tree, so that the 3D fractal tree fused with the first fractal tree and the second fractal tree is obtained. Therefore, the accurate and complete function call relation in the acquired 3D fractal tree is guaranteed. And if each branch of the second fractal tree corresponding to the virtual node is respectively supplemented to the virtual node corresponding to the first fractal tree, obtaining a 3D fractal tree with different branches, wherein the branches of the first fractal tree and the second fractal tree are fused. Therefore, each obtained 3D fractal tree is a function call path for the code to be detected to run once, and the accurate and complete function call relation contained in the obtained 3D fractal tree can be ensured.
Optionally, determining node information of each function to be detected in the code to be detected includes: traversing each element in the code to be detected; for any element, if the element is a function, determining the element as a function to be detected; determining whether the function to be detected is a set function, and if the function to be detected is the set function, determining that the node label of the function to be detected indicates that the function to be detected is a fractal node; and traversing each element in the function body code of the function to be detected, thereby determining the child node of the function to be detected.
In the method, whether any element is a function or not is judged to ensure that the generated 3D fractal tree represents a function call relation; the 3D fractal tree is prevented from containing non-function elements, so that the function calling relation is not accurate. Determining whether the function to be detected is a set function, if the function to be detected is the set function, if so, covering the rewrite function, and acquiring a node label of the function to be detected as a fractal node; here, the setting function may also be a setting statement block, such as an if statement block and/or a switch statement block.
Optionally, before determining the node information of each function to be detected in the code to be detected, the method further includes: and determining that the cache does not contain the node information of the function to be detected.
In the method, if the analyzed function to be detected, which is the same as the function to be detected, exists in the cache and the node information of the analyzed function to be detected exists in the cache, the node information in the cache is directly used as the node information of the function to be detected, and the pointer direction of the function to be detected is set. Therefore, the same multiple functions to be detected only need to be analyzed once, the speed of obtaining the 3D fractal tree is increased, and the detection speed is further increased.
Optionally, if the element is a function, determining that the element is a function to be detected includes: and if the element is determined to be a function and is a set service function, determining the element to be a function to be detected.
In the method, the function is a service function, and the service function can be used for realizing the service function of the code to be detected. The method and the device have the advantages that the function call relation detection of the service function aiming at the service function of the code to be detected is obtained, the log function and other auxiliary functions are not needed to be analyzed, the speed of obtaining the 3D fractal tree is increased, and the detection speed is further increased.
Optionally, determining whether each function to be detected conforms to a function call relationship through the 3D fractal tree includes: traversing the 3D fractal tree after adding one node in the 3D fractal tree construction process to determine whether each function to be detected in the 3D fractal tree conforms to a function call relation; and if not, stopping the construction of the 3D fractal tree.
According to the method, the function call relation of the code to be detected can be detected in the construction process of the 3D fractal tree, and the detection speed is increased.
Optionally, determining whether each function to be detected conforms to a function call relationship through the 3D fractal tree includes: traversing nodes corresponding to each first function to be detected in the 3D fractal tree from a root node in the 3D fractal tree to obtain a first function call path; for any second function to be detected, traversing nodes corresponding to each second function to be detected in the 3D fractal tree from virtual nodes corresponding to function branches in the second function to be detected to obtain a second function call path; and determining whether each function to be detected accords with a function calling relation or not according to the first function calling path and the second function calling path.
In the method, the 3D fractal tree includes nodes corresponding to the first functions to be detected and nodes corresponding to the second functions to be detected, and the first function call path and the second function call path can be obtained. Namely, each node line in the 3D fractal tree completely contains the call relations of all functions to be detected, and further, the function call relations can be determined according to the node lines.
In a second aspect, an embodiment of the present invention provides a device for detecting a function-call relationship, where the device includes:
the analysis module is used for determining node information of each function to be detected in the code to be detected, wherein the node information comprises a node label used for representing whether the function to be detected is a fractal node;
the processing module is used for constructing a first fractal tree according to the node information of each first function to be detected and constructing a second fractal tree according to the node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node;
the processing module is further used for constructing a 3D fractal tree according to the first fractal tree and the second fractal tree;
and the judging module is used for determining whether each function to be detected accords with the function call relation or not through the 3D fractal tree.
In a third aspect, an embodiment of the present application further provides a computing device, including: a memory for storing a program; a processor for calling the program stored in said memory and executing the method as described in the various possible designs of the first aspect according to the obtained program.
These and other implementations of the present application will be more readily understood from the following description of the embodiments.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1(a) is a schematic diagram of an architecture for detecting a function call relationship according to an embodiment of the present invention;
fig. 1(b) is a schematic diagram of an architecture for detecting a function call relationship according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a method for detecting a function call relation according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a first fractal tree according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a second tree of trees according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a 3D fractal tree according to an embodiment of the present invention;
fig. 6(a) is a schematic diagram of a 3D fractal tree according to an embodiment of the present invention;
fig. 6(b) is a schematic diagram of a 3D fractal tree according to an embodiment of the present invention;
fig. 7(a) is a schematic diagram of a 3D fractal tree according to an embodiment of the present invention;
fig. 7(b) is a schematic diagram of a 3D fractal tree according to an embodiment of the present invention;
fig. 8(a) is a schematic diagram of generating a 3D fractal tree according to an embodiment of the present invention;
fig. 8(b) is a schematic diagram of generating a 3D fractal tree according to an embodiment of the present invention;
fig. 9 is a schematic flowchart of a method for detecting a function call relation according to an embodiment of the present invention;
fig. 10 is a schematic diagram of a function call relation detection apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1(a) and fig. 1(b) are respectively system architectures for detecting a function call relation according to an embodiment of the present invention; as shown in fig. 1(a), when the detection module does not include the function call relation principle: and inputting the code to be detected into the detection module, and inputting the corresponding function call relation principle into the detection module. The detection module can analyze and acquire node information of each code to be detected in the codes to be detected, and construct a first fractal tree according to the node information of the first function to be detected, which corresponds to each non-differentiated node obtained through analysis. And constructing a second fractal tree according to the node information of the second function to be detected, which corresponds to each fractal node and is obtained through analysis. And constructing and obtaining a complete 3D fractal tree according to the first fractal tree and the second fractal tree. Each node contained in the 3D fractal tree can represent a complete function call relation between service functions in the code to be detected. Further, comparing the function call relation of the code to be detected in the 3D fractal tree with the input function call relation principle, determining whether the function call relation of the code to be detected is wrong, and outputting a detection result to indicate function information that the function call relation in the code to be detected is wrong, or outputting the detection result to indicate that the function call relation in the code to be detected is correct.
As shown in fig. 1(b), when the detection module includes at least one function call relationship rule: and inputting the code to be detected into the detection module, and inputting a selected principle instruction for indicating that the detection is carried out by using a certain function call relation principle into the detection module. Enabling the detection module to determine a function call relation principle for detection according to the selected principle instruction; the further detection module can obtain a function call relation between service functions in the code to be detected according to the constructed complete 3D fractal tree. And further, comparing the function call relation of the code to be detected with the selected function call relation principle, determining whether the function call relation of the code to be detected is wrong, and outputting a detection result. In the above explanation, when the 3D fractal tree is constructed, the function call relation of the code to be detected may be detected according to the currently obtained partial function call relation, that is, the function call relation is obtained while the 3D fractal tree is generated, and the function call relation is detected to accelerate the detection speed. In addition, a plurality of function call relation principles can respectively correspond to the function call relation detection of the codes to be detected of different business functions; for example, the function call relationship of the code to be detected having the deposit function is detected by the function call relationship principle 1, and the function call relationship of the code to be detected having the withdrawal function is detected by the function call relationship principle 2. The multiple function call relationship principles may also respectively correspond to function call relationship detection of the to-be-detected code of different function modules in the same business function, for example, the function call relationship of the to-be-detected code of the money updating module in the deposit function is detected by the function call relationship principle 3. The function call relation principle can be set according to needs, and specific setting is not limited.
Based on this, an embodiment of the present application provides a flow of a method for detecting a function-call relationship, as shown in fig. 2, including:
step 201, determining node information of each function to be detected in the code to be detected, wherein the node information comprises a node label for representing whether the function to be detected is a fractal node;
here, the fractal node includes: an if statement block, a switch statement block, and an override rewrite function.
Step 202, constructing a first fractal tree according to node information of each first function to be detected, and constructing a second fractal tree according to node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node;
step 203, constructing a 3D fractal tree according to the first fractal tree and the second fractal tree;
and 204, determining whether each function to be detected accords with a function call relation or not through the 3D fractal tree.
Here, whether the function call relationship is satisfied or not may be a function call sequence, a function call interval, or the like; for example, when a state is circulated in a code, a table to be updated is generally required to be locked by a table locking function, and then data of a corresponding row or column of the table is updated by an update function, which is a function call relation principle of the table locking function and the update function of the code. If the code needs to detect the function call relation, the code can be used as the code to be detected, a 3D fractal tree is generated according to the method to represent the function call relation of the code to be detected, when the function call relation is that an updating function is executed before, a table locking function is executed or not executed after, namely, after corresponding data of a table is updated, a table is locked or no table is locked, the detection result can obtain an error code of the code to be detected, the error code is marked and displayed on an interface, and therefore developers can quickly and intuitively obtain the error code and modify the error code.
In the method, the node information of each function to be detected in the code to be detected is obtained to determine the information of the function to be detected in the 3D fractal tree and whether the function to be detected contains a fractal label which is a fractal node or not; furthermore, the function to be detected is analyzed in a fractal node manner or in a non-fractal node manner. Therefore, node information of the fractal node and the fractal node can be obtained, so that the 3D fractal tree comprises a first fractal tree, namely, a calling relation between first functions to be detected of the fractal node and a calling relation between the fractal node and the fractal node; and a second fractal tree, namely, the calling relation of each second function to be detected in the fractal node. Compared with the prior art that the function call relation in the fractal node cannot be completely acquired in the 3D fractal tree, the function call relation in the 3D fractal tree acquired in the application is complete, and the accuracy of code detection is improved.
The embodiment of the application provides a method for constructing a first fractal tree, wherein the node information further comprises child nodes; the child node is a function called by a function to be detected; the constructing of the first fractal tree according to the node information of each first function to be detected includes: aiming at any first function to be detected, taking the first function to be detected as a root node of a first fractal tree, taking the root node as a first construction node, and judging whether a child node of the first construction node is a non-fractal node; if the child node is a non-fractal node, constructing the child node as a next-layer node of the first construction node, taking the next-layer node as the first construction node, and returning to the step of judging whether the child node of the first construction node is the non-fractal node; if the child node of the first construction node is a fractal node, constructing the child node as a virtual node of the first construction node without the child node; until none of the nodes in the first fractal tree have child nodes.
For example, the following steps are carried out: as shown in fig. 3, a schematic diagram of a first fractal tree provided in this embodiment is provided, where the schematic diagram of the first fractal tree is only used to help understanding the content of the present solution, and the present solution is not limited thereto, and the first fractal tree may be displayed in an interface tree diagram form or may not be displayed. The code to be detected comprises a function to be detected: function 1, function 2, function 3, function 4, function 5, function 6, function 7; the first function to be detected of the fractal node is as follows: function 1, function 2, function 3, function 4. One of the two branches of the second function to be detected of the fractal node contains function 5, and the other branch contains functions 6 and 7. Acquiring the code to be detected; analyzing a function 1 in a currently acquired code to be detected to acquire node information of the function 1, wherein the node information can comprise a function name, a called next-level function (a child node of the function 1) set and a fractal label; the called function set comprises: function 2 and fractal nodes; the fractal label is an fractal node. The node information of function 1 is stored in a cache. And taking the function 1 as a root node of the first fractal tree, taking the root node function 1 as a first construction node, and taking the child node function 2 and the fractal node of the function 1 as a next-layer node of the root node of the first fractal tree. The fractal node is used as a virtual node, the node can contain all contents in the fractal node, and also can only contain the identification of the fractal node, and the like, and the contents in the node can be set according to the requirements, so that the fractal node does not have child nodes in the first fractal tree and has an identifiable identification, and the specific contents are not limited. Analyzing a function 2 in a currently acquired code to be detected, and acquiring node information of the function 2, wherein a called function set in the node information comprises: function 3 and function 4; the fractal label is an fractal node. The node information of function 2 is stored in the cache. And taking the function 2 as root nodes of the functions 3 and 4, taking the root node function 2 as a first construction node, and taking the child node functions 3 and 4 of the function 2 as next-layer nodes of the root nodes of the first fractal tree. And if the function 3 and/or the function 4 have called functions, continuing to generate a next layer of nodes according to the method until any node at the bottommost layer in the first fractal tree does not have a child node. Therefore, the first fractal tree with definite hierarchy is generated according to the node hierarchy of each first function to be detected in the first fractal tree and the fractal node of the next hierarchy corresponding to the first function to be detected, the call relation of the function to be detected corresponding to each node in the first fractal tree can be accurately determined, and the accuracy of function call relation detection is improved.
The embodiment of the present application provides a method for constructing a second fractal tree, where constructing the second fractal tree according to node information of each second function to be detected includes: aiming at any second function to be detected, generating a virtual node of the second function to be detected as a root node of a second fractal tree; generating a virtual node corresponding to any function branch of the second function to be detected as a first-layer node under a root node of the second fractal tree;
generating the lower-layer node of the virtual node of any function branch by the following method:
taking the virtual node as a second construction node, and judging whether a child node of the second construction node is a non-fractal node; if the child node of the second construction node is a non-fractal node, constructing the child node as a next-layer node of the second construction node, taking the next-layer node as the second construction node, and returning to the step of judging whether the child node of the second construction node is the non-fractal node; if the child node of the second construction node is a fractal node, constructing the child node as a virtual node of the second construction node without the child node; until no node in the second fractal tree has a child node.
In the above example: fig. 4 is a schematic diagram of a second tree in the embodiment of the present application, where the schematic diagram of the second tree is only used to help understand the content of the present solution, and is not limited to the present solution, and the second tree may be displayed in an interface tree diagram form or may not be displayed. The fractal nodes can be divided into two types, one is an if statement block or a switch statement block, and the other is an override rewrite function.
If the acquired fractal node is an if statement block or a switch statement block; analyzing the fractal node, defining a virtual function X for the fractal node, and packaging the virtual function X into a virtual node X; and the virtual node X is taken as the root node of the second tree. Respectively defining a virtual function Y and a virtual function Z for each function branch of the fractal node, and respectively packaging the virtual function Y and the virtual function Z into a virtual node Y and a virtual node Z corresponding to the function branch; and taking the virtual node Y and the virtual node Z as first-layer nodes below the root node of the second fractal tree. Further, taking the virtual node Y as a second construction node, and the child node set of the second construction node-virtual node Y is: a function 5; fractal labels are non-fractal nodes; the function 5 is constructed as the next level node of the second construction node, virtual node Y. And then taking the function 5 as a second construction node, wherein the child node set of the second construction node-function 5 is as follows: a function 8; the fractal label is an fractal node, and the function 8 is constructed as a second construction node-a node of the next layer of the function 5.
Taking the virtual node Z as a second construction node, wherein the child node set of the second construction node-the virtual node Z is as follows: function 6, function 7; and the fractal label is an fractal node, and the function 6 and the function 7 are constructed as a next layer node of a second construction node, namely the virtual node Z. Then, taking the function 6 and the function 7 as second construction nodes; the child node set of the second construction node-function 6 is: a function 9; the fractal label is an fractal node, and the function 9 is constructed as a second construction node-a node of the next layer of the function 6. The child node set of the second construction node-function 7 is: v; the fractal label is a fractal node, and V is constructed as a next-layer virtual node without child nodes of a second construction node-function 7. Thus, no child node exists until any node at the lowest level in the second fractal tree. Therefore, by setting the hierarchical relation and the branch relation of the virtual nodes, the function call relation in the second fractal tree corresponding to the fractal nodes is accurate, the accuracy and the integrity of the 3D fractal tree are improved, and the accuracy of function call relation detection is further improved.
If the acquired fractal node is a coverage rewriting function; the fractal node is analyzed, and com, insight, search, overlapping methods search, search are called to obtain all the implementations, namely, the parent function and the child functions which rewrite and cover the parent function. Packing the parent function X of the coverage rewriting function into a virtual node X; and the virtual node X is taken as the root node of the second tree. Respectively taking a sub-function Y and a sub-function Z which cover and rewrite the parent function X in the covering and rewriting function as a virtual node Y and a virtual node Z; and taking the virtual node Y and the virtual node Z as first-layer nodes below the root node of the second fractal tree. Further, taking the virtual node Y as a second construction node, taking a function 5 for performing overlay rewriting on the sub-function Y (the second construction node and the virtual node Y) as a child node, and combining the child nodes of the virtual node Y as follows: a function 5; fractal labels are non-fractal nodes; function 5 is constructed as the next level node to virtual node Y. Then, taking the function 5 as a second construction node, taking a function 8 for performing coverage rewriting on the function 5 (the second construction node) as a child node, and the child node set of the function 5 is as follows: a function 8; fractal labels are non-fractal nodes; the function 8 is constructed as a node of the next layer of the function 5 (second construction node).
Taking the virtual node Z as a second construction node, taking a function 6 and a function 7 for performing coverage rewriting on the subfunction Z (the second construction node and the virtual node Z) as child nodes, and combining the child nodes of the virtual node Z as follows: function 6, function 7; fractal labels are non-fractal nodes; the functions 6 and 7 are constructed as nodes of the next layer of the virtual node Z (second construction node). Then, taking the function 6 and the function 7 as second construction nodes, taking a function 9 for performing coverage rewriting on the function 6 (the second construction node) as a child node, and combining the child nodes of the function 6 (the second construction node) as follows: a function 9; the fractal label is an fractal-free node, and the function 9 is constructed as a node of the next layer of the function 6 (second construction node). Taking V for performing coverage rewriting on the function 7 (second construction node) as a child node, wherein the child nodes of the function 7 (second construction node) are combined as follows: v; the fractal label is a fractal node, and V is constructed as a next-layer virtual node of the function 7 (second construction node) without child nodes. Thus, no child node exists until any node at the lowest level in the second fractal tree. Therefore, by setting the hierarchical relationship of the virtual nodes, the covering and rewriting levels of the parent function and each child function in the covering and rewriting function can be clear, the function call relationship in the second fractal tree corresponding to the fractal node is accurate, the accuracy and the integrity of the 3D fractal tree are improved, and the accuracy of function call relationship detection is further improved.
The embodiment of the application provides a method for constructing a 3D fractal tree, wherein the method for constructing the 3D fractal tree according to the first fractal tree and the second fractal tree comprises the following steps: determining a second fractal tree corresponding to the virtual node in the first fractal tree; and fusing the first fractal tree and the second fractal tree into a 3D fractal tree through virtual nodes in the first fractal tree. In the above example, the 3D fractal tree shown in fig. 5 is a 3D fractal tree obtained by supplementing the second fractal tree in the above example to the first fractal tree.
The embodiment of the application provides a method for constructing a 3D fractal tree, wherein the merging of the first fractal tree and the second fractal tree into the 3D fractal tree comprises: supplementing a second fractal tree corresponding to the virtual node into the virtual node of the first fractal tree to obtain a 3D fractal tree fused with the first fractal tree and the second fractal tree; or for each branch of a second fractal tree corresponding to the virtual node, respectively supplementing the branch into the virtual node of the first fractal tree, so as to obtain at least one 3D fractal tree with different branches, wherein the branches of the first fractal tree and the second fractal tree are fused. That is, the second fractal tree may be supplemented into the corresponding virtual node of the corresponding first fractal tree, as shown in fig. 5; it is also possible to merge each branch in the second tree with the first tree, respectively, as shown in fig. 6(a) and 6 (b). Therefore, a complete 3D fractal tree with multiple function call paths can be obtained; or the 3D fractal trees with one different function call path may be obtained respectively, where the 3D fractal tree with one different function call path includes all the function call paths. The 3D fractal tree comprises the function call relations of all functions to be detected in the codes to be detected, and the accuracy of the detection result of the codes to be detected can be improved.
The embodiment of the application provides a method for constructing a 3D fractal tree, which determines node information of each function to be detected in a code to be detected, and comprises the following steps: traversing each element in the code to be detected; for any element, if the element is a function, determining the element as a function to be detected; determining whether the function to be detected is a set function, and if the function to be detected is the set function, determining that the node label of the function to be detected indicates that the function to be detected is a fractal node; and traversing each element in the function body code of the function to be detected, thereby determining the child node of the function to be detected. That is, the analysis element in the code to be detected is a function, and the fractal function is a set function, for example, an if statement block, a switch statement block, an overwrite function. In addition, an element which is also required to be analyzed and generates corresponding node information in the code to be detected can be provided, the element is an fractal node and is also a non-function, the element can comprise at least one function, and the element has at least one function branch. For example, the element that is an fractal node and also is a non-function may be a statement block, and the element may be analyzed by the above-described generation method of the first fractal tree. As shown in fig. 7(a), when it is determined that the next-layer node of the function 1 is the statement block W and the function 2, the function 3 and the function 4 in the statement block W and the function 5 and the function 6 in the next-layer node of the function 2 are continuously obtained; the finally obtained 3D fractal tree is shown in fig. 7(b), and the node statement blocks W of the next layer of the function 1 are integrated into the node functions 3 and 4 of the next layer of the function 1.
The embodiment of the application provides a method for constructing a 3D fractal tree, which, before determining node information of each function to be detected in a code to be detected, further comprises: and determining that the cache does not contain the node information of the function to be detected. That is to say, if the analyzed function to be detected, which is the same as the function to be detected, exists in the cache, and the node information of the analyzed function to be detected exists in the cache, the node information in the cache is directly used as the node information of the function to be detected, and the pointer direction of the function to be detected can be set; and if the cache does not have the analyzed function to be detected which is the same as the function to be detected, analyzing the function to be detected, acquiring node information and caching. Therefore, the same multiple functions to be detected only need to be analyzed once, the speed of obtaining the 3D fractal tree is increased, and the detection speed is further increased.
The embodiment of the application provides a method for constructing a 3D fractal tree, wherein if the element is a function, the element is determined to be a function to be detected, and the method comprises the following steps: and if the element is determined to be a function and is a set service function, determining the element to be a function to be detected. That is, the function to be detected may be set; for example, if only the service function of the code to be detected needs to be detected, that is, the service function in the code to be detected is detected, the service function may be set as the function to be detected. In this way, only the function call relation of the business function can be detected, and analysis on a constructor, a hash function, a toString function and the like is not needed. Namely: method, getResolVescope () instanceof library ScopeBase | |)! Iswriteable () etc. scene skipping. The method has the advantages of determining the function to be detected in a targeted manner, reducing the number of function analysis, reducing the work of function analysis and accelerating the detection speed.
The embodiment of the application provides a method for constructing a 3D fractal tree, which determines whether each function to be detected accords with a function call relation through the 3D fractal tree, and comprises the following steps: traversing the 3D fractal tree after adding one node in the 3D fractal tree construction process to determine whether each function to be detected in the 3D fractal tree conforms to a function call relation; and if not, stopping the construction of the 3D fractal tree. That is to say, the function call relationship is obtained and detected according to the currently constructed partial fractal tree while constructing the 3D fractal tree, that is, the function call relationship is detected while constructing the fractal tree, so as to accelerate the speed of detecting the function call relationship.
The embodiment of the application provides a method for constructing a 3D fractal tree, which determines whether each function to be detected accords with a function call relation through the 3D fractal tree, and comprises the following steps: traversing nodes corresponding to each first function to be detected in the 3D fractal tree from a root node in the 3D fractal tree to obtain a first function call path; for any second function to be detected, traversing nodes corresponding to each second function to be detected in the 3D fractal tree from virtual nodes corresponding to function branches in the second function to be detected to obtain a second function call path; and determining whether each function to be detected accords with a function calling relation or not according to the first function calling path and the second function calling path. That is to say, the function call relationship between the first functions to be detected and the call relationship of the first functions to be detected to the second functions to be detected can be obtained according to the first fractal tree, so as to obtain the first function call path. And acquiring a calling relation between the second functions to be detected according to the second fractal tree to acquire a second function calling path. And thus, acquiring and detecting the function call path of each function to be detected of the code to be detected according to the first function call path and the second function call path.
Based on the above method process, the codes to be detected can be classified into three categories, the first category is that the codes to be detected include both the second functions to be detected corresponding to the fractal nodes and the first functions to be detected corresponding to the non-fractal nodes, and the above method process has already described how to obtain the 3D fractal tree of the codes to be detected. The second type is that the code to be detected does not contain a second function to be detected corresponding to the fractal node, and only contains a first function to be detected corresponding to the non-fractal node; the code to be detected can be used for acquiring the 3D fractal tree corresponding to the code to be detected by applying a 3D fractal tree construction method such as a first fractal tree, acquiring a function call relation and detecting according to a function call relation principle corresponding to the code to be detected. The third type is that the code to be detected only comprises a second function to be detected corresponding to the fractal node; the code to be detected can be used for obtaining the 3D fractal tree corresponding to the code to be detected by applying a 3D fractal tree construction method such as a second fractal tree, obtaining a function call relation and detecting according to a function call relation principle corresponding to the code to be detected. In addition, when the loop calling function exists in the three codes to be detected, the pointer which has loop pointing and does not influence function calling relation detection can be erased. For example, the nodes of the next layer of the function 1 are the function 2 and the function 3, the nodes of the next layer of the function 3 are the function 1, the nodes of the next layer of the function 1 are the function 3, and the nodes of the next layer of the function 3 are the function 1. Thus, a cyclic direction of a function call path is formed between the function 1 and the function 3, but only the function call relation of the function 1 and the function 2 is detected in the function call relation principle, a pointer of the function 3 to the function 1 can be erased, and the cyclic direction is damaged; when the 3D tree is prevented from being generated, endless loop analysis is performed on the function 1 and the function 3, and the detection speed is reduced.
When the same node is repeatedly called in the three codes to be detected, the finally obtained 3D fractal tree is not influenced. For example, the code to be detected 1 and the code to be detected 2 are shown below; fig. 8(a) is a schematic diagram of generating a 3D fractal tree for representing a code to be detected 1, and fig. 8(b) is a schematic diagram of generating a 3D fractal tree for representing a code to be detected 2:
the code to be detected 1: { function 1 ═ (function 2) + (function 3)
Function 2 ═ (function 4)
Function 3 ═ (function 4)
Function 4 ═ a × B
}
And 2, the code to be detected: { function 1 ═ (function 2) + (function 3)
Function 2 ═ (function 4)
Function 4 ═ a × B
Function 3 ═ (function 4)
Function 4 ═ a × B
}
Based on the above method flow, an embodiment of the present application provides a flow of a method for detecting a function call relationship, as shown in fig. 9, including:
and step 901, acquiring a code to be detected.
And step 902, analyzing any element in the code to be detected, and determining the element with the function as the element as the function to be detected. The element can also be determined as a function, and the element which is a service function is a function to be detected; here, it may also be determined that the element is an fractal node and also a non-function, and may include at least one function, and the element having at least one function branch is the first function to be detected; here, it may also be determined that the element is a fractal node, which is the second function to be detected.
And step 903, acquiring node information of each function to be detected.
And 904, acquiring the first fractal tree and the second fractal tree according to the node information of each function to be detected.
And 905, fusing the first fractal tree and the second fractal tree to obtain a 3D fractal tree.
And 906, acquiring a function call relation of the code to be detected through the 3D fractal tree.
Step 907, comparing and detecting the function call relation with the function call relation principle.
And 908, acquiring a detection result.
It should be noted that, the above flow steps are not exclusive, and for example, step 903 and step 904 may be performed simultaneously.
Based on the same concept, an embodiment of the present invention provides a function call relation detection apparatus, and fig. 10 is a schematic diagram of the function call relation detection apparatus provided in the embodiment of the present application, as shown in fig. 10, including:
the analysis module 1001 is configured to determine node information of each function to be detected in the code to be detected, where the node information includes a node tag used to represent whether the function to be detected is a fractal node;
the processing module 1002 is configured to construct a first fractal tree according to node information of each first function to be detected, and construct a second fractal tree according to node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node;
the processing module 1002 is further configured to construct a 3D fractal tree according to the first fractal tree and the second fractal tree;
a determining module 1003, configured to determine whether each function to be detected conforms to a function call relationship through the 3D fractal tree.
Optionally, the node information further includes child nodes; the child node is a function called by a function to be detected; the processing module 1002 is specifically configured to: aiming at any first function to be detected, taking the first function to be detected as a root node of a first fractal tree, taking the root node as a first construction node, and judging whether a child node of the first construction node is a non-fractal node; if the child node is a non-fractal node, constructing the child node as a next-layer node of the first construction node, taking the next-layer node as the first construction node, and returning to the step of judging whether the child node of the first construction node is the non-fractal node; if the child node of the first construction node is a fractal node, constructing the child node as a virtual node of the first construction node without the child node; until none of the nodes in the first fractal tree have child nodes.
Optionally, the processing module 1002 is specifically configured to: aiming at any second function to be detected, generating a virtual node of the second function to be detected as a root node of a second fractal tree; generating a virtual node corresponding to any function branch of the second function to be detected as a first-layer node under a root node of the second fractal tree; generating the lower-layer node of the virtual node of any function branch by the following method: taking the virtual node as a second construction node, and judging whether a child node of the second construction node is a non-fractal node; if the child node of the second construction node is a non-fractal node, constructing the child node as a next-layer node of the second construction node, taking the next-layer node as the second construction node, and returning to the step of judging whether the child node of the second construction node is the non-fractal node; if the child node of the second construction node is a fractal node, constructing the child node as a virtual node of the second construction node without the child node; until no node in the second fractal tree has a child node.
Optionally, the processing module 1002 is specifically configured to: determining a second fractal tree corresponding to the virtual node in the first fractal tree; and fusing the first fractal tree and the second fractal tree into a 3D fractal tree through virtual nodes in the first fractal tree.
Optionally, the processing module 1002 is specifically configured to: supplementing a second fractal tree corresponding to the virtual node into the virtual node of the first fractal tree to obtain a 3D fractal tree fused with the first fractal tree and the second fractal tree; or for each branch of a second fractal tree corresponding to the virtual node, respectively supplementing the branch into the virtual node of the first fractal tree, so as to obtain at least one 3D fractal tree with different branches, wherein the branches of the first fractal tree and the second fractal tree are fused.
Optionally, the processing module 1002 is specifically configured to: traversing each element in the code to be detected; for any element, if the element is a function, determining the element as a function to be detected; determining whether the function to be detected is a set function, and if the function to be detected is the set function, determining that the node label of the function to be detected indicates that the function to be detected is a fractal node; and traversing each element in the function body code of the function to be detected, thereby determining the child node of the function to be detected.
Optionally, the analysis module 1001 is further configured to: and determining that the cache does not contain the node information of the function to be detected.
Optionally, the processing module 1002 is specifically configured to: if the element is a function, determining the element to be a function to be detected, including: and if the element is determined to be a function and is a set service function, determining the element to be a function to be detected.
Optionally, the determining module 1003 is specifically configured to: determining whether each function to be detected accords with a function call relation through the 3D fractal tree, including: traversing the 3D fractal tree after adding one node in the 3D fractal tree construction process to determine whether each function to be detected in the 3D fractal tree conforms to a function call relation; and if not, stopping the construction of the 3D fractal tree.
Optionally, the processing module 1002 is specifically configured to: traversing nodes corresponding to each first function to be detected in the 3D fractal tree from a root node in the 3D fractal tree to obtain a first function call path; for any second function to be detected, traversing nodes corresponding to each second function to be detected in the 3D fractal tree from virtual nodes corresponding to function branches in the second function to be detected to obtain a second function call path; and determining whether each function to be detected accords with a function calling relation or not according to the first function calling path and the second function calling path.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A method for detecting a function call relation, the method comprising:
determining node information of each function to be detected in the code to be detected, wherein the node information comprises a node label for representing whether the function to be detected is a fractal node;
constructing a first fractal tree according to the node information of each first function to be detected, and constructing a second fractal tree according to the node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node;
constructing a 3D fractal tree according to the first fractal tree and the second fractal tree;
and determining whether each function to be detected accords with a function call relation or not through the 3D fractal tree.
2. The method as recited in claim 1, wherein the node information further includes child nodes; the child node is a function called by a function to be detected; the constructing of the first fractal tree according to the node information of each first function to be detected includes:
aiming at any first function to be detected, taking the first function to be detected as a root node of a first fractal tree, taking the root node as a first construction node, and judging whether a child node of the first construction node is a non-fractal node;
if the child node is a non-fractal node, constructing the child node as a next-layer node of the first construction node, taking the next-layer node as the first construction node, and returning to the step of judging whether the child node of the first construction node is the non-fractal node;
if the child node of the first construction node is a fractal node, constructing the child node as a virtual node of the first construction node without the child node;
until none of the nodes in the first fractal tree have child nodes.
3. The method of claim 2, wherein constructing the second trellis tree based on node information for each second function to be detected comprises:
aiming at any second function to be detected, generating a virtual node of the second function to be detected as a root node of a second fractal tree; generating a virtual node corresponding to any function branch of the second function to be detected as a first-layer node under a root node of the second fractal tree;
generating the lower-layer node of the virtual node of any function branch by the following method:
taking the virtual node as a second construction node, and judging whether a child node of the second construction node is a non-fractal node;
if the child node of the second construction node is a non-fractal node, constructing the child node as a next-layer node of the second construction node, taking the next-layer node as the second construction node, and returning to the step of judging whether the child node of the second construction node is the non-fractal node;
if the child node of the second construction node is a fractal node, constructing the child node as a virtual node of the second construction node without the child node;
until no node in the second fractal tree has a child node.
4. The method as claimed in claim 3, wherein constructing a 3D fractal tree from the first fractal tree and the second fractal tree comprises:
determining a second fractal tree corresponding to the virtual node in the first fractal tree;
and fusing the first fractal tree and the second fractal tree into a 3D fractal tree through virtual nodes in the first fractal tree.
5. The method as recited in claim 4, wherein said fusing said first fractal tree and said second fractal tree into a 3D fractal tree, comprises:
supplementing a second fractal tree corresponding to the virtual node into the virtual node of the first fractal tree to obtain a 3D fractal tree fused with the first fractal tree and the second fractal tree; or,
and aiming at each branch of a second fractal tree corresponding to the virtual node, respectively supplementing the branch into the virtual node of the first fractal tree to obtain at least one 3D fractal tree with different branches, wherein the branches of the first fractal tree and the second fractal tree are fused.
6. The method according to any one of claims 1 to 5, wherein determining node information of each function to be detected in the code to be detected comprises:
traversing each element in the code to be detected;
for any element, if the element is a function, determining the element as a function to be detected; determining whether the function to be detected is a set function, and if the function to be detected is the set function, determining that the node label of the function to be detected indicates that the function to be detected is a fractal node; and traversing each element in the function body code of the function to be detected, thereby determining the child node of the function to be detected.
7. The method according to any one of claims 1 to 5,
determining whether each function to be detected accords with a function call relation through the 3D fractal tree, including:
traversing the 3D fractal tree after adding one node in the 3D fractal tree construction process to determine whether each function to be detected in the 3D fractal tree conforms to a function call relation; and if not, stopping the construction of the 3D fractal tree.
8. The method as claimed in any one of claims 1 to 5, wherein determining whether each function to be detected conforms to a function call relationship through the 3D fractal tree comprises:
traversing nodes corresponding to each first function to be detected in the 3D fractal tree from a root node in the 3D fractal tree to obtain a first function call path;
for any second function to be detected, traversing nodes corresponding to each second function to be detected in the 3D fractal tree from virtual nodes corresponding to function branches in the second function to be detected to obtain a second function call path;
and determining whether each function to be detected accords with a function calling relation or not according to the first function calling path and the second function calling path.
9. A function call relation detecting apparatus, the apparatus comprising:
the analysis module is used for determining node information of each function to be detected in the code to be detected, wherein the node information comprises a node label used for representing whether the function to be detected is a fractal node;
the processing module is used for constructing a first fractal tree according to the node information of each first function to be detected and constructing a second fractal tree according to the node information of each second function to be detected; the first function to be detected is a function to be detected of which the node label is indicated to be an fractal node; the second function to be detected is a function to be detected with a node label indicated as a fractal node;
the processing module is further used for constructing a 3D fractal tree according to the first fractal tree and the second fractal tree;
and the judging module is used for determining whether each function to be detected accords with the function call relation or not through the 3D fractal tree.
10. A computer device, comprising:
a memory for storing a computer program;
a processor for calling a computer program stored in said memory to execute the method of any of claims 1 to 8 in accordance with the obtained program.
CN202110338210.1A 2021-03-30 2021-03-30 Method and device for detecting function call relationship Active CN113076244B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202110338210.1A CN113076244B (en) 2021-03-30 2021-03-30 Method and device for detecting function call relationship
PCT/CN2021/141990 WO2022206062A1 (en) 2021-03-30 2021-12-28 Function call relationship detecting method and apparatus

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110338210.1A CN113076244B (en) 2021-03-30 2021-03-30 Method and device for detecting function call relationship

Publications (2)

Publication Number Publication Date
CN113076244A true CN113076244A (en) 2021-07-06
CN113076244B CN113076244B (en) 2023-03-03

Family

ID=76611369

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110338210.1A Active CN113076244B (en) 2021-03-30 2021-03-30 Method and device for detecting function call relationship

Country Status (2)

Country Link
CN (1) CN113076244B (en)
WO (1) WO2022206062A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022206062A1 (en) * 2021-03-30 2022-10-06 深圳前海微众银行股份有限公司 Function call relationship detecting method and apparatus

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5581696A (en) * 1995-05-09 1996-12-03 Parasoft Corporation Method using a computer for automatically instrumenting a computer program for dynamic debugging
US20030159133A1 (en) * 2001-10-26 2003-08-21 International Business Machines Corporation Method and system for tracing and displaying execution of nested functions
US20040205474A1 (en) * 2001-07-30 2004-10-14 Eleazar Eskin System and methods for intrusion detection with dynamic window sizes
US20110209126A1 (en) * 2010-02-19 2011-08-25 Ansgar Fehnker Inter-procedural analysis of computer programs
CN105468508A (en) * 2014-09-04 2016-04-06 阿里巴巴集团控股有限公司 Code testing method and apparatus
CN106294156A (en) * 2016-08-11 2017-01-04 北京邮电大学 A kind of static code fault detection analysis method and device
CN111104335A (en) * 2019-12-25 2020-05-05 清华大学 A C language defect detection method and device based on multi-level analysis

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8631395B2 (en) * 2011-09-02 2014-01-14 Microsoft Corporation Inter-procedural dead catch handler optimizations
CN112181808B (en) * 2020-09-08 2022-06-28 北京邮电大学 A program concurrency defect detection method, apparatus, device and storage medium
CN113076244B (en) * 2021-03-30 2023-03-03 深圳前海微众银行股份有限公司 Method and device for detecting function call relationship

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5581696A (en) * 1995-05-09 1996-12-03 Parasoft Corporation Method using a computer for automatically instrumenting a computer program for dynamic debugging
US20040205474A1 (en) * 2001-07-30 2004-10-14 Eleazar Eskin System and methods for intrusion detection with dynamic window sizes
US20030159133A1 (en) * 2001-10-26 2003-08-21 International Business Machines Corporation Method and system for tracing and displaying execution of nested functions
US20110209126A1 (en) * 2010-02-19 2011-08-25 Ansgar Fehnker Inter-procedural analysis of computer programs
CN105468508A (en) * 2014-09-04 2016-04-06 阿里巴巴集团控股有限公司 Code testing method and apparatus
CN106294156A (en) * 2016-08-11 2017-01-04 北京邮电大学 A kind of static code fault detection analysis method and device
CN111104335A (en) * 2019-12-25 2020-05-05 清华大学 A C language defect detection method and device based on multi-level analysis

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
姜林 等: "基于可控随机变换的分形树生成算法及实现", 《微电子学与计算机》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022206062A1 (en) * 2021-03-30 2022-10-06 深圳前海微众银行股份有限公司 Function call relationship detecting method and apparatus

Also Published As

Publication number Publication date
CN113076244B (en) 2023-03-03
WO2022206062A1 (en) 2022-10-06

Similar Documents

Publication Publication Date Title
CN109426723B (en) Detection method, system, equipment and storage medium using released memory
CN107992307B (en) Method and device for compiling functions
JP7201078B2 (en) Systems and methods for dynamically identifying data arguments and instrumenting source code
US8935673B1 (en) System and method for debugging computer program based on execution history
US8312440B2 (en) Method, computer program product, and hardware product for providing program individuality analysis for source code programs
US11200048B2 (en) Modification of codified infrastructure for orchestration in a multi-cloud environment
CN111104335B (en) A C language defect detection method and device based on multi-level analysis
US20060150160A1 (en) Software analyzer
US20200210158A1 (en) Automated or machine-enhanced source code debugging
CN108984416B (en) A way to assess the danger level of dependency conflicts in a Maven environment
US10915302B2 (en) Identification and visualization of associations among code generated from a model and sources that affect code generation
EP2257873A2 (en) Systems and methods for information flow analysis
CN110673837B (en) Code repairing method and device, electronic equipment and computer readable storage medium
CN111488579A (en) Vulnerability detection method and device, electronic equipment and computer readable storage medium
CN112346730B (en) Intermediate representation generation method, computer equipment and storage medium
CN115994086A (en) Image processing method and device, storage medium and terminal
CN113076244A (en) Method and device for detecting function call relationship
US11334475B1 (en) Graph based event-driven computing
CN112631925B (en) Method for detecting single-variable atom violation defect
US20130152049A1 (en) Warning of register and storage area assignment errors
CN116432185B (en) Abnormality detection method and device, readable storage medium and electronic equipment
CN118193382A (en) Application program testing method, device, equipment, storage medium and program product
US20240256713A1 (en) Updating annotated software objects
JP2020038482A (en) Program verification program, program verification method and program verification device
Boussabbeh et al. Formal proofs of termination detection for local computations by refinement-based compositions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant