Program processing method, system, apparatus, and electronic device
Patent Information
- Application Number
- CN202310188817.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2026-09-08
- Estimated Expiration
- 2043-02-21
AI Technical Summary
[0005]本发明实施例提供了一种程序处理方法、系统、装置及电子设备,以至少解决相关技术中依赖于开发改造、预先部署代码的方式动态影响运行中的程序造成的人力成本高的技术问题
[0017] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described program processing method at runtime.
Smart Images

Figure CN116166559B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of cloud computing, and more specifically, to a program processing method, system, apparatus, and electronic device. Background Technology
[0002] Adapting to changes, responding to requirements, and pursuing the latest security strategies are the current expectations of relevant industries (such as financial institutions and the internet) for software programs. This requires software testers and security personnel to respond to requirement changes more quickly, construct test scenarios and complete tests more quickly, and handle urgent events such as zero-day vulnerabilities more quickly. However, currently, for testers and security personnel, the program running in the environment is a complete black box. They cannot obtain the memory attribute state of the classes and methods that the program is actually executing, and they cannot quickly exert dynamic influence on the classes and methods of the program running in the environment according to testing and security requirements.
[0003] In related technologies, the only ways to address memory-level changes in program parameters, such as changes to class and method attribute values, dynamic scanning and querying of class attributes during runtime, are through development support, pre-deployed code, and static scanning. For example, adding temporary logs to provide information to testing and security personnel, developing a configuration center to configure some configuration attributes so testers can modify certain configuration items in real time, and allowing configuration scanning features to quickly respond to security requirements lead to high labor costs and inconsistent results in meeting the need to operate on running programs.
[0004] There is currently no effective solution to the above problems. Summary of the Invention
[0005] This invention provides a program processing method, system, device, and electronic device to at least solve the technical problem of high human resource costs caused by relying on the development, modification, and pre-deployment of code to dynamically influence running programs in related technologies.
[0006] According to one aspect of the present invention, a program processing method is provided, which is applied to a target execution tool installed in a target program. The method includes: performing reverse proxy on memory objects in the method area of a target memory block to obtain a list of loaded classes of the target program currently running in memory, wherein the target memory block is a memory block occupied by the target program in memory; obtaining operation information of operations to be performed on the loaded class list; and performing target operation content on the loaded class list according to the operation information.
[0007] Furthermore, the target operation includes at least one of the following: initializing a class instance, modifying a class variable, querying a class attribute value, executing a class method, modifying an object variable, querying an object variable, or executing an object method.
[0008] Furthermore, the program processing method also includes: obtaining at least one operation step contained in the operation information, wherein each operation step includes an operation subject and an operation content, the operation subject being one of the following: class, object, and the operation content in at least one operation step constituting the target operation content; when the number of at least one operation step is equal to 1, extracting the operation subject and operation content in the current operation step, and executing the operation content on the operation subject in the loaded class list.
[0009] Furthermore, the program processing method also includes: after obtaining at least one operation step contained in the operation information, when the number of at least one operation step is greater than or equal to 2, determining whether each operation step has a parent operation step, obtaining the dependency information of each operation step, wherein the execution of the operation step depends on the parent operation step, and the dependency information is used to record the parent operation step of the operation step; determining the operation order of at least one operation step according to the dependency information of each operation step; extracting the operation subject and operation content in the current operation step according to the operation order, and executing the operation content on the operation subject in the loading class list.
[0010] Furthermore, the program processing method also includes: for each operation step, after extracting the operation subject and operation content in the current operation step, and executing the operation content on the operation subject in the loaded class list, determining whether there is first information in the current operation step, wherein the first information represents saving the operation result of the current operation step; if the first information exists in the current operation step, saving the operation result to the target storage area in memory; determining whether the current operation step is the last executed operation step; if it is determined that the current operation step is the last executed operation step, sending all operation results in the target storage area to the target platform, wherein the target platform displays the operation results.
[0011] Furthermore, the program processing method also includes: for each operation step, after extracting the operation subject and operation content in the current operation step and executing the operation content on the operation subject in the loading class list, determining whether there is second information representing updating the loading class list in the current operation step; if there is second information in the current operation step, updating the content of the loading class list based on the operation result of the current operation step.
[0012] Furthermore, before performing reverse proxy on the memory objects in the method area of the target memory block, the tool installer checks whether the target execution tool is installed in the target program. If the target execution tool is detected to be installed in the target program, the operation information is sent to the target execution tool. If the target execution tool is not detected to be installed in the target program, an installation request is sent to the target programming interface of the memory. The target programming interface is used to install the target execution tool in the target program according to the installation request.
[0013] According to another aspect of the present invention, a program processing system is also provided, comprising: a target platform, configured to acquire operation information on operations to be performed on a loaded class list, and send the operation information to a tool installer; a tool installer, configured to acquire the operation information, and, if it is detected that a target execution tool has been installed in the target program, send the operation information to the target execution tool; and a target execution tool, configured to execute the above-described program processing method.
[0014] Furthermore, the target execution tool includes a liveness detection module. The tool installer sends a liveness detection request to the liveness detection module and detects whether the target execution tool is installed in the target program based on the response result of the liveness detection request.
[0015] Furthermore, the tool installer is used to send an installation request to the target programming interface in the memory where the target program resides when it is detected that the target execution tool is not installed in the target program, wherein the target programming interface is used to install the target execution tool in the target program according to the installation request.
[0016] According to another aspect of the present invention, a program processing apparatus is also provided, comprising: a processing module, configured to perform reverse proxy on memory objects in the method area of a target memory block to obtain a list of loaded classes of a target program running in memory, wherein the target memory block is a memory block occupied by the target program in memory; an acquisition module, configured to acquire operation information of an operation to be performed on the loaded class list; and a first execution module, configured to execute target operation content on the loaded class list according to the operation information.
[0017] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described program processing method at runtime.
[0018] According to another aspect of the present invention, an electronic device is also provided, the electronic device including one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors are configured to run the programs, wherein the programs are configured to execute the above-described program processing method during runtime.
[0019] In this embodiment of the invention, operations on a running target program are achieved by manipulating a list of loaded classes. This is done by performing reverse proxy on memory objects in the method area of the target memory block to obtain the list of loaded classes of the running target program in memory. Then, operation information for operations to be performed on the loaded class list is obtained, and the target operation content is executed on the loaded class list according to the operation information. The target memory block refers to the memory block occupied by the target program in memory.
[0020] In the above process, by performing reverse proxy on the memory objects in the method area of the target memory block, the list of loaded classes of the target program currently running in memory is obtained. This allows the maintenance list of loaded classes in the entire memory block, which is not exposed by JVMTI, to be provided to the target execution tool. By executing target operations on the loaded class list according to the operation information, the target operations are executed on the running target program, thereby realizing the operation of the running target program and achieving dynamic influence on the running target program, thus reducing labor costs.
[0021] Therefore, the solution provided in this application achieves the goal of manipulating the list of loaded classes to operate on the target program in operation, thereby reducing the technical effect of manpower costs. It also solves the technical problem of high manpower costs caused by relying on development, modification, and pre-deployment of code to dynamically affect the running program in related technologies. Attached Figure Description
[0022] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0023] Figure 1 This is a schematic diagram of an optional program processing method according to an embodiment of the present invention;
[0024] Figure 2 This is a schematic diagram of an optional program processing system according to an embodiment of the present invention;
[0025] Figure 3 This is a schematic diagram of the operation of an optional program processing system according to an embodiment of the present invention;
[0026] Figure 4 This is a schematic diagram of an optional program processing device according to an embodiment of the present invention;
[0027] Figure 5 This is a schematic diagram of an optional electronic device according to an embodiment of the present invention. Detailed Implementation
[0028] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0029] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0031] Example 1
[0032] According to an embodiment of the present invention, an embodiment of a program processing method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0033] Figure 1 This is a schematic diagram of an optional program processing method according to an embodiment of the present invention, such as... Figure 1 As shown, this method is applied to a target execution tool, which is installed in the target program. The method includes the following steps:
[0034] Step S101: Perform reverse proxy on the memory objects in the method area of the target memory block to obtain the list of loaded classes of the target program running in memory, where the target memory block is the memory block occupied by the target program in memory.
[0035] Optionally, the aforementioned target program is a Java program that runs in the JVM (Java Virtual Machine). Multiple Java programs are allowed to run in the Java Virtual Machine. Each instance of a Java program occupies a portion of the memory used by the Java Virtual Machine, and the memory block occupied by each instance is private to that instance. In the memory block of that instance, there is a method area used to store the classes loaded by that instance.
[0036] In this embodiment, the program corresponding to the target execution tool is loaded into the target program, thereby achieving the installation of the target execution tool within the target program. Specifically, the target execution tool includes a hot-call dynamic stub, an adapter class, a stub class, and a logic tree parsing execution module. The hot-call dynamic stub is an agent implemented using bytecode technology. When the agent is loaded into the target program using JVMTI, it loads the adapter class, stub class, and logic tree parsing execution module into the target program. JVMTI is an unconventional technology in Java, a native programming interface provided by the Java Virtual Machine (JVM), often simply referred to as the JVM Tool Interface. It acts as a backdoor to the JVM, allowing communication with the JVM.
[0037] Furthermore, when JVMTI starts, the adapter class performs reverse proxy on the memory objects in the method area of the target memory block to obtain the list of loaded classes of the target program running in memory, and sends the list of loaded classes to the stub class. This allows the adapter pattern to provide the stub class with the maintenance list of loaded classes in the entire memory block that JVMTI does not expose to the outside world.
[0038] It should be noted that by performing reverse proxy on the memory objects in the method area of the target memory block, the list of loaded classes of the target program currently running in memory is obtained. This enables the JVMTI to provide the maintenance list of loaded classes in the entire memory block, which is not exposed to the outside, to the target execution tool. This facilitates the target execution tool to modify, query, and call methods of the target program in real time, and also enables the target execution tool to dynamically influence the target program.
[0039] Step S102: Obtain operation information for the operations to be performed on the loaded class list.
[0040] Optionally, staff can pre-fill an operation form (i.e., the aforementioned operation information) on the front end. This operation information records the operations to be performed on the running target program. The operation information includes at least one operation step, and each operation step includes an operation subject and operation content. Optionally, in this embodiment, each operation step includes, but is not limited to, the following: the name of the current operation step, the name of the parent operation step, the current operation subject, the current operation content, whether the operation result of the current operation step needs to be saved, and whether the loaded class list needs to be refreshed. The operation subject can be a class or an object. The object is the object returned after the parent operation step is executed. When the operation subject is a class, the operation content can be initializing a class instance, modifying class variables, querying class variable values, or executing class methods. When the operation subject is an object, the operation content can be modifying object member variables, querying object member variable values, or executing object methods.
[0041] Furthermore, for different operation contents, the parameters required to execute the operation content also need to be filled in the operation information. For example, if the operation content is to initialize a class instance, the input parameter type and input parameter value of the initialization method need to be filled in. If the operation content is to execute a class method or execute an object method, the method name, method input parameter type, and input parameter method need to be filled in. If the operation content is to query object member variables and query class variables, the variable name needs to be filled in. If the operation content is to modify object member variables and modify class variables, the variable name and the value to be modified need to be filled in.
[0042] Once the operation information is determined, it can be persisted to the database as a hot-access asset. When the operation information is needed, staff can retrieve it from the database using the target platform and send it to the stub class for the stub class to access. The stub class starts a socket service to implement real-time task reception and liveness detection services. The real-time task reception service relies on the stub class and implements a first socket interface, which waits for external calls to receive operation information for dynamic memory modification. The liveness detection service relies on the stub class and implements a second socket interface, which is used to detect whether the stub class already exists in the target program.
[0043] Step S103: Perform the target operation on the loaded class list according to the operation information.
[0044] In step S103, the logic tree parsing and execution module can obtain operation information from the stub class, and then perform the target operation content on the loaded class list according to the content recorded in the operation information. It should be emphasized that the process of the logic tree parsing and execution module performing the target operation content on the loaded class list is equivalent to performing the target operation content on the running target program. In this case, the operation content in at least one operation step in the operation information constitutes the target operation content.
[0045] Optionally, when there is only one operation step in the operation information, the logic tree parsing and execution module can directly execute the corresponding operation content on the loaded class list according to that operation step. When there are multiple operation steps in the operation information, the logic tree parsing and execution module can first determine the operation order of the multiple operation steps, and then execute the operation content corresponding to each operation step according to the operation order.
[0046] It should be noted that by performing target operations on the list of loaded classes based on the operation information, the target operations are performed on the running target program, thereby achieving dynamic influence on the running target program.
[0047] Based on the scheme defined in steps S101 to S103 above, it can be understood that in this embodiment of the invention, the method of operating on the running target program by manipulating the loaded class list is adopted. This involves performing reverse proxy on the memory objects in the method area of the target memory block to obtain the loaded class list of the running target program in memory. Then, operation information for the operations to be performed on the loaded class list is obtained, and the target operation content is executed on the loaded class list according to the operation information. Here, the target memory block is the memory block occupied by the target program in memory.
[0048] It's noteworthy that in the above process, by performing reverse proxying on the memory objects in the method area of the target memory block, the list of loaded classes of the target program currently running in memory is obtained. This allows the maintenance list of loaded classes in the entire memory block, which is not exposed by JVMTI, to be provided to the target execution tool. By executing target operations on the loaded class list based on the operation information, target operations are executed on the running target program, thereby enabling operations on the running target program and achieving dynamic influence over it, thus reducing labor costs.
[0049] Therefore, the solution provided in this application achieves the goal of manipulating the list of loaded classes to operate on the target program in operation, thereby reducing the technical effect of manpower costs. It also solves the technical problem of high manpower costs caused by relying on development, modification, and pre-deployment of code to dynamically affect the running program in related technologies.
[0050] In one optional embodiment, the target operation includes at least one of the following: initializing a class instance, modifying a class variable, querying a class attribute value, executing a class method, modifying an object variable, querying an object variable, and executing an object method.
[0051] Optionally, the operation content in at least one operation step in the operation information constitutes the target operation content. When the operation subject is a class, the operation content may be initializing a class instance, modifying a class variable, querying the value of a class variable, or executing a class method. When the operation subject is an object, the operation content may be modifying an object member variable, querying the value of an object member variable, or executing an object method.
[0052] It should be noted that, based on the target operation content, the target program can be modified, queried, and its methods called in real time, thereby improving the applicability of dynamic modification in this application.
[0053] In one optional embodiment, during the execution of target operation content on the loaded class list according to operation information, the target execution tool can obtain at least one operation step contained in the operation information. The operation content in the at least one operation step constitutes the target operation content. Therefore, when the number of at least one operation step is equal to 1, the operation subject and operation content in the current operation step are extracted, and the operation content is executed on the operation subject in the loaded class list. Each operation step includes an operation subject and an operation content. The operation subject is one of the following: class or object.
[0054] Optionally, the logic tree parsing and execution module can obtain operation information from the stub class, and then perform structural parsing on the operation information to obtain at least one operation step. Optionally, when the number of at least one operation step is equal to 1, it is determined that only one operation content needs to be executed on one operation subject in the loading class list. Therefore, the logic tree parsing and execution module can directly extract the operation subject and operation content in the current operation step, and execute the operation content on the corresponding operation subject in the loading class list.
[0055] Specifically, the logic tree parsing and execution module can perform operations such as querying, modifying, and executing methods in the loaded class list according to the operation steps. When querying the loaded class list, no processing of the list's contents is required; only the corresponding variable needs to be found. When modifying the loaded class list, the corresponding variable in the list can be directly modified. Therefore, in this embodiment, the processing method for the loaded class list is only described when the operation content is executing a method or initializing a class instance. Optionally, if the operation step involves executing a class method or an object method, the logic tree parsing and execution module can first find the corresponding class in the loaded class list, then obtain the Method instance object representing the method in the class through reflection, and then execute the invoke method of that instance object to execute the class method or the object method. If the operation step involves initializing a class instance, the logic tree parsing and execution module can first set the class loader of the current thread's thread context to the class loader of the class to be instantiated to solve the class loader isolation problem, and then use reflection to initialize the object of the class to be instantiated, thereby initializing the class instance.
[0056] It should be noted that by directly executing the operation step when there is only one operation step, the execution efficiency of the target program is improved.
[0057] In one optional embodiment, after obtaining at least one operation step contained in the operation information, the target execution tool can, when the number of at least one operation step is greater than or equal to two, determine whether each operation step has a parent operation step, obtain the dependency information of each operation step, and then determine the operation order of at least one operation step based on the dependency information of each operation step. Thus, according to the operation order, the operation subject and operation content in the current operation step are extracted, and the operation content is executed on the operation subject in the loaded class list. The execution of an operation step depends on a parent operation step, and the dependency information is used to record the parent operation step of the operation step.
[0058] Optionally, staff can fill in the parent operation step of the current operation step in the operation form. After the logic tree parsing and execution module obtains the operation form, it can use the disjoint-set data structure algorithm to form an operation tree according to the relationship between parent and child operation steps. The operation tree represents the execution order of each operation step.
[0059] Furthermore, staff can execute each operation step in the order of execution. For each operation step, when executing the current operation step, the logic tree parsing and execution module extracts the operation subject and operation content in the current operation step, and executes the operation content on the operation subject in the loaded class list.
[0060] It should be noted that by including multiple operation steps in the operation information, the order of operation between each operation step is determined first, and then each operation step is executed, thus ensuring the accuracy of dynamically influencing the target program.
[0061] In an optional embodiment, for each operation step, after extracting the operation subject and operation content of the current operation step and executing the operation content on the operation subject in the loaded class list, the target execution tool can determine whether there is first information in the current operation step. If the first information exists in the current operation step, the operation result is saved to the target storage area in memory. Then, it is determined whether the current operation step is the last executed operation step. If it is determined that the current operation step is the last executed operation step, all operation results in the target storage area are sent to the target platform, where the target platform displays the operation results. The first information represents the saved operation result of the current operation step.
[0062] Optionally, for each operation step, the operation step records whether the operation result of the current operation step needs to be saved. When the operation step records that the operation result of the current operation step needs to be saved, it is determined that the first information exists in the current operation step. After each operation step is completed, if it is determined that the first information exists in the completed operation step (i.e., the current operation step), the logic tree parsing and execution module can save the operation result of the operation content into the result Map (i.e., the aforementioned target storage area). Specifically, when the operation content is querying an object member variable or querying a class variable, the operation result is the query value; when the operation content is modifying an object member variable or modifying a class variable, the operation result can be whether the modification was successful; when the operation content executes a class method or an object method, the logic tree parsing and execution module can serialize the return value of the class method or object method and then save it into the result Map. The saving format can be step name: return serialized value. Conversely, if the current operation step records that the operation result does not need to be saved, it is determined that the first information does not exist, and in this case, there is no need to save the result of this operation.
[0063] Furthermore, the logic tree parsing and execution module can determine whether the current operation step is the last operation step to be executed. If it is determined that the current operation step is the last operation step to be executed, the entire operation tree is completed. At this time, the logic tree parsing and execution module can push the result Map to the target platform. The target platform saves the content it receives and can display it to the target object.
[0064] It should be noted that, by saving the operation results when the first information exists in the current operation step, and pushing them to the target platform, relevant staff can promptly understand the dynamic impact on the target program.
[0065] In an optional embodiment, for each operation step, after extracting the operation subject and operation content in the current operation step and performing the operation content on the operation subject in the loading class list, the logic tree parsing and execution module can determine whether there is second information representing the updating of the loading class list in the current operation step. If there is second information in the current operation step, the content of the loading class list is updated based on the operation result of the current operation step.
[0066] Optionally, for each operation step, the operation step records whether the loaded class list needs to be refreshed. When the operation step records that the loaded class list needs to be refreshed, it is determined that the second information exists in the current operation step. Subsequently, after each operation step is completed, if it is determined that the second information exists in the completed operation step (i.e., the current operation step), the logic tree parsing and execution module can update the content of the loaded class list based on the operation result of the current operation step. Conversely, if the current operation step records that the loaded class list does not need to be refreshed, it is determined that the second information does not exist, and in this case, there is no need to refresh the content of the loaded class list.
[0067] It should be noted that by updating the class loading list when second information exists in the current operation step, the class loading list can be synchronized with the content of the target program in real time even if the adapter class does not perform reverse proxy on the memory objects in the method area of the target memory block again, thereby improving the accuracy of the dynamic impact of this application on the target program.
[0068] In one optional embodiment, before performing reverse proxy on the memory object in the method area of the target memory block, the tool installer detects whether the target execution tool is installed in the target program. If the target execution tool is detected to be installed in the target program, operation information is sent to the target execution tool. If the target execution tool is not detected to be installed in the target program, an installation request is sent to the target programming interface of the memory, wherein the target programming interface is used to install the target execution tool in the target program according to the installation request.
[0069] Optionally, the target execution tool may not be installed in all programs in memory. Therefore, when an operator wants to perform operations on a target program, they can first use a tool installer to check whether the target execution tool is installed in the target program to ensure that the operations performed on the target program are executed normally. The aforementioned target installer can routinely run on the container host machine of cloud-based applications and on the server environment of non-cloud-based applications.
[0070] Specifically, during the process of the tool installer detecting whether the target execution tool is installed in the target program, if the target program is a cloud-based program, the tool installer can enter the container and send a liveness test request to the liveness test service in the container. If the target program is not a cloud-based program, the tool installer can directly send a liveness test request to the liveness test service on the current server. If a response to the liveness test request is obtained from the liveness test service, it is determined that the target execution tool has been installed in the target program, and the operation information obtained from the target platform can be sent to the target execution tool.
[0071] Optionally, if no response is received from the liveness detection service for the liveness detection request, the liveness detection is considered to have failed. In this case, the tool installer can download the agent from the remote static resource repository and send an installation request to the JVMTI in memory (i.e., the aforementioned target programming interface). The installation request includes the agent, which can then be invoked by the JVMTI. The agent can then load the adapter class, stub class, and logic tree parsing execution module into the target program, thereby installing the target execution tool.
[0072] It should be noted that by setting up the installer, the effectiveness of any modification to the system is ensured, avoiding the inability to dynamically affect the program due to the absence of a target execution tool in the program.
[0073] In this application, the target execution tool leverages the features of JVMTI to fully utilize bytecode technology. By having users fill out forms on the front end to call internal classes and query internal properties of a running program, the form is dynamically assembled into internal program call logic. Using bytecode instrumentation, the program logic is deployed to the program's memory and executed without modifying the program code or restarting the environment. This dynamically affects the running program, enabling testing and security personnel to independently modify program execution and query running program properties without relying on development and operations personnel. This decouples development and testing and solves the problem of security systems being unable to directly scan the actual runtime effects of code. It provides tool support for agile testing and agile security systems. It addresses the issues in functional testing where environment changes depend on operations releases and memory technical attribute values depend on development modifications, and the inability to scan dynamic attributes in security testing. It provides a tool foundation for more modern R&D processes such as agile testing, agile security, and hot patching.
[0074] Therefore, the solution provided in this application achieves the goal of manipulating the list of loaded classes to operate on the target program in operation, thereby reducing the technical effect of manpower costs. It also solves the technical problem of high manpower costs caused by relying on development, modification, and pre-deployment of code to dynamically affect the running program in related technologies.
[0075] Example 2
[0076] According to an embodiment of the present invention, an embodiment of a program processing system is provided, wherein, Figure 2 This is a schematic diagram of an optional program processing system according to an embodiment of the present invention, such as... Figure 2 As shown, the system includes:
[0077] The target platform is used to obtain operation information for the operations to be performed on the list of loaded classes and send the operation information to the tool installer;
[0078] The tool installer is used to obtain operation information and, if it detects that the target execution tool has been installed in the target program, send the operation information to the target execution tool.
[0079] The target execution tool is used to execute the above-mentioned program processing methods.
[0080] Optional, such as Figure 2 As shown, the target platform and the tool installer can communicate with each other, and the tool installer and the target execution tool can communicate with each other. Figure 3 This is a schematic diagram of the operation of an optional program processing system according to an embodiment of the present invention, such as... Figure 3As shown, testers, security personnel, and other users can fill out an operation form for the target program (i.e., the aforementioned operation information) on the front end of the target platform, along with the physical machine where the target program is located and the program name. The target platform then retrieves the operation form and persists it. Further, when the target platform receives a user-issued task to execute the operation form, it sends a task distribution request to the tool installer on the physical machine where the target program is located. This request includes the operation form and the program name. The installer then retrieves the task distribution request, locates the target program based on the program name in the request, and checks if the target execution tool is already installed on the target program. If the target execution tool is detected, the installer sends the operation form to the target execution tool, which then executes the aforementioned program processing method upon receiving the operation form.
[0081] Specifically, such as Figure 3 As shown, in one optional embodiment, the target execution tool can parse the operation form, construct an operation tree based on the relationships between the operation steps, and then invoke and execute the target program according to the operation tree, thereby dynamically influencing the target program. Afterwards, the target execution tool can send the operation results to the target platform so that users can view the execution results on the target platform.
[0082] In the above process, the target execution tool reverse proxies the memory objects in the method area of the target memory block to obtain the list of loaded classes of the target program running in memory. This provides the target execution tool with a maintenance list of loaded classes in the entire memory block, which is not exposed by JVMTI. By executing target operations on the list of loaded classes according to the operation information, the target operation is executed on the running target program, thereby achieving dynamic influence on the running target program and reducing labor costs.
[0083] Therefore, the solution provided in this application achieves the goal of manipulating the list of loaded classes to operate on the target program in operation, thereby reducing the technical effect of manpower costs. It also solves the technical problem of high manpower costs caused by relying on development, modification, and pre-deployment of code to dynamically affect the running program in related technologies.
[0084] In one optional embodiment, the target execution tool includes a liveness detection module, and the tool installer is used to send a liveness detection request to the liveness detection module and detect whether the target execution tool is installed in the target program based on the response result of the liveness detection request.
[0085] Optionally, the liveness detection module in the target execution tool is used to implement the aforementioned liveness detection service. During the process of the tool installer detecting whether the target execution tool is already installed in the target program, such as... Figure 2 As shown, the tool installer sends a liveness detection request to the liveness detection module. If a response to the liveness detection request is received from the liveness detection service, it is determined that the target execution tool has been installed in the target program, and thus the operation information obtained from the target platform can be sent to the target execution tool.
[0086] Optionally, if no response is received from the liveness detection service for the liveness detection request, the liveness detection is considered to have failed, and the target execution tool is not installed in the target program.
[0087] In one alternative embodiment, the tool installer is configured to send an installation request to the target programming interface in the memory where the target program resides if the target execution tool is not detected to be installed in the target program, wherein the target programming interface is configured to install the target execution tool in the target program according to the installation request.
[0088] Optional, such as Figure 3 As shown, if the target execution tool is not installed in the target program, i.e., the liveness detection fails, the tool installer can download the agent from the remote static resource library and send an installation request to the JVMTI in memory (i.e., the aforementioned target programming interface). The installation request includes the agent, so that the JVMTI can invoke the agent and load the adapter class, stub class and logic tree parsing execution module in the target program through the agent, thereby realizing the installation of the target execution tool.
[0089] It should be noted that by setting up the installer, the effectiveness of any modification to the system is ensured, avoiding the inability to dynamically affect the program due to the absence of a target execution tool in the program.
[0090] Example 3
[0091] According to an embodiment of the present invention, an embodiment of a program processing apparatus is provided, wherein, Figure 4 This is a schematic diagram of an optional program processing apparatus according to an embodiment of the present invention, such as... Figure 4 As shown, the device includes:
[0092] Processing module 401 is used to perform reverse proxy on memory objects in the method area of the target memory block to obtain a list of loaded classes of the target program running in memory, wherein the target memory block is the memory block occupied by the target program in memory;
[0093] Module 402 is used to obtain operation information for the operations to be performed on the list of loaded classes;
[0094] The first execution module 403 is used to perform target operation content on the loaded class list according to the operation information.
[0095] It should be noted that the above-mentioned processing module 401, acquisition module 402 and first execution module 403 correspond to steps S101 to S103 in the above embodiments. The three modules and the corresponding steps implement the same examples and application scenarios, but are not limited to the content disclosed in the above embodiment 1.
[0096] Optionally, the target operation includes at least one of the following: initializing a class instance, modifying a class variable, querying a class attribute value, executing a class method, modifying an object variable, querying an object variable, or executing an object method.
[0097] Optionally, the first execution module 403 further includes: an acquisition submodule, used to acquire at least one operation step contained in the operation information, wherein each operation step includes an operation subject and an operation content, the operation subject being one of the following: a class, an object, and the operation content in at least one operation step constituting the target operation content; and an execution submodule, used to extract the operation subject and operation content in the current operation step when the number of at least one operation step is equal to 1, and to execute the operation content on the operation subject in the loaded class list.
[0098] Optionally, the program processing device further includes: a first determining module, configured to determine whether each operation step has a parent operation step when the number of at least one operation step is greater than or equal to 2, and obtain dependency information for each operation step, wherein the execution of the operation step depends on the parent operation step, and the dependency information is used to record the parent operation step of the operation step; a second determining module, configured to determine the operation order of at least one operation step according to the dependency information of each operation step; and a second execution module, configured to extract the operation subject and operation content in the current operation step according to the operation order, and execute the operation content on the operation subject in the loading class list.
[0099] Optionally, the program processing device further includes: a first judgment module, used to judge whether there is first information in the current operation step, wherein the first information represents the operation result of saving the current operation step; a saving module, used to save the operation result to a target storage area in memory if the first information exists in the current operation step; a second judgment module, used to judge whether the current operation step is the last executed operation step; and a sending module, used to send all operation results in the target storage area to a target platform if it is determined that the current operation step is the last executed operation step, wherein the target platform displays the operation results.
[0100] Optionally, the program processing device further includes: a third judgment module, used to determine whether there is second information representing the updating of the loaded class list in the current operation step; and an update module, used to update the content of the loaded class list based on the operation result of the current operation step if the second information exists in the current operation step.
[0101] Optionally, before performing reverse proxy on the memory objects in the method area of the target memory block, the tool installer checks whether the target execution tool is installed in the target program. If the target execution tool is detected to be installed in the target program, the operation information is sent to the target execution tool. If the target execution tool is not detected to be installed in the target program, an installation request is sent to the target programming interface of the memory, wherein the target programming interface is used to install the target execution tool in the target program according to the installation request.
[0102] Example 4
[0103] According to another aspect of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is configured to execute the above-described program processing method at runtime.
[0104] Example 5
[0105] According to another aspect of the present invention, an electronic device is also provided, wherein, Figure 5 This is a schematic diagram of an optional electronic device according to an embodiment of the present invention, such as... Figure 5 As shown, the electronic device includes one or more processors; and a memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to run the programs, wherein the programs are configured to execute the program processing methods described above during runtime.
[0106] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0107] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0108] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between units or modules may be electrical or other forms.
[0109] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0111] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0112] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A program processing method, characterized in that, The program processing method is applied to a target execution tool, which is installed in a target program. The method includes: Perform reverse proxy on the memory objects in the method area of the target memory block to obtain the list of loaded classes of the target program currently running in memory, wherein the target memory block is the memory block occupied by the target program in memory; Obtain operation information for the operations to be performed on the loaded class list, wherein the operation information includes at least one operation step, each operation step includes an operation subject and operation content, the operation subject is one of the following: class, object, the operation content in the at least one operation step constitutes the target operation content, the object is the object returned after the parent operation step is executed, when the operation subject is the class, the operation content is to initialize a class instance, modify class variables, query class variable values, and execute class methods, when the operation subject is the object, the operation content is to modify object member variables, query object member variable values, and execute object methods; The target operation content is executed on the list of loaded classes according to the operation information.
2. The method according to claim 1, characterized in that, The target operation includes at least one of the following: initializing a class instance, modifying a class variable, querying a class attribute value, executing a class method, modifying an object variable, querying an object variable, and executing an object method.
3. The method according to claim 2, characterized in that, Perform target operations on the loaded class list according to the operation information, including: Obtain at least one operation step contained in the operation information; When the number of at least one operation step is equal to 1, the operation subject and operation content in the current operation step are extracted, and the operation content is executed on the operation subject in the loading class list.
4. The method according to claim 3, characterized in that, After obtaining at least one operation step included in the operation information, the method further includes: When the number of the at least one operation step is greater than or equal to 2, it is determined whether each operation step has a parent operation step, and the dependency information of each operation step is obtained, wherein the execution of the operation step depends on the parent operation step, and the dependency information is used to record the parent operation step of the operation step. The operation sequence of the at least one operation step is determined based on the dependency information of each operation step; According to the operation sequence, extract the operation subject and operation content in the current operation step, and execute the operation content on the operation subject in the loading class list.
5. The method according to claim 3 or 4, characterized in that, For each operation step, after extracting the operation subject and operation content of the current operation step, and executing the operation content on the operation subject in the loading class list, the method further includes: Determine whether there is first information in the current operation step, wherein the first information represents the operation result of saving the current operation step; If the first information exists in the current operation step, the operation result is saved to the target storage area in the memory; Determine whether the current operation step is the last operation step executed; If the current operation step is determined to be the last operation step to be executed, all operation results in the target storage area are sent to the target platform, whereby the target platform displays the operation results.
6. The method according to claim 3 or 4, characterized in that, For each operation step, after extracting the operation subject and operation content of the current operation step, and executing the operation content on the operation subject in the loading class list, the method further includes: Determine whether there is second information representing updating the list of loaded classes in the current operation step; If the second information exists in the current operation step, the content of the loaded class list is updated based on the operation result of the current operation step.
7. The method according to claim 6, characterized in that, Before performing reverse proxy on the memory objects in the method area of the target memory block, the tool installer checks whether the target execution tool is installed in the target program. If the target execution tool is detected to be installed in the target program, the operation information is sent to the target execution tool. If the target execution tool is not detected to be installed in the target program, an installation request is sent to the target programming interface of the memory, wherein the target programming interface is used to install the target execution tool in the target program according to the installation request.
8. A program processing system, characterized in that, include: The target platform is used to obtain operation information for the operations to be performed on the list of loaded classes, and send the operation information to the tool installer; The tool installer is used to acquire the operation information and, upon detecting that a target execution tool has been installed in the target program, send the operation information to the target execution tool. The operation information includes at least one operation step, each operation step including an operation subject and operation content. The operation subject is one of the following: a class or an object. The operation content in the at least one operation step constitutes the target operation content. The object is the object returned after the parent operation step is executed. When the operation subject is the class, the operation content is to initialize a class instance, modify class variables, query class variable values, and execute class methods. When the operation subject is the object, the operation content is to modify object member variables, query object member variable values, and execute object methods. The target execution tool is used to execute the program processing method according to any one of claims 1 to 7.
9. The system according to claim 8, characterized in that, The target execution tool includes a liveness detection module. The tool installer is used to send a liveness detection request to the liveness detection module and detect whether the target execution tool is installed in the target program based on the response result of the liveness detection request.
10. The system according to claim 8, characterized in that, The tool installer is used to send an installation request to the target programming interface in the memory where the target program is located when it is detected that the target execution tool is not installed in the target program, wherein the target programming interface is used to install the target execution tool in the target program according to the installation request.
11. A program processing apparatus, characterized in that, include: The processing module is used to perform reverse proxy on the memory objects in the method area of the target memory block to obtain the list of loaded classes of the target program running in memory, wherein the target memory block is the memory block occupied by the target program in the memory; The acquisition module is used to acquire operation information for the operations to be performed on the loaded class list. The operation information includes at least one operation step, and each operation step includes an operation subject and operation content. The operation subject is one of the following: class or object. The operation content in the at least one operation step constitutes the target operation content. The object is the object returned after the parent operation step is executed. When the operation subject is the class, the operation content is to initialize a class instance, modify class variables, query class variable values, and execute class methods. When the operation subject is the object, the operation content is to modify object member variables, query object member variable values, and execute object methods. The first execution module is used to execute the target operation content on the list of loaded classes according to the operation information.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the program processing method according to any one of claims 1 to 7 when it is run.
13. An electronic device, characterized in that, The electronic device includes one or more processors; A memory for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to be configured to run the programs, wherein the programs are configured to execute the program processing method as described in any one of claims 1 to 7 at runtime.