CN109117164B - Micro-service updating method and system based on difference analysis of key elements - Google Patents

Micro-service updating method and system based on difference analysis of key elements Download PDF

Info

Publication number
CN109117164B
CN109117164B CN201811014183.7A CN201811014183A CN109117164B CN 109117164 B CN109117164 B CN 109117164B CN 201811014183 A CN201811014183 A CN 201811014183A CN 109117164 B CN109117164 B CN 109117164B
Authority
CN
China
Prior art keywords
android application
key element
micro
version
similarity
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.)
Active
Application number
CN201811014183.7A
Other languages
Chinese (zh)
Other versions
CN109117164A (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.)
Peking University
Original Assignee
Peking University
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 Peking University filed Critical Peking University
Publication of CN109117164A publication Critical patent/CN109117164A/en
Application granted granted Critical
Publication of CN109117164B publication Critical patent/CN109117164B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/72Code refactoring
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a micro-service updating method and a system based on key element difference analysis, which screen out a key element set to be analyzed through analyzing byte codes in micro-services, judge whether destructive change occurs to android applications in version change relative to micro-services through analyzing the similarity of the key elements between the android applications of new and old versions, judge whether the destructive change occurs to the key elements through analyzing the similarity of the key elements between the android applications of the new and old versions when the destructive change occurs, position the key elements to be modified in the micro-services, give a modification recommendation list to each key element to be modified, further update the micro-services according to the modification recommendation list, and avoid unnecessary modification to the micro-services and unnecessary modification to the key elements in the micro-services when the android application versions are subjected to non-destructive change, resource waste is reduced, and micro-service upgrading efficiency is improved.

Description

Micro-service updating method and system based on difference analysis of key elements
Technical Field
The invention relates to computer software, in particular to a micro-service updating method and system based on difference analysis of key elements.
Background
In the era of mobile internet, the way for users to consume content and obtain online services is mainly mobile application. A large amount of contents such as service and user usage data are accumulated in a single application. However, the current situation that the applications are independent from each other forms an 'information island' of the mobile application ecology. The information isolated island between the APPs becomes an important reason that the scene is split and the intelligent degree of the application is difficult to promote.
By adopting the internet software behavior reflection technology, the android application can be encapsulated into the micro service without the support of a third-party developer, and the possibility is provided for breaking the ecological information island phenomenon of the mobile application. Under the condition that third party cooperation is not needed, any function of any android application can be packaged into the micro-service by utilizing the internetware behavior reflection technology.
The internetware behavior reflection technology is used for completely monitoring execution of android application, analyzing a model monitoring result in operation and generating application microservices. The application behavior runtime model will act on the stack area and code segments of the memory space in the runtime environment, thereby implementing instruction level reflection. Since the results of monitoring the execution of the android application depend on the android application bytecode, this technique relies heavily on the android application bytecode and the application microservice matching. If the bytecode of the mobile application changes, the runtime environment of the mobile application also changes, which causes that the micro-service obtained by the previous analysis cannot be matched with the runtime environment at the moment, that is, the application micro-service fails, and the internetware behavior reflection technology cannot run normally.
The following scenario may lead to application microservice failure:
1. and 6, issuing the android application in a multi-channel mode. For the same android application, different packaging modes can be adopted if the application is published in different downloading channels. Causing the source code of the application to change.
2. And upgrading the android application version. Upgrading of an android application version is divided into two situations, namely, firstly, source code logic corresponding to application microservices generated by an internetware behavior reflection technology is changed; the second is that the logic is unchanged. However, when the application version is upgraded, the application is re-obfuscated and packaged, and even if the source code logic corresponding to the generated application microservice is not changed, the runtime model fails due to code obfuscation.
3. The android application is hot updated. In recent years, many developers have started to use a hot-update framework of an application to update application source code by means of hot-patching without upgrading the version of an android application.
These objective conditions may cause the stability of the reflection technology of the behavior of the internet software to be reduced, and the service cannot be continuously provided. At present, the traditional approach for dealing with the situation is to upgrade and monitor the applications in the android application market, and once the upgrade of the applications is found, corresponding upgrade is performed on the android application microservices in a man-machine cooperation and semi-automatic mode immediately. Through long-term experiments and measurement, development cost of 1.5 people days is spent on average when the micro-service upgrading, testing, deploying and the like are carried out once. These factors increase the cost of application of the behavioral reflex technology of the internetware, reduce the economic benefit and create a great gap between the technology and the application.
The three reasons for the failure of the application microservice are that the bytecode of the android application is changed to a certain extent in the process of application release or version change. The present document refers to the situation that the bytecode of the application changes as the application version changes, and refers to the version before the version changes as the "old version" and the version after the version changes as the "new version".
The android application bytecode is stored in an executable file dex file of the android system. Representing android application bytecodes as abstract syntax trees, abstract syntax tree changes can be divided into two broad categories: firstly, the nodes of the abstract syntax tree are changed, such as some Token names are modified; secondly, the structure of the abstract syntax tree is changed, for example, a method is added, a domain is deleted, and the like. In the actual use scenario of the internetware behavior reflection technology, most of multi-channel release, version upgrade and hot update do not affect the actual logic of the generated application microservices. That is, the node itself of the abstract syntax tree is changed, and the structure is not changed. Nodes in these dex bytecode abstract syntax trees are defined herein as key elements, i.e., symbol sets between two different versions of the same android application that may cause the microservices corresponding to one version of application to generate a "binary incompatibility" phenomenon with another version of the android application. Specifically, in an actual scenario, the class name, the method name and the variable name of the dex bytecode are corresponded.
To solve the above-mentioned problem that the key elements change during the version change process, the following two challenges are mainly faced:
1. and judging whether destructive change occurs in the version change process. During the course of version change, the change of bytecode can be divided into destructive change and non-destructive change. If the original micro service causes a compiling error, a runtime exception or an unexpected result to the new android application byte code due to the version change, the change is destructive. Otherwise, it is a non-destructive change. For non-destructive version changes, the android application micro-service can still be compatible with the new version of the android application without updating, and only for destructive changes, the android application micro-service must be updated to be compatible with the new version of the android application. If a system judgment method is lacked, whether the android application version is subjected to destructive change or non-destructive change cannot be predicted in advance, even if the android application version is subjected to non-destructive change, developers still need to adopt the same mode and consume 1.5 people of development cost, and then can obtain the conclusion that the original android application microservice can operate without being updated, so that great resource waste is generated. However, due to the high complexity and the variable runtime environment of the android bytecode, it is difficult to predict in advance whether the android application version is changed destructively or non-destructively by a single method.
2. And positioning the key element to be modified and modifying the recommendation. For the situation that the version of the android application is destructively changed, the modification position in the application micro-service of the old version needs to be automatically positioned, namely, the fact that the old application micro-service cannot work normally due to the fact that the key elements are changed is determined. Because the application microservice generated after monitoring the android application is only one code logic segment, the corresponding logic segment needs to be found in the relatively huge android application source code, whether each key element in the android application source code changes is analyzed, and if the key element in the android application source code changes, a corresponding modification recommendation needs to be given, the difficulty of the work is very high, and especially how to balance the efficiency and the accuracy of the work becomes another important challenge.
Disclosure of Invention
The invention mainly aims to provide a micro-service updating method and system based on key element difference analysis, and aims to solve the problems that the prior art cannot accurately judge whether destructive change occurs in the android application version change process, and cannot accurately position key elements needing to be modified and recommend a modification scheme to the key elements needing to be modified when destructive change occurs in the android application version change process.
A micro-service updating method based on differential analysis of key elements comprises the following steps:
key element screening process: analyzing byte codes in the micro-service matched with the old edition of android application, and screening out a set of all key elements influencing the matching between the micro-service and the new edition of android application;
and (3) key element similarity analysis flow: analyzing similarity between the new version android application and the old version android application of each key element in the set;
destructive change judgment flow: judging whether destructive change occurs to the micro-service or not after the android application is changed from the old version to the new version;
the key element positioning process needing to be modified comprises the following steps: when the android application is changed from the old version to the new version and is destructively changed relative to the micro-service, judging whether each key element in the set is destructively changed relative to the micro-service after the android application is changed from the old version to the new version according to the similarity between the key elements in the new version and the old version of the android application, and taking the destructively changed key element as a key element needing to be modified in the micro-service;
the key element modification scheme recommendation process comprises the following steps: according to the similarity of each key element between the new edition of android application and the old edition of android application, giving a modification recommendation list to each key element needing to be modified in the micro service, wherein the modification recommendation list comprises a preset number of key elements with the highest similarity with the key element needing to be modified in the micro service in each key element in the new edition of android application;
and (3) micro-service updating flow: and for each key element needing to be modified in the micro-service, modifying the key element needing to be modified into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified, so as to finish the updating of the micro-service.
Further, the key element screening process comprises:
step S1: analyzing the dex byte code of the micro service by using a visitor mode, and constructing an abstract syntax tree of the dex byte code of the micro service;
step S2: traversing the abstract syntax tree of the Dex byte codes of the micro-service, and adding all the Dex class nodes, Dex domain nodes, Dex method nodes in the abstract syntax tree of the Dex byte codes of the micro-service and the class names, the method names and the variable names in the domain access statements and the function call statements in the Dex code nodes into the set as key elements influencing the matching between the micro-service and the new edition android application.
Further, the key element similarity analysis process includes:
and (3) a key element similarity static analysis process: analyzing the similarity of each key element in the set between the new edition of android application and the old edition of android application according to the dex bytecode of the old edition of android application and the dex bytecode of the new edition of android application;
the key element similarity dynamic analysis process comprises the following steps: respectively monitoring the application activity condition in the runtime stack models of the new edition of android application and the old edition of android application by utilizing an internetware behavior reflection frame to obtain runtime stack model monitoring results of the new edition of android application and the old edition of android application; and analyzing the similarity of each key element in the set between the new edition android application and the old edition android application according to the monitoring result of the stack model when the new edition android application and the old edition android application run.
Further, in the key element similarity static analysis process, for any key element X in the set, the step of analyzing the similarity between the new version android application and the old version android application includes:
step S1: calculating the first-degree similarity of the key element X between the new-version android application and the old-version android application, wherein the calculation method comprises the following steps:
extracting the intra-element features of a key element X in the new edition of android application and the old edition of android application, and calculating the degree of similarity of the key element X between the new edition of android application and the old edition of android application according to the intra-element features of the key element X in the new edition of android application and the old edition of android application;
step S2: judging whether the key element X is a complex element or a simple element, if the key element X is the complex element, taking the first degree of similarity as the similarity of the key element X between the new version android application and the old version android application, and if the key element X is the simple element, entering the step S3:
step S3: calculating the second-degree similarity of a key element X between the new-version android application and the old-version android application, taking the second-degree similarity as the similarity of the key element X between the new-version android application and the old-version android application, and calculating the second-degree similarity of the key element X between the new-version android application and the old-version android application comprises the following steps:
extracting inter-element features of a key element X in the new version android application and the old version android application, searching elements associated with the key element X in the new version android application and the old version android application according to the inter-element features of the key element X in the new version android application and the old version android application, calculating similarity between the elements associated with the key element X in the new version android application and the elements associated with the key element X in the old version android application, and accordingly obtaining the second degree similarity between the key element X in the new version android application and the old version android application.
Further, in the dynamic key element similarity analysis process, for any key element Y in the set, the step of analyzing the similarity between the new version android application and the old version android application includes:
and calculating the similarity of the key element Y between the new edition of android application and the old edition of android application according to the precedence relationship of the activity occurrence time of the key element Y in the application activity.
Further, the destructive change determination process includes:
and running the micro-service on the new version android application, if the obtained return value is the same as the return value obtained when the micro-service runs on the old version android application, judging that the android application is changed from the old version to the new version and is not destructively changed relative to the micro-service, and if the phenomenon that the micro-service throws out abnormity, cannot run or the returned result is incorrect, judging that the android application is changed from the old version to the new version and is destructively changed relative to the micro-service.
Further, in the key element positioning process to be modified, for any key element Z in the set, the process of determining whether a destructive change occurs to the microservice after the android application is changed from the old version to the new version includes:
calculating expected e1 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity static analysis process;
calculating expected e2 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity dynamic analysis process;
when e1< t1 and e2< t2 are satisfied, determining that the key element Z is destructively changed relative to the microservice after the android application is changed from the old version to the new version, and otherwise determining that the key element Z is not destructively changed relative to the microservice after the android application is changed from the old version to the new version.
Further, in the key element modification scheme recommendation process, the process of giving the modification recommendation list to any key element c in the microservice that needs to be modified includes:
calculating the similarity between all key elements in the new edition of android application and the key elements c in the old edition of android application;
arranging all key elements in the new edition android application according to the sequence of similarity from high to low to obtain a set C ═ { C1, C2, C3, …, cn }, and arranging the calculated similarities from high to low to obtain a set S ═ S1, S2, S3, …, sk, …, sn };
forming a first list of the first k key elements in the set C, wherein (s1-sk)/s1<, which is a preset critical value;
in the minimum-cost maximum network flow, setting the capacity of element nodes starting from a source point to each old version of android application as n, and forming a second list by using key elements which are less than or equal to n and have the highest similarity with the key element c in the new version of android application;
combining the first list with the second list to form the modified recommendation list.
A micro-service updating system based on key element difference analysis is used for implementing each flow in the micro-service updating method based on key element difference analysis, and comprises the following steps:
the key element screening module is used for analyzing byte codes in the micro-service matched with the old version android application and screening out a set of all key elements influencing the matching between the micro-service and the new version android application;
a key element similarity analysis module for analyzing the similarity between the new version of android application and the old version of android application of each key element in the set;
the destructive change judging module is used for judging whether destructive change occurs on the micro-service or not after the android application is changed from the old version to the new version;
a key element positioning module to be modified, configured to, when the android application changes from an old version to a new version and is destructively changed with respect to the micro-service, determine, according to a similarity between the new version android application and the old version android application of each key element, whether each key element in the set is destructively changed with respect to the micro-service after the android application changes from the old version to the new version, and use the destructively changed key element as a key element to be modified in the micro-service;
a key element modification scheme recommending module, configured to provide a modification recommendation list for each key element that needs to be modified in the micro-service according to a similarity between the new version of the android application and the old version of the android application of each key element, where the modification recommendation list includes a preset number of key elements that are the highest in similarity between each key element in the new version of the android application and the key element that needs to be modified in the micro-service;
and the micro-service updating module is used for modifying each key element needing to be modified in the micro-service into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified so as to finish the updating of the micro-service.
Compared with the prior art, the micro-service updating method and system based on key element difference analysis provided by the invention screen out the key element set to be analyzed through analyzing byte codes in the micro-service, judge whether destructive change occurs to the android application in the version change process relative to the micro-service through analyzing the similarity of each key element between the android applications of the new version and the old version, judge whether each key element has destructive change through analyzing the similarity of each key element between the android applications of the new version and the old version when the destructive change occurs, position the key elements to be modified in the micro-service, give a modification recommendation list for each key element to be modified, further update the micro-service according to the modification recommendation list, and avoid unnecessary modification to the micro-service when the android application version has non-destructive change, and key elements which are not needed to be modified in the micro-service are modified, so that the resource waste is reduced, and the micro-service upgrading efficiency is improved.
Drawings
FIG. 1 is a schematic diagram of an android application key element analysis framework structure;
FIG. 2 is a schematic general flow chart of a micro-service updating method based on differential analysis of key elements according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of class diagram analysis of a dex file using visitor patterns;
FIG. 4 is a structure of an abstract syntax tree;
FIG. 5 is a diagram illustrating the definition of the first degree similarity and the second degree similarity;
FIG. 6 is a schematic diagram of selection of first degree similarity and second degree similarity;
FIG. 7 is a diagram of android application monitoring results class;
FIG. 8 is a schematic view of a minimum cost maximum flow architecture;
FIG. 9 is a flow diagram of an application layer overview;
fig. 10 is a general flowchart of a micro-service update system based on a difference analysis of key elements according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be further described in detail with reference to the following embodiments and the accompanying drawings.
The embodiment of the invention designs an android application key element analysis framework. The analysis framework shown in fig. 1 consists of 3 levels, and the input of the analysis framework and the positioning of the levels are described below.
The input of the analysis framework is byte codes of the old version android application, runtime stack model monitoring results of the old version android application, the old version micro-service, byte codes of the new version android application and runtime stack model monitoring results of the new version android application.
The processing layer is composed of a key element screening process, the input of the process is the old version micro service, and the output is the key element to be analyzed by the method. By analyzing the micro-service byte codes, the flow can obtain key elements needing to be analyzed by the invention, namely symbols in some byte codes influencing the key related to the purpose of the invention. The key elements correspond to class names, method names, and variable names in the Java code.
The analysis layer is composed of a key element similarity static analysis process and a key element similarity dynamic analysis process.
And (3) a key element similarity static analysis process: the input of the process is the key elements, the old version android application bytecode and the new version android application bytecode defined by the key element screening process, and the output is specific to the key elements, and after the old version android application bytecode and the new version android application bytecode are subjected to static analysis, the similarity relation of the key elements between the new version android application and the old version android application is obtained. The similarity of a certain key element between the new-version android application and the old-version android application refers to the fact that the key element exists in both the new-version android application and the old-version android application, and the similarity between the key element in the new-version android application and the key element in the old-version android application is the similarity between the key element and the new-version android application. The flow is one of core flows of an analysis framework and aims to obtain the similarity relation of key elements between the android applications of the new version and the old version through static analysis.
The key element similarity dynamic analysis process comprises the following steps: the input of the process is the key elements defined in the text, the monitoring results of the stack model when the old version android application runs and the monitoring results of the stack model when the new version android application runs, which are obtained by the key element screening process, and the output is the similarity relation of the key elements between the new version android application and the old version android application after dynamic analysis. The process is also one of core processes of an analysis framework, aims to obtain the similarity relation of key elements between the android applications of the new and old versions through dynamic analysis, and is an important supplement of a static analysis process of the similarity of the key elements.
The application layer is composed of a destructive change judgment process, a key element positioning process to be modified and a key element modification scheme recommendation process.
Destructive change judgment flow: the input of the process is the similarity relation between the new and old versions of android applications of each key element obtained by the key element similarity static analysis process and the key element similarity dynamic analysis process, and the output is the possibility that the bytecode of the new version of android applications is destructively changed relative to the old version of micro-service, namely the phenomenon of binary incompatibility can occur to the extent of the old version of micro-service and the new version of android applications. The purpose of the destructive change judging process is to judge whether the android application is destructively changed in the version change process.
The key element positioning process needing to be modified comprises the following steps: the input of the process is the similarity relation between the new and old versions of the android applications of each key element obtained by the key element similarity static analysis process and the key element similarity dynamic analysis process, and the output is the possibility that each key element in the android applications is subjected to destructive change. The purpose of the key element positioning flow to be modified is to position which key elements are destructively changed in the process of version change.
The key element modification scheme recommendation process comprises the following steps: the input of the process is the similarity relation of each key element between the android applications of the new version and the old version obtained by the key element similarity static analysis process and the key element similarity dynamic analysis process, and the key elements which are positioned in the key element positioning process and have destructive changes are output, and the output is the recommendation of the reason element which should be changed in the microservice of the new version for each changed key element.
As shown in fig. 2, the micro service updating method based on the differential analysis of key elements according to the embodiment of the present invention includes:
key element screening process: analyzing byte codes in the micro-service matched with the old edition of android application, and screening out a set of all key elements influencing the matching between the micro-service and the new edition of android application;
and (3) key element similarity analysis flow: analyzing the similarity of each key element in the set between the new edition of android application and the old edition of android application;
destructive change judgment flow: judging whether destructive change occurs to the micro-service or not after the android application is changed from the old version to the new version;
the key element positioning process needing to be modified comprises the following steps: when the android application is changed from the old version to the new version and is destructively changed relative to the micro-service, judging whether each key element in the set is destructively changed relative to the micro-service after the android application is changed from the old version to the new version according to the similarity between each key element and the new version android application, and taking the key element which is destructively changed as a key element needing to be modified in the micro-service;
the key element modification scheme recommendation process comprises the following steps: according to the similarity of each key element between the new edition of android application and the old edition of android application, giving a modification recommendation list for each key element needing to be modified in the micro service, wherein the modification recommendation list comprises a preset number of key elements with the highest similarity with the key element needing to be modified in the micro service in each key element in the new edition of android application;
and (3) micro-service updating flow: and for each key element needing to be modified in the micro-service, modifying the key element needing to be modified into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified, so as to complete the updating of the micro-service.
According to the definition, the key element refers to a symbol set between two different versions of the same android application, which may cause the phenomenon of "binary incompatibility" between the microservice corresponding to one version of the application and another version of the android application. The new and old versions of an android application herein are new and old versions of the same android application. The key element screening process mainly aims at screening key elements needing to be analyzed from the micro-service, and comprises the following steps:
step S1: the dex byte code of the micro service is parsed using the visitor pattern, and at the same time, an abstract syntax tree of the dex byte code of the micro service is constructed. The visitor pattern is a design pattern and belongs to a behavior pattern. The visitor model is characterized by the ability to decouple data structures from data operations, thereby addressing the issue of stable data structures and volatile data operations. Because the structure of the dex bytecode is relatively fixed, the structure of the dex bytecode needs to be traversed for several times under different conditions, and new operations need to be added according to requirements to meet the analysis requirements of the dex bytecode under different conditions.
In conjunction with the structure and composition of the dex bytecode, an embodiment of the invention designs a class diagram for parsing a dex file using a visitor pattern as shown in fig. 3. First, the visitor is designed. An abstract class Dex visitor is defined as the base class for the concrete visitor. 4 kinds of concrete visitors are involved in total, and the abstract class Dex visitor r is inherited by the abstract class Dex visitor r, namely a Dex class visitor, a Dex domain visitor, a Dex method visitor and a Dex code visitor. The four types of visitors respectively define the relevant visit functions which are not realized in the abstract class, and the concrete visitors inheriting the abstract classes cover the abstract methods which are not defined, so that different visitors can perform different operations when accessing stable data structures. Next, in order to analyze and extract the key elements, when parsing the dex bytecode using the visitor schema, a stable data structure needs to be defined first. In this context, the defined data structure is an abstract syntax tree structure of the dex bytecode. Defining abstract class node Dex nodes, wherein the constituent nodes of the Dex byte code abstract syntax tree comprise 5 types, and the constituent nodes inherit the abstract class Dex nodes, namely the Dex class nodes, the Dex domain nodes, the Dex method nodes, the Dex code nodes and the Dex statement nodes. The abstract syntax tree of the dex byte code is constructed while the byte code of the dex file is analyzed by using the visitor mode, namely, the definition of the data structure is completed.
The structure of the abstract syntax tree is shown in fig. 4, where the root node of the abstract syntax tree is a Dex file node, and its child nodes are a Dex class node list corresponding to classes in Dex byte codes. And a Dex domain node list and a Dex method node list in the Dex class nodes respectively correspond to member variables and member functions of classes in the Dex byte codes. The child node of the Dex method node is a Dex code node, the word node of the Dex code node is a Dex statement node list, and 20 statements are defined by the Dex byte code corresponding to the statements defined in the Dex byte code.
Step S2: traversing the abstract syntax tree of the Dex byte codes of the micro-service, and adding class names, method names and variable names in domain access statements and function call statements in all the Dex class nodes, Dex domain nodes and Dex method nodes and the Dex code nodes of the abstract syntax tree of the Dex byte codes of the micro-service into a set as key elements influencing the matching between the micro-service and the new edition android application. After the design of the visitor and the definition of the data structure are completed, according to the design principle of the visitor mode, for each node of the abstract syntax tree, an accept method is defined, and the accept method accepts the parameter type of the visitor base class. When the object of a concrete interviewer class is transmitted into the method, the object-oriented language can automatically call the function of the subclass to cover the function of the base class, so that the traversal of the abstract syntax tree is completed, and the effect of different functions is realized in the traversal process. In the following static analysis of the similarity of key elements, the abstract syntax tree is traversed and feature extracted in the same way.
The key element similarity analysis process comprises a key element similarity static analysis process and a key element similarity dynamic analysis process.
And (3) a key element similarity static analysis process: and analyzing the similarity of each key element in the set between the new edition android application and the old edition android application according to the dex byte code of the old edition android application and the dex byte code of the new edition android application.
Specifically, in the static analysis flow of key element similarity, for any key element X in the set, the step of analyzing the similarity between the new version android application and the old version android application includes:
step S1: calculating the first-degree similarity of the key element X between the new-version android application and the old-version android application, wherein the calculation method comprises the following steps:
extracting the intra-element features of the key element X in the new edition of android application and the old edition of android application, and calculating the degree of similarity of the key element X between the new edition of android application and the old edition of android application according to the intra-element features of the key element X in the new edition of android application and the old edition of android application.
Step S2: and judging whether the key element X is a complex element or a simple element, if the key element X is the complex element, taking the first degree similarity as the similarity of the key element X between the new edition of android application and the old edition of android application, and if the key element X is the simple element, entering the step S3.
Step S3: calculating the second-degree similarity of the key element X between the new-version android application and the old-version android application, taking the second-degree similarity as the similarity of the key element X between the new-version android application and the old-version android application, and calculating the second-degree similarity of the key element X between the new-version android application and the old-version android application comprises the following steps:
extracting the inter-element features of the key element X in the new version android application and the old version android application, searching the elements associated with the key element X in the new version android application and the old version android application according to the inter-element features of the key element X in the new version android application and the old version android application, calculating the similarity between the elements associated with the key element X in the new version android application and the elements associated with the key element X in the old version android application, and accordingly obtaining the second-degree similarity between the key element X in the new version android application and the old version android application.
The key element similarity static analysis comprises key element feature extraction and similarity analysis according to the extracted features. In the aspect of key element feature extraction, two types of features of key elements are mainly extracted: intra-element features and inter-element features.
Intra-element features, i.e. some descriptive attributes of the key elements themselves; inter-element features, i.e., relationships between key elements and other key elements. The properties of the key elements are characterized through the two characteristics of the key elements, so that a foundation is laid for judging the similarity of the key elements among different versions. In the following, a class is taken as an example to describe which features are extracted for such key elements as class.
Intra-class features, including:
1) the method comprises the following steps: i.e. how many methods are defined inside the class.
2) Number of instructions: i.e. the internal methods of the class share many instructions. The instruction quantity characteristic and the method quantity characteristic can describe and judge the complexity degree of the class.
3) Instruction type distribution: the dex byte code describes 20 statement types in total, the instruction type distribution characteristics count the distribution conditions of various statement types one by one, and an integer vector is used for recording the characteristics.
4) Number of times the method is internally called: this characteristic reflects the degree of cohesion of the generic method. For each method, it is recorded whether this method is called 1 or 2 times in the method defined by the class itself, respectively. Then, statistics are made on all methods of the class, how many of them are internally called 1 or 2 times.
5) Number of times the method is called by other classes: this feature reflects the degree of coupling of class-wide methods. For each method, the number of times this method is called in the other classes is recorded.
Inter-class features, including:
6) inheritance and implementation relationship: for each class or interface, a record inherits it or implements a list of its classes. This feature describes the relationship between classes.
7) Reference relationship: for each class, a list of other classes that reference its internal methods is recorded.
The similarity analysis is divided into two parts: analysis of first degree similarity and analysis of second degree similarity. As shown in fig. 5, the first degree similarity is defined herein as the similarity between classes themselves; the second degree similarity is defined as a similarity between classes judged by the similarity of classes related to the present class. If two classes correspond to the same class in different versions of the dex bytecode, then the class similarity among the lists of their respective associated two classes will also be very high. Based on the thought, a two-degree similarity method is provided as a supplement to the similarity of the first-degree similarity only comparison class, so as to help improve the accuracy of the similarity analysis of the key elements.
The 7 features extracted for analyzing the similarity of the classes are defined in the foregoing, and from the viewpoint of data types, the 7 features can be classified into two classes, namely, numerical class features and non-numerical class features. The numerical class characteristics can be directly used for similarity calculation, including method number, instruction type distribution, the number of times that the method is called internally and the number of times that the method is called by other classes, and the non-numerical class is used for recording the association with other classes and can not be directly used for calculation, including inheritance and implementation relation and reference relation. For each class, its set of numerical class features is defined as a feature vector of the class.
For numerical class features, a Cosine similarity method is adopted herein to calculate the similarity between feature vectors of two classes, i.e., a degree of similarity between the classes. For example, the feature vector of class a is defined as < a1, a2, a3, a4, a5>, and the feature vector of class B is defined as < B1, B2, B3, B4, B5 >. The Cosine similarity between class a and class B is:
Figure BDA0001785756280000141
for non-numeric class features, a list of classes associated with the class of interest is recorded, and the similarity of classes in the two-by-two list using Cosine similarity, respectively, is used. And then, according to the classes of the old versions, sorting the numerical values of the similarity of the classes in the list in a descending order, selecting the value with the highest similarity to sum, and then normalizing to obtain the second-degree similarity between the classes.
The invention classifies each class according to the complexity thereof into a complex class and a simple class. For complex classes, more accurate judgment can be basically obtained by using the first degree similarity, if the second degree similarity is introduced, not only is the loss brought to the whole in time efficiency, but also the accuracy is possibly reduced due to the addition of interference factors, so that as shown in fig. 6, for complex classes, the first degree similarity is used as the similarity between android applications of new and old versions, and for simple classes, the second degree similarity is used as the similarity between android applications of new and old versions, namely, the similarity of the classes is judged by judging the similarity of the classes associated with the first degree similarity. Thus, when the key element is a complex element, the first degree similarity is used as the similarity between the new version android application and the old version android application of the key element, and when the key element is a simple element, the second degree similarity is used as the similarity between the new version android application and the old version android application of the key element.
The key element similarity dynamic analysis process comprises the following steps: respectively monitoring the application activity condition in the runtime stack models of the new edition of android application and the old edition of android application by utilizing the internetware behavior reflection frame to obtain runtime stack model monitoring results of the new edition of android application and the old edition of android application; and analyzing the similarity of each key element in the set between the new edition android application and the old edition android application according to the runtime stack model monitoring result of the new edition android application and the old edition android application.
In the dynamic analysis process of the similarity of the key elements, for any key element Y in the set, the step of analyzing the similarity between the new version android application and the old version android application includes:
and calculating the similarity of the key element Y between the new edition of the android application and the old edition of the android application according to the precedence relationship of the activity occurrence time of the key element Y in the application activity. Compared with the static analysis of the similarity of the key elements, the dynamic analysis of the similarity of the key elements is characterized in that the time dependence of application execution is added, namely in a runtime environment, the activities of android applications are completely monitored and recorded through an internetware behavior reflection framework, and the similarity of the key elements between the android applications of new and old versions is calculated by analyzing the sequence of the activity occurrence time of the key elements in the activities. The input of the dynamic analysis process of the similarity of the key elements is the monitoring result of the stack model when the android application of the new and old versions is run and the key elements obtained by the screening process of the key elements, and the output is the similarity relation of the key elements between the android application of the new and old versions.
The dynamic analysis process of the similarity of the key elements needs to use the monitoring result of the stack model when the android application runs. The behavior reflection framework of the application internetware is used for comprehensively monitoring and recording the application activity condition in the stack model during operation, and the state of the memory stack space at a certain moment can be mastered by analyzing the monitoring record, so that the purpose of analyzing the application logic is achieved. The method uses the android application runtime stack model monitoring result to calculate the similarity of key elements in the android application between different versions. The monitoring result is shown in fig. 7, the first step of the stack runtime model is to establish a control flow graph, each control flow corresponds to an execution sequence of a Java thread, and a ControlFlow class is a basic unit of the control flow graph. the thread Id represents a thread Id corresponding to the control flow; the headStartClock and headEndClock represent the start and end timestamps of the thread; duration represents the duration of the control flow. The method represents the operation executed by the control flow, and the internetware behavior reflection framework divides the control flow into 6 types, namely method calling, domain reading operation, domain writing operation, exception throwing, thread hanging and thread awakening; method records the type of control flow and some related information: if the type is method calling, the name of the called method is recorded; if the type is read-write operation of the domain, the name of the operated domain is recorded. args denotes the parameter list of methods and retVal denotes the return type of methods. The subFlows represent the child control flow set of this control flow, and the parentFlow represents the parent control flow of this control flow.
It follows from the definition of the control flow that the control flow is a tree structure. Thus, control flow may be accessed recursively using a depth-first traversal approach. By recording the process information in the course of the recursive access, the hierarchical information of each node can be obtained. The level information of this node corresponds to the depth of the method in stack space in the stack runtime model.
When the application calls the function, the system automatically allocates a block of space for the application in the stack space, and records the frame pointer and the stack pointer of the function by using the register. If a new function call occurs in the function call process, the system stores context information of application operation in a mode of recording a return address on a stack; then, carrying out space allocation and function statement execution of new function call; and after the execution of the new function is finished, restoring the context information through the return address, and returning to the stack space of the original function again to continue the execution.
Therefore, the depth in the stack space can reflect the context of the method call and the precedence relationship of the call, and is very important runtime information. The method mainly utilizes the stack depth of the method as the characteristic of dynamic analysis, and assists information such as function signature of the method to carry out similarity matching of key elements. For each method, when the monitoring result is analyzed, a stack depth sequence S is recorded, the stack depth sequence reflects the context situation of the stack space when the function is executed, and the time sequence reflects the time sequence of the occurrence of the context situation.
The invention adopts the minimum cost maximum flow algorithm to calculate the similarity of key elements between the android applications of the new version and the old version. The structure diagram of the minimum cost maximum flow is shown in fig. 8, and the following will first briefly describe the meaning of each component of the network flow around the minimum cost maximum flow algorithm, then describe the rationality of the algorithm, and finally give the result of the operation of the algorithm and the corresponding meaning.
Source and sink: the starting point and the ending point of the network flow need to continuously find a path between the source point and the sink point, which can increase the flow of the network flow.
The old method node: each old method corresponds to a node, and each old method node is respectively connected with the source node and each new method node; in addition, each old method node is also connected to a sink.
The new method comprises the following steps: each new method corresponds to a node, and each new method node is connected with a sink and each old method node respectively.
Side capacity: the capacity of the network flow edge represents how many nodes are accepted as similar. The capacity of the edge from the source point and the edge from the sink point is n, and n is a value set manually, namely the number of nodes in the list of the recommended similar new methods, which is finally obtained by the framework through network flows for a certain old method. The capacity of the edge between the new node and the old node is 1, which means that each old method can be matched with the new method only once.
The cost of the edge: the edge between the old and new methods, cost s, represents the similarity of the old and new methods, where if the similarity is lower, it means that the two points are more similar. The cost between the source and old method nodes and between the new method node and the sink is 0. In addition, there is a connecting edge between each old method and the sink, and the capacity of the edge is the set cost threshold t.
In the following, the contents and the rationality of the min-cost max-flow algorithm will be briefly described. Adopting greedy thought, finding a path from a source point to a sink point to increase flow when an algorithm is executed each time; and satisfying the path minimizes the cost of increased traffic; until no more path can be found from the source to the sink, the algorithm ends. Because the maximum flow has an upper limit and the flow is increased every time the algorithm is executed, the algorithm is definitely ended and the maximum flow of the network is reached; since each time a greedy idea is used, the minimum cost is added, so at the end of the algorithm, the minimum cost is the minimum of all costs to reach the current traffic.
Since there is an edge from each old method node to the sink that costs a threshold t, if the similarity of an old method node to all new method nodes is greater than the threshold t, the least-cost-max flow algorithm will choose to flow directly from the old method node to the sink.
From this, the result obtained after running this algorithm can be derived: if n is set to 3, in the minimum cost maximum flow network generated finally, there are less than or equal to 3 new method nodes connected to each old method node, which means that the similarity degree between the new method nodes and the old method nodes is the highest in the global.
Note that, because the edge between the old method node and the sink exists, there may be a case where the old method node is not connected to any new method node, and this case indicates that the old method node does not find a new method node matching with the old method node.
The destructive change judgment process includes:
the method comprises the steps of operating the micro-service on a new edition of android application, judging that the android application does not have destructive change relative to the micro-service after being changed from an old edition to a new edition if an obtained return value is the same as a return value obtained when the micro-service is operated on an old edition of android application, and judging that the destructive change relative to the micro-service occurs after the android application is changed from the old edition to the new edition if the phenomenon that the micro-service throws out abnormity, cannot be operated or a returned result is incorrect.
The main function of the destructive change judging process is to judge whether the change of the android application version causes the problem of 'binary incompatibility' between the micro service of the old version and the android application of the new version. Three main flows of the application layer: the destructive change judgment process, the key element positioning process to be modified and the key element modification scheme recommendation process have strong relevance. A flowchart of the application layer as a whole is shown in fig. 9. The new version android application and the old version microservice are first input into a destructive change judgment flow. If the new version android application has not undergone a destructive version update, the process ends. Otherwise, entering a key element positioning process needing to be modified. Inputting analysis results obtained by the static analysis process and the dynamic analysis process into a key element positioning process to be modified, and judging whether all key elements obtained in the key element screening process need to be modified one by one. If no modification is needed, the loop continues; and if the modification is needed, entering a key element modification scheme recommendation flow.
The design idea of the destructive change judgment flow is more intuitive: the method comprises the steps that an old version of micro-service is operated on a new version of android application, and if a return value which is the same as that of the old version of android application is obtained, the version change of the android application is non-destructive; otherwise, if the phenomenon that the micro-service throws an exception, cannot run or the returned result is incorrect occurs, the version change of the android application is destructive. This completes the first objective of the present document: the possibility that the change occurring in the version change is a non-destructive change is judged.
In the key element positioning process to be modified, for any key element Z in the set, the process of judging whether destructive change occurs to the micro service after the android application is changed from the old version to the new version includes:
calculating expected e1 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity static analysis process;
calculating expected e2 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity dynamic analysis process;
and when e1< t1 and e2< t2 are satisfied, determining that the key element Z is destructively changed relative to the microservice after the android application is changed from the old version to the new version, and otherwise determining that the key element Z is not destructively changed relative to the microservice after the android application is changed from the old version to the new version.
The key idea of the key element positioning process to be modified is to judge whether the key element is changed in the version change by a class name, a method name or a variable name. If the key elements in the old version and the new version of the android application contain the elements with the same names in the output results of the static analysis process and the dynamic analysis process, the elements with higher similarity have lower possibility of needing to be modified when the elements are subjected to destructive change, and otherwise, the elements have higher possibility of needing to be modified when the elements are subjected to destructive change. The key of the process is: for a certain key element in the old edition android application, the expectation that the change of the android application is non-destructive is calculated.
For a certain key element in the old edition of android application, the analysis layer gives a score of the similarity of the similar element in the new edition of android application. The dynamic analysis process gives a limited set of similar elements, and the static analysis process gives a similarity score between all elements in the new version of android application and the key elements in the old version of android application. And the result given by the dynamic analysis process is easy to judge. In the above description, the minimum cost and maximum cost network flow design used in the dynamic analysis is introduced, where the edge capacity from the source point to the old method node is n, which means that after the operation of the network flow algorithm is finished, there are new method nodes less than or equal to n, and the new method nodes are connected with the old method node, and these nodes are the new method recommendation list closest to the old method node obtained after the operation of the network flow algorithm is finished. For any old method node m, because the lower the cost among the nodes in the dynamic analysis process, the higher the similarity among the nodes, the cost of the new method list matched with the nodes is sorted in an increasing order, and the new method list matched with the old method node is recorded as follows:
M={m1,m2,m3,…,mn}
in addition, a distribution is set:
F={p1,p2,p3,…,pn}
if m ═ mi (i ∈ {1,2, …, n }) exists, the expectation is taken that the process element may undergo non-destructive changes:
e=pi*1
otherwise, note that the expectation that the method element may undergo a non-destructive change is 0.
Secondly, for the results given by the static analysis, the expectation of the destructive change of the element can be calculated by adopting a similar method. But one problem needs to be solved first: because the dynamic analysis flow limits the length of the new element list matched with the elements in the old version android application by depending on the network flow n, all the obtained new elements have certain similarity with the elements in the old version android application. However, static analysis matches all elements of the new version of the android application with elements of the old version of the android application and finds similarity, which is inefficient; also, in fact, for a similar list of elements, the likelihood of a change to a non-destructive change occurring decreases sharply as the ordering of the similarity increases. Thus, it is not necessary to analyze and match all elements of the new version of the android application. Firstly, a new version element list for matching needs to be selected, then, calculation can be carried out by adopting the same method as dynamic analysis, and from the result of static analysis, the expectation that key elements are subjected to nondestructive change is carried out. Finally, the expectations obtained by the static analysis process and the dynamic analysis process can be integrated by using a certain weight to obtain the final result that the change of the element is expected by the nondestructive change.
Finally, a determination needs to be made as to whether the element needs to be modified in conjunction with the expectation that it will undergo a destructive change. For any key element that needs to be matched, the expectation of non-destructive change in the static analysis is recorded as e1, and the expectation of non-destructive change in the dynamic analysis is recorded as e 2. In the android application key element difference analysis framework, the threshold for judging the nondestructive change of the element is t1, and in the dynamic analysis, the threshold for the nondestructive change of the element is t 2. If e1< t1 and e2< t2 are satisfied, then the element is determined to have a destructive change, which needs to be modified in the next flow. Therefore, the element is added into the element list to be modified, and after the method is operated on all the elements, the integrally output list is the element list to be modified in the old version android application.
In the key element modification scheme recommendation process, for any key element c needing to be modified in the micro-service, the process of giving a modification recommendation list comprises the following steps:
calculating the similarity between all key elements in the new edition of android application and the key elements c in the old edition of android application;
arranging all key elements in the new edition android application according to the sequence of similarity from high to low to obtain a set C ═ { C1, C2, C3, …, cn }, and arranging the calculated similarities from high to low to obtain a set S ═ S1, S2, S3, …, sk, …, sn };
forming a first list of the first k key elements in the set C, wherein (s1-sk)/s1<, which is a preset critical value;
in the minimum-cost maximum network flow, setting the capacity of element nodes starting from a source point to each old version of android application as n, and forming a second list by using key elements which are less than or equal to n and have the highest similarity with the key element c in the new version of android application;
and combining the first list with the second list to form a modified recommendation list.
For the element c in any old version of android application, the static analysis flow gives out the result that all similar elements in the new version of android application have the similarity with the element. Because the static analysis process mainly matches the similarity of the elements according to some static characteristics of the elements, it is difficult to determine how many elements have characteristics very similar to the elements in the new version of the android application. Therefore, the method of fixing the length of the list is not adopted, otherwise the recall rate of the method can be reduced rapidly. The length of the new method recommendation list needs to be dynamically adjusted according to the distribution of the similarity. For an element c in any old version android application, calculating the similarity between all elements in the new version android application and the element c in the old version android application, and after the similarity is arranged in a descending order, recording the set as:
C={c1,c2,c3,…,cn}
the set of similarity values is:
S={s1,s2,s3,…,sn}
since the higher the value of the similarity is in the static analysis process, the more likely it is that non-destructive changes occur, the recommendation list obtained by the recommendation process is a set of the first k elements of the set C, where k is the largest positive integer that satisfies the following formula:
(s1-sk)/s1<
which is a defined threshold value that needs to be adjusted to the most appropriate value according to the actual usage scenario. A new set of elements matching element c in the old version of the android application in the static analysis flow is obtained:
C'={c1,c2,c3,…,ck}
the result of the dynamic analysis is easier to understand. In the minimum-cost maximum network flow, the capacity from a source point to each old version android application element node is set to be n, and then the fact that for each old version android application element node, n or less new versions of android application elements have the highest similarity with the old version android application element node is shown. Then the list with the length less than or equal to n is the recommendation result of the recommendation flow. The size of n can be dynamically adjusted as needed to achieve the desired accuracy and recall.
And the modification recommendation of the key elements is completed by combining the similar element list obtained by the dynamic analysis process and the static analysis process. For the elements to be modified, the key element modification scheme recommendation flow in the method can only give a recommendation list of modification schemes, and cannot directly give accurate modification elements; but the modification of the recommendation list can assist programmers in improving the efficiency of upgrading the micro-services, and because the list is limited, the micro-services can be automatically upgraded by adopting a mode of traversing the list and assisting with an automatic test method of the micro-services.
As shown in fig. 10, an embodiment of the present invention further provides a micro service update system based on differential analysis of key elements, which is used for implementing each process in the micro service update method based on differential analysis of key elements, and includes:
the key element screening module 1 is used for analyzing byte codes in the micro-service matched with the old version of the android application and screening out a set of all key elements influencing the matching between the micro-service and the new version of the android application;
a key element similarity analysis module 2, configured to analyze a similarity between the new version of android application and the old version of android application of each key element in the set;
the destructive change judging module 3 is used for judging whether destructive change occurs on the android application relative to the microservice after the android application is changed from the old version to the new version;
a key element positioning module 4 to be modified, configured to, when the android application is changed from the old version to the new version and is destructively changed with respect to the micro-service, determine, according to a similarity between the new version of the android application and the old version of the android application, whether each key element in the set is destructively changed with respect to the micro-service after the android application is changed from the old version to the new version, and use the key element that is destructively changed as a key element to be modified in the micro-service;
a key element modification scheme recommending module 5, configured to provide a modification recommendation list for each key element that needs to be modified in the micro-service according to a similarity between the new version of the android application and the old version of the android application of each key element, where the modification recommendation list includes a preset number of key elements that are the highest in similarity between each key element in the new version of the android application and the key element that needs to be modified in the micro-service;
and the micro-service updating module 6 is used for modifying each key element needing to be modified in the micro-service into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified so as to finish the updating of the micro-service.
The modules correspond to the processes in the micro-service updating method based on the difference analysis of the key elements, and are used for implementing the processes in the micro-service updating method based on the difference analysis of the key elements, and the working principle, the working process and the like of each module can refer to the description of each process in the micro-service updating method based on the difference analysis of the key elements, and are not described herein again.
The above-described embodiments are merely preferred embodiments, which are not intended to limit the scope of the present invention, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (9)

1. A micro-service updating method based on differential analysis of key elements is characterized by comprising the following steps:
key element screening process: analyzing byte codes in the micro-service matched with the old edition of android application, and screening out a set of all key elements influencing the matching between the micro-service and the new edition of android application;
and (3) key element similarity analysis flow: analyzing similarity between the new version android application and the old version android application of each key element in the set;
destructive change judgment flow: judging whether destructive change occurs to the micro-service or not after the android application is changed from the old version to the new version;
the key element positioning process needing to be modified comprises the following steps: when the android application is changed from the old version to the new version and is destructively changed relative to the micro-service, judging whether each key element in the set is destructively changed relative to the micro-service after the android application is changed from the old version to the new version according to the similarity between the key elements in the new version and the old version of the android application, and taking the destructively changed key element as a key element needing to be modified in the micro-service;
the key element modification scheme recommendation process comprises the following steps: according to the similarity of each key element between the new edition of android application and the old edition of android application, giving a modification recommendation list to each key element needing to be modified in the micro service, wherein the modification recommendation list comprises a preset number of key elements with the highest similarity with the key element needing to be modified in the micro service in each key element in the new edition of android application;
and (3) micro-service updating flow: and for each key element needing to be modified in the micro-service, modifying the key element needing to be modified into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified, so as to finish the updating of the micro-service.
2. The micro-service updating method based on differential analysis of key elements according to claim 1, wherein the key element screening process comprises:
step S1: analyzing the dex byte code of the micro service by using a visitor mode, and constructing an abstract syntax tree of the dex byte code of the micro service;
step S2: traversing the abstract syntax tree of the Dex byte codes of the micro-service, and adding all the Dex class nodes, Dex domain nodes, Dex method nodes in the abstract syntax tree of the Dex byte codes of the micro-service and the class names, the method names and the variable names in the domain access statements and the function call statements in the Dex code nodes into the set as key elements influencing the matching between the micro-service and the new edition android application.
3. The micro-service updating method based on differential analysis of key elements as claimed in claim 2, wherein the key element similarity analysis process comprises:
and (3) a key element similarity static analysis process: analyzing the similarity of each key element in the set between the new edition of android application and the old edition of android application according to the dex bytecode of the old edition of android application and the dex bytecode of the new edition of android application;
the key element similarity dynamic analysis process comprises the following steps: respectively monitoring the application activity condition in the runtime stack models of the new edition of android application and the old edition of android application by utilizing an internetware behavior reflection frame to obtain runtime stack model monitoring results of the new edition of android application and the old edition of android application; and analyzing the similarity of each key element in the set between the new edition android application and the old edition android application according to the monitoring result of the stack model when the new edition android application and the old edition android application run.
4. The key-element-difference-analysis-based micro-service updating method according to claim 3, wherein in the key-element-similarity static analysis process, for any key element X in the set, the step of analyzing the similarity between the new version android application and the old version android application comprises:
step S1: calculating the first-degree similarity of the key element X between the new-version android application and the old-version android application, wherein the calculation method comprises the following steps:
extracting the intra-element features of a key element X in the new edition of android application and the old edition of android application, and calculating the degree of similarity of the key element X between the new edition of android application and the old edition of android application according to the intra-element features of the key element X in the new edition of android application and the old edition of android application;
step S2: judging whether the key element X is a complex element or a simple element, if the key element X is the complex element, taking the first degree of similarity as the similarity of the key element X between the new version android application and the old version android application, and if the key element X is the simple element, entering the step S3:
step S3: calculating the second-degree similarity of a key element X between the new-version android application and the old-version android application, taking the second-degree similarity as the similarity of the key element X between the new-version android application and the old-version android application, and calculating the second-degree similarity of the key element X between the new-version android application and the old-version android application comprises the following steps:
extracting inter-element features of a key element X in the new version android application and the old version android application, searching elements associated with the key element X in the new version android application and the old version android application according to the inter-element features of the key element X in the new version android application and the old version android application, calculating similarity between the elements associated with the key element X in the new version android application and the elements associated with the key element X in the old version android application, and accordingly obtaining the second degree similarity between the key element X in the new version android application and the old version android application.
5. The key-element-difference-analysis-based micro-service updating method according to claim 3, wherein the step of analyzing the similarity between the new version android application and the old version android application for any key element Y in the set in the key-element-similarity dynamic analysis process comprises:
and calculating the similarity of the key element Y between the new edition of android application and the old edition of android application according to the precedence relationship of the activity occurrence time of the key element Y in the application activity.
6. The micro-service updating method based on differential analysis of key elements according to claim 1, wherein the destructive change judgment process comprises:
and running the micro-service on the new version android application, if the obtained return value is the same as the return value obtained when the micro-service runs on the old version android application, judging that the android application is changed from the old version to the new version and is not destructively changed relative to the micro-service, and if the phenomenon that the micro-service throws out abnormity, cannot run or the returned result is incorrect, judging that the android application is changed from the old version to the new version and is destructively changed relative to the micro-service.
7. The key-element-difference-analysis-based micro-service updating method according to claim 3, wherein in the key-element-to-be-modified locating process, for any key element Z in the set, the process of determining whether a destructive change occurs to the micro-service after the android application changes from an old version to a new version comprises:
calculating expected e1 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity static analysis process;
calculating expected e2 of the key element Z undergoing nondestructive change according to the analysis result of the key element similarity dynamic analysis process;
when e1< t1 and e2< t2 are satisfied, determining that a destructive change occurs on a key element Z relative to the microservice after the android application changes from an old version to a new version, and otherwise determining that the key element Z is not destructively changed on the microservice after the android application changes from the old version to the new version;
wherein t1 is a threshold for judging non-destructive change of an element in static analysis; t2 is a threshold for determining non-destructive changes in elements in dynamic analysis.
8. The micro-service updating method based on key element difference analysis according to claim 3, wherein the process of giving the modification recommendation list to any key element c needing to be modified in the micro-service in the key element modification scheme recommendation process comprises:
calculating the similarity between all key elements in the new edition of android application and the key elements c in the old edition of android application;
arranging all key elements in the new edition android application according to the sequence of similarity from high to low to obtain a set C ═ { C1, C2, C3, …, cn }, and arranging the calculated similarities from high to low to obtain a set S ═ S1, S2, S3, …, sk, …, sn };
forming a first list of the first k key elements in the set C, wherein (s1-sk)/s1<, which is a preset critical value;
in the minimum-cost maximum network flow, setting the capacity of element nodes starting from a source point to each old version of android application as n, and forming a second list by using key elements which are less than or equal to n and have the highest similarity with the key element c in the new version of android application;
combining the first list with the second list to form the modified recommendation list.
9. A key-element-variability-analysis-based micro-service updating system for implementing each process in the key-element-variability-analysis-based micro-service updating method according to claim 1, comprising:
the key element screening module is used for analyzing byte codes in the micro-service matched with the old version android application and screening out a set of all key elements influencing the matching between the micro-service and the new version android application;
a key element similarity analysis module for analyzing the similarity between the new version of android application and the old version of android application of each key element in the set;
the destructive change judging module is used for judging whether destructive change occurs on the micro-service or not after the android application is changed from the old version to the new version;
a key element positioning module to be modified, configured to, when the android application changes from an old version to a new version and is destructively changed with respect to the micro-service, determine, according to a similarity between the new version android application and the old version android application of each key element, whether each key element in the set is destructively changed with respect to the micro-service after the android application changes from the old version to the new version, and use the destructively changed key element as a key element to be modified in the micro-service;
a key element modification scheme recommending module, configured to provide a modification recommendation list for each key element that needs to be modified in the micro-service according to a similarity between the new version of the android application and the old version of the android application of each key element, where the modification recommendation list includes a preset number of key elements that are the highest in similarity between each key element in the new version of the android application and the key element that needs to be modified in the micro-service;
and the micro-service updating module is used for modifying each key element needing to be modified in the micro-service into one key element in the modification recommendation list according to the modification recommendation list given to the key element needing to be modified so as to finish the updating of the micro-service.
CN201811014183.7A 2018-06-22 2018-08-31 Micro-service updating method and system based on difference analysis of key elements Active CN109117164B (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810651406 2018-06-22
CN2018106514064 2018-06-22

Publications (2)

Publication Number Publication Date
CN109117164A CN109117164A (en) 2019-01-01
CN109117164B true CN109117164B (en) 2020-08-25

Family

ID=64861577

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811014183.7A Active CN109117164B (en) 2018-06-22 2018-08-31 Micro-service updating method and system based on difference analysis of key elements

Country Status (1)

Country Link
CN (1) CN109117164B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110780897B (en) * 2019-08-26 2022-05-10 华为云计算技术有限公司 Code changing method and device
CN110995855B (en) * 2019-12-13 2022-06-21 深圳先进技术研究院 Microservice cluster scheduling method, scheduling device and computer readable storage medium
CA3123916C (en) 2020-03-26 2023-03-14 Citrix Systems, Inc. Microapp functionality recommendations with cross-application activity correlation
WO2021203403A1 (en) 2020-04-10 2021-10-14 Citrix Systems, Inc. Microapp subscription recommendations
US11553053B2 (en) * 2020-04-16 2023-01-10 Citrix Systems, Inc. Tracking application usage for microapp recommendation
US11314630B1 (en) 2020-12-14 2022-04-26 International Business Machines Corporation Container configuration recommendations
US11797623B2 (en) 2021-12-09 2023-10-24 Citrix Systems, Inc. Microapp recommendations for networked application functionality
CN115733750A (en) * 2022-11-25 2023-03-03 中国工商银行股份有限公司 Method, device, equipment and storage medium for updating metadata in micro-service gateway

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473104A (en) * 2013-09-24 2013-12-25 北京大学 Method for discriminating re-package of application based on keyword context frequency matrix
CN105893848A (en) * 2016-04-27 2016-08-24 南京邮电大学 Precaution method for Android malicious application program based on code behavior similarity matching
CN107729042A (en) * 2017-10-16 2018-02-23 东软集团股份有限公司 Mobile solution upgrade method and device, storage medium, electronic equipment
KR101857001B1 (en) * 2017-03-03 2018-05-14 숭실대학교산학협력단 Android dynamic loading file extraction method, recording medium and system for performing the method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473104A (en) * 2013-09-24 2013-12-25 北京大学 Method for discriminating re-package of application based on keyword context frequency matrix
CN105893848A (en) * 2016-04-27 2016-08-24 南京邮电大学 Precaution method for Android malicious application program based on code behavior similarity matching
KR101857001B1 (en) * 2017-03-03 2018-05-14 숭실대학교산학협력단 Android dynamic loading file extraction method, recording medium and system for performing the method
CN107729042A (en) * 2017-10-16 2018-02-23 东软集团股份有限公司 Mobile solution upgrade method and device, storage medium, electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于关键元素的流量矩阵分析研究;严晋如;《中国优秀硕士学位论文全文数据库信息科技辑》;20131215(第S2期);第I139-34页 *

Also Published As

Publication number Publication date
CN109117164A (en) 2019-01-01

Similar Documents

Publication Publication Date Title
CN109117164B (en) Micro-service updating method and system based on difference analysis of key elements
CN107704265B (en) Configurable rule generation method for service flow
US10162610B2 (en) Method and apparatus for migration of application source code
CN107644323B (en) Intelligent auditing system for business flow
US8516443B2 (en) Context-sensitive analysis framework using value flows
CN109189469B (en) Reflection-based android application micro-servitization method and system
JP2020522790A (en) Automatic dependency analyzer for heterogeneously programmed data processing systems
US20240045850A1 (en) Systems and methods for database orientation transformation
EP3674918A2 (en) Column lineage and metadata propagation
Habchi et al. Code smells in ios apps: How do they compare to android?
CN111913713B (en) Heterogeneous service integration method based on service call tracing
US10514898B2 (en) Method and system to develop, deploy, test, and manage platform-independent software
WO2018222327A1 (en) Automated or machine-enhanced source code debugging
Rossini et al. The cloud application modelling and execution language (CAMEL)
Graham et al. A software design and evaluation system
CN103186463A (en) Method and system for determining testing range of software
Hentschel et al. An interactive verification tool meets an IDE
CN109284222B (en) Software unit, project testing method, device and equipment in data processing system
CN109299004B (en) Method and system for analyzing difference of key elements
Falleri et al. Incremental inconsistency detection with low memory overhead
US7647581B2 (en) Evaluating java objects across different virtual machine vendors
Criado et al. Heuristics-based mediation for building smart architectures at run-time
Kang et al. Automating program transformation for Java using semantic patches
CN115794214A (en) Application module metadata management method, device, storage medium and device
US11442845B2 (en) Systems and methods for automatic test generation

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