Log desensitization printing method and device based on desensitization agent, equipment and medium

By specifying a desensitization agent in Java services and registering a log-class desensitization converter, the problem of invasiveness of existing log-desensitization solutions is solved, and a simple, efficient, flexible and secure log-desensitization printing solution is realized, which improves the system development and maintenance efficiency.

CN119557914APending Publication Date: 2025-03-04CHINA PING AN LIFE INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411478216.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The existing log desensitization solution code is highly invasive and lacks flexibility and simplicity, resulting in low efficiency in enterprise system development and maintenance.

Method used

By specifying a desensitization agent in the Java service, the Java virtual machine is loaded when it starts, and the log class desensitization converter is registered using the Java virtual machine's expansion interface to achieve desensitization enhancement of the log content class, and print the desensitized log content when the application is running.

Benefits of technology

It realizes a log desensitization printing solution that is code-free, simple, efficient, flexible and safe, which reduces maintenance costs and improves system development and maintenance efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557914A_ABST
    Figure CN119557914A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of information security, and discloses a log desensitization printing method, device and equipment based on a desensitization agent.The method comprises the steps that the desensitization agentis designated in Java service through mounting parameters, and an initialization method in the desensitization agentis called; based on an initialization method, calling an interception modification method by utilizing an expansion interface of the Java virtual machine to register a log desensitization converter; when the class is loaded by the Java virtual machine, calling a conversion method in the log class desensitization converter to perform desensitization enhancement on the log content class; and calling an information formatting method in the desensitized and enhanced log content class to print the log content. According to the method, a desensitization agent is appointed in a Java service, when a class is loaded in a Java virtual machine, a conversion method in a log class desensitization converter is called to perform desensitization enhancement on a log content class loaded in the Java virtual machine, and finally corresponding log content is printed. In this way, the log content can be printed more simply, conveniently, efficiently, flexibly and safely.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information security technology, and in particular to a log desensitization printing method, device, equipment and medium based on a desensitization agent. Background Art

[0002] With the development of Internet information technology, corporate business has gradually expanded to the Internet field. Insurance systems, banking systems, transaction systems, and order systems in enterprises will all generate log data. Log data has become an important basis for enterprise management and decision-making. Log data usually contains a large amount of sensitive information, such as user names, passwords, IP addresses, etc. The leakage of this sensitive information will not only damage the business of the enterprise, but may also cause privacy and security issues. Therefore, the desensitization of log data has become a key link in enterprise information security.

[0003] In the existing technology, common log desensitization processing solutions include the following three:

[0004] Desensitization tool SDK: Process sensitive data by calling the desensitization tool when printing logs;

[0005] Log component output extension (Appender): Through the custom log output component (Appender), desensitization operations are performed when the log is printed;

[0006] Customized log format output method: modify the output format when the log is generated to achieve desensitization function;

[0007] Although these log desensitization processing solutions can achieve log desensitization to a certain extent, they generally have a significant defect: the code is highly invasive. These log desensitization solutions usually require the existing log printing code to be modified after the desensitization rules are configured. For example, it is necessary to modify the log output format or modify the processing logic of the log content. In addition, when adding or modifying desensitization rules, it is usually necessary to recode and deploy, which is cumbersome, has high maintenance costs, and poor flexibility.

[0008] In summary, most of the existing log desensitization solutions rely on changes in the code, lacking flexibility and simplicity, which seriously affects the development and maintenance efficiency of enterprise systems. Therefore, there is an urgent need for a simpler, more efficient, flexible and secure log desensitization printing solution to solve the above problems in the existing technology. Summary of the invention

[0009] The present invention provides a log desensitization printing method, device, equipment and medium based on a desensitization agent, so as to solve the technical problem that most existing log desensitization schemes rely on changes inside the code and lack flexibility and simplicity.

[0010] In a first aspect, a log desensitization printing method based on a desensitization agent is provided, comprising:

[0011] Specifying the desensitizing agent in the Java service using the mount parameter so that the desensitizing agent is loaded when the Java virtual machine is started;

[0012] Calling the initialization method in the desensitizing agent to initialize the agent environment;

[0013] Based on the initialization method, the extended interface of the Java virtual machine is used to call the interception modification method to register the log class desensitization converter;

[0014] When the Java virtual machine loads a class, a conversion method in the log class desensitization converter is called to desensitize and enhance the log content class loaded in the Java virtual machine;

[0015] When the application is running, the information formatting method in the desensitized and enhanced log content class is called to print the corresponding log content.

[0016] In a second aspect, a log desensitization printing device based on a desensitization agent is provided, comprising:

[0017] A parameter specifying module, used to specify a desensitizing agent in a Java service using a mounting parameter, so that the desensitizing agent is loaded when the Java virtual machine is started;

[0018] An agent initialization module, used to call the initialization method in the desensitizing agent to initialize the agent environment;

[0019] An interception and modification module, used to call an interception and modification method based on the initialization method using the extended interface of the Java virtual machine to register a log class desensitization converter;

[0020] A desensitization enhancement module, used for calling the conversion method in the log class desensitization converter when the Java virtual machine loads a class, so as to perform desensitization enhancement on the log content class loaded in the Java virtual machine;

[0021] The log printing module is used to call the information formatting method in the desensitized and enhanced log content class to print the corresponding log content when the application is running.

[0022] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned log desensitizing printing method based on a desensitizing agent when executing the computer program.

[0023] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above-mentioned log desensitization printing method based on the desensitization agent are implemented.

[0024] In the scheme implemented by the log desensitization printing method, device, equipment and medium based on the above-mentioned desensitization agent, the desensitization agent can be specified in the Java service using the mounting parameters, so that the desensitization agent is loaded when the Java virtual machine starts; the initialization method in the desensitization agent is called to initialize the agent environment; based on the initialization method, the interception modification method is called using the extended interface of the Java virtual machine to register the log class desensitization converter; when the Java virtual machine loads the class, the conversion method in the log class desensitization converter is called to desensitize and enhance the log content class loaded in the Java virtual machine; when the application is running, the information formatting method in the desensitized and enhanced log content class is called to print the corresponding log content. In the present invention, in view of the lack of flexibility and simplicity of the log desensitization scheme in the prior art, a desensitization agent can be specified in the Java service, and when the Java virtual machine loads the class, the conversion method in the log class desensitization converter is called to desensitize and enhance the log content class loaded in the Java virtual machine, and finally the corresponding log content is printed. In this way, the log content can be printed more simply, efficiently, flexibly and safely. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0026] Figure 1 It is a flow chart of a log desensitization printing method based on a desensitization agent in one embodiment of the present invention;

[0027] Figure 2 yes Figure 1 A schematic flow chart of a specific implementation of step S20;

[0028] Figure 3 yes Figure 1 A schematic flow chart of a specific implementation of step S30;

[0029] Figure 4 yes Figure 3 A schematic flow chart of a specific implementation of step S33;

[0030] Figure 5 yes Figure 1A schematic flow chart of a specific implementation of step S40;

[0031] Figure 6 yes Figure 1 A schematic flow chart of a specific implementation of step S50;

[0032] Figure 7 yes Figure 6 A schematic flow chart of a specific implementation of step S52;

[0033] Figure 8 It is a structural schematic diagram of a log desensitization printing device based on a desensitization agent in one embodiment of the present invention;

[0034] Fig. 9 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;

[0035] Fig.10 It is another structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0037] See also Figure 1 As shown, Figure 1 A flow chart of a log desensitization printing method based on a desensitization agent provided in an embodiment of the present invention includes the following steps:

[0038] S10: Use the mount parameters to specify the desensitizing agent in the Java service, so that the desensitizing agent is loaded when the Java virtual machine is started.

[0039] When starting the Java service, specify the mount path of the desensitizing agent in the mount parameters. Specifically, you can use the -javaagent parameter to specify the path of the desensitizing agent, for example:

[0040] -javaagent:desensitizeAgent.jar. When the Java virtual machine (JVM) is started, the mount parameter will trigger the loading operation of the desensitize agent (DesensitizeAgent, also called JavaAgent, hereinafter the same), ensuring that the desensitize agent can be injected into the service's operating environment when the Java virtual machine is started.

[0041] S20: Calling the initialization method in the desensitizing agent to initialize the agent environment.

[0042] When the desensitizing agent is successfully loaded, the initialization method (premain) in the agent is called, which is used to set up the operating environment of the desensitizing agent. In the initialization method, the desensitizing agent will prepare the subsequent class conversion operations through the Java virtual machine and register the relevant desensitizing logic. This step ensures that the agent can effectively intercept and modify the log classes loaded subsequently.

[0043] Combination Figure 2 As shown, in step S20, the specific steps of calling the initialization method in the desensitizing agent include:

[0044] S21: Detect whether there is the initialization method associated with the Java virtual machine.

[0045] S22: If the initialization method associated with the Java virtual machine exists, then before the main method of the Java virtual machine is executed, the initialization method in the desensitizing agent is called to perform pre-entry processing to perform bytecode monitoring initialization.

[0046] S23: After the initialization method is executed, the main method continues to be executed through the Java virtual machine.

[0047] For steps S21-S23, when the Java virtual machine is started, it is first necessary to detect whether the initialization method associated with the Java virtual machine exists. The detection process is performed by checking the premain method of the Java virtual machine. The premain method is a special entry method in the Java virtual machine. When the JavaAgent is mounted, the Java virtual machine will execute the premain method before executing the main method. Therefore, the desensitizing agent needs to confirm whether the Java virtual machine supports the premain method when it is started to ensure that the agent environment can be initialized normally.

[0048] If a premain method associated with the Java virtual machine is detected, the initialization method in the desensitizing agent will be called before the Java virtual machine executes the main method of the application. The main function of this initialization method is to perform pre-entry processing for subsequent bytecode monitoring and enhancement operations. Specifically, the desensitizing agent will inject the required bytecode monitoring logic through the premain method and prepare for the conversion operation of the log class. This step ensures that the agent environment has completed the relevant initialization before the log class is loaded, and can capture and enhance the bytecode of the log class in a timely manner.

[0049] When the initialization method is executed, the environment of the desensitizing agent is initialized, and the Java virtual machine will continue to execute the main method. At this point, the main logic of the application starts running, and the desensitizing agent is ready to perform desensitization on the log class during the program running. The Java virtual machine executes according to the normal startup process, which does not affect the operation of the main program, but at the same time has a non-intrusive log desensitization function.

[0050] S30: Based on the initialization method, the extended interface of the Java virtual machine is used to call the interception modification method to register the log class desensitization converter.

[0051] During the proxy initialization process, the interception modification method (i.e. addTransformer, hereinafter the same) is called through the Instrumentation interface (i.e. extended interface, hereinafter the same) of the Java virtual machine to register the log class desensitization transformer (i.e. DesensitizeLogClassFileTransformer, hereinafter the same). The log class desensitization transformer is responsible for intercepting and enhancing the behavior of the log class when it is loaded, so as to implement the desensitization operation in the log output process.

[0052] Combination Figure 3 As shown, in step S30, the Java virtual machine's extended interface is used to call the interception modification method to register the log class desensitization converter, and the specific steps include:

[0053] S31: Initialize the extended interface of the Java virtual machine.

[0054] During the initialization of the desensitizing agent, the Instrumentation interface of the Java virtual machine must be initialized first. The Instrumentation interface is a key mechanism provided by the Java virtual machine, allowing developers to dynamically modify bytecodes during class loading. Through this interface, the desensitizing agent can monitor and modify classes loaded by the Java virtual machine to achieve desensitization enhancement of log classes. During the initialization process, the desensitizing agent obtains the Instrumentation interface through the premain method and prepares for subsequent bytecode conversion operations.

[0055] S32: Obtain an instance of the extended interface based on the initialization method, and instantiate the log class desensitizing converter.

[0056] After completing the initialization of the Instrumentation interface, the desensitizing agent will call the initialization method to obtain an instance of the Instrumentation interface. After obtaining the Instrumentation interface instance, the desensitizing agent will instantiate a log class desensitizing converter. The log class desensitizing converter is a custom class converter that is specifically used to intercept and modify classes related to log output. The core function of the log class desensitizing converter is to insert desensitizing logic when loading the log content class to ensure that sensitive information is shielded or replaced during the log output process.

[0057] S33: Calling the interception modification method to register the log class desensitizing converter into the Java virtual machine.

[0058] After completing the instantiation of the log class desensitizing transformer, the agent registers the log class desensitizing transformer in the Java virtual machine by calling the addTransformer method in the Instrumentation interface.

[0059] The addTransformer method allows developers to dynamically modify the bytecode of a class when the Java virtual machine loads the class. By registering the log class desensitizing transformer with the virtual machine, the desensitizing agent can intercept the bytecode of the log content class (such as LoggingEventVO) when it is loaded and apply the desensitizing processing logic before the log content is output.

[0060] After registration is completed, the Java virtual machine will automatically call the registered log class desensitization converter in the subsequent log content class loading process to perform bytecode enhancement on the log content class. This ensures that all log content will be desensitized before printing to protect the security of sensitive information.

[0061] Combination Figure 4 As shown, in step S33, the calling interception modification method registers the log class desensitizing converter into the Java virtual machine, and the specific steps include:

[0062] S331: Obtain the extended interface of the Java virtual machine and initialize it.

[0063] When the desensitizing agent is loaded, it is necessary to obtain the extended interface of the Java virtual machine, namely the Instrumentation interface. The Instrumentation interface is a standard API provided by the Java virtual machine, which is used to intercept and modify bytecodes when classes are loaded. Through the premain method, the desensitizing agent can obtain an instance of the Instrumentation interface when the Java virtual machine is started. After obtaining the Instrumentation interface, the desensitizing agent will initialize it to prepare for bytecode monitoring and modification operations on the classes loaded in the Java virtual machine.

[0064] S332: Instantiate the log class desensitizing converter through the extended interface.

[0065] After completing the initialization of the Instrumentation interface, the desensitizing agent will instantiate a log class desensitizing transformer (DesensitizeLogClassFileTransformer). The log class desensitizing transformer is a custom class that implements the ClassFileTransformer interface and is used to intercept and modify specific log classes. During the instantiation process, the log class desensitizing transformer will configure the relevant desensitization rules to ensure that desensitization operations can be performed when the log class is loaded, shielding or replacing sensitive information in the log. Through this log class desensitizing transformer, the desensitizing agent can implement non-invasive log desensitization processing without modifying the application code.

[0066] S333: Call the interception modification method of the extended interface to register the log class desensitizing converter in the Java virtual machine.

[0067] After the log class desensitizing converter is instantiated, the desensitizing agent will register the log class desensitizing converter with the Java virtual machine through the addTransformer method of the Instrumentation interface.

[0068] The addTransformer method allows developers to dynamically modify the bytecode of a class when the class is loaded. By registering the log class desensitizing transformer with the Java virtual machine, the desensitizing agent can intercept the loading process of the log class and enhance the core methods of the log class (such as getFormattedMessage) to insert desensitizing logic.

[0069] After the log class desensitizing converter is successfully registered, the Java virtual machine will automatically call the log class desensitizing converter when loading the log class to ensure that all log contents have been desensitized before printing, thereby avoiding the leakage of sensitive information.

[0070] S40: When the Java virtual machine loads a class, a conversion method in the log class desensitization converter is called to desensitize and enhance the log content class loaded in the Java virtual machine.

[0071] When the Java virtual machine loads the log content class (such as LoggingEventVO), the transform method (i.e., conversion method, the same below) of the log class desensitizing converter will be triggered. At this time, the log class desensitizing converter will traverse the classes loaded in the Java virtual machine and identify the log content class. After finding the target class (i.e., the log content class), the log class desensitizing converter will proxy the core methods in the log content class (such as the getFormattedMessage method) and add custom desensitizing logic before and after it. Specifically, the log class desensitizing converter performs desensitization operations before the log content is output to ensure that sensitive information has been desensitized when the log is output.

[0072] Combination Figure 5 As shown, in step S40, the conversion method in the log desensitizing converter is called, and the specific steps include:

[0073] S41: In the conversion method, all classes loaded in the Java virtual machine are traversed to find the log content class.

[0074] In the transform method of the log class desensitization converter, all classes currently loaded by the Java virtual machine are first traversed through the Instrumentation interface. The purpose of the traversal operation is to find the target class related to the log output, such as the log content class such as LoggingEventVO. The log class desensitization converter will filter out classes that meet the characteristics of the log class from all loaded classes, preparing for the subsequent bytecode modification operation.

[0075] S42: Utilize the conversion interface in the log class desensitizing converter to obtain the original bytecode of the log content class.

[0076] When the target log content class is found, the log class desensitizing converter will call the conversion interface to obtain the original bytecode of the log content class. The bytecode represents the original binary representation of the log content class in the Java virtual machine, including structural information such as the class's fields, methods, and operation instructions. By obtaining the original bytecode, the desensitizing converter can analyze the internal structure of the log class and identify the parts that need to be desensitized.

[0077] S43: Parse the original bytecode through a bytecode operation library to obtain structural information of the log content class.

[0078] After obtaining the original bytecode, the log class desensitizer uses the bytecode manipulation library to parse the original bytecode. During the parsing process, the log class desensitizer extracts the structural information of the log content class, including the class fields, method signatures, local variable tables, etc. This information is crucial for identifying and locating fields containing sensitive data in the log content. For example, the log class desensitizer can focus on the return value in the getFormattedMessage method, which usually contains the complete content of the log.

[0079] S44: Locate sensitive fields according to the structural information, and modify the sensitive fields to obtain new bytecodes.

[0080] Based on the structural information obtained through parsing, the log-class desensitizing converter will locate sensitive fields in the log content class, such as fields that may contain usernames, passwords, or IP addresses. Using the bytecode manipulation library, the log-class desensitizing converter will modify the operation instructions of these fields and replace the original sensitive fields with content that complies with the desensitization rules. For example, for a field containing an IP address, the log-class desensitizing converter can partially mask or replace it with a common symbol (such as ***). The modified field will generate a new bytecode representation.

[0081] S45: Write the new bytecode back to the Java virtual machine.

[0082] After modifying the sensitive fields, the log class desensitizing converter will rewrite the new bytecode back to the Java virtual machine, replacing the original log class bytecode. This step ensures that when the log content class is called, the modified bytecode will execute the desensitized logic and print the secure log content. The Java virtual machine will directly use the enhanced bytecode when loading the class.

[0083] S50: When the application is running, the information formatting method in the desensitized and enhanced log content class is called to print the corresponding log content.

[0084] In the actual application running process, when the getFormattedMessage method of the log content class is called, the system will automatically call the desensitized enhanced version. This enhanced version will execute the desensitization logic to replace or block sensitive information in the log (such as user name, password, IP address, etc.). The desensitized log content will be formatted through the getFormattedMessage method and finally printed out to ensure that the system log records do not contain any sensitive information.

[0085] Combination Figure 6 As shown, in step S50, the information formatting method in the log content class after desensitization enhancement is called, and the specific steps include:

[0086] S51: Get the return value of the information formatting method to obtain the desensitized log content.

[0087] When the getFormattedMessage method in the log content class is called, the desensitization enhanced log content class will execute the desensitization logic. Through the return value of the getFormattedMessage method, you can get the log content that has been desensitized. At this point, the original log information (such as user name, password, IP address and other sensitive data) has been processed accordingly according to the predefined desensitization rules (for example, replaced with masks or common symbols).

[0088] S52: passing the desensitized log content to a log output tool, and using the log output tool to print the desensitized log content.

[0089] After obtaining the anonymized log content, the system will pass the anonymized log content to the log output tool. Common log output tools can be log frameworks such as Log4j and SLF4J. The key to this step is that the anonymized log content will be output to the console, file, or other specified log output target through the log tool according to the log output format pre-configured by the application. This operation ensures that the log content has been anonymized and meets security requirements.

[0090] Combination Figure 7 As shown, in step S52, the desensitized log content is passed to a log output tool, and the desensitized log content is printed using the log output tool. The specific steps include:

[0091] S521: Perform secondary formatting on the desensitized log content, and convert the output form of the desensitized log content according to the log output format.

[0092] After the desensitization process is completed, the log content can be further formatted to comply with the application's log output specifications. The main purpose of secondary formatting is to convert and adjust the desensitized log content according to the system or project's log output format (such as JSON, XML, or plain text format).

[0093] S522: Verify the availability of the log output tool, and configure the output target and output policy.

[0094] After the log content is formatted, the system will verify the availability of the log output tool to ensure that the tool can work properly. During the verification process, the system will check the initialization status and configuration parameters of the log output tool to ensure that the log tool is in an available state. Subsequently, the system will configure the log output target (such as console, file, remote server, etc.) and output strategy (such as real-time output, asynchronous output, batch writing, etc.) according to specific needs to ensure that the log content can be correctly output according to the specified strategy.

[0095] S523: The desensitized log content that has undergone secondary formatting is transferred to the internal buffer of the verified log output tool.

[0096] After verifying the availability of the log output tool and completing the relevant configuration, the system will pass the desensitized log content that has been formatted twice to the internal buffer of the log output tool. Log tools usually manage the storage and output of log content through the internal buffer.

[0097] S524: calling the printing interface of the log output tool to perform a printing operation and obtain a printing result.

[0098] After the log content is passed to the internal buffer, the system will call the print interface of the log output tool (such as Logger.info() or Appender.append(), etc.) to perform the log printing operation. The print interface is responsible for sending the anonymized log content in the internal buffer to the configured output target (such as log file, console, etc.). When calling the print interface, the system will decide whether to output synchronously or asynchronously based on the configured output strategy.

[0099] S525: Perform asynchronous callback monitoring on the printing result to ensure that the desensitized log content is successfully written into the specified target.

[0100] To ensure that the desensitized log content is successfully written to the specified target (such as a log file or remote server), the system will perform asynchronous callback monitoring on the printing operation. Through the asynchronous callback mechanism, the system can receive feedback from the output tool after the log is printed to confirm whether the log is successfully written to the target location. If any exception occurs (such as output failure, file system error, etc.), the system will record the error information and perform corresponding processing to ensure reliable output of the log content.

[0101] S53: Record the desensitized log content into a log file.

[0102] While the log output tool prints the desensitized log content, the system will also record the desensitized log information synchronously in the log file. The log file writing operation is handled by the Appender or similar components of the log framework to ensure the persistent storage of log information. The recorded log content has been desensitized, and sensitive data has been replaced or hidden to ensure that the log file will not expose any sensitive information during subsequent review or analysis.

[0103] It can be seen that in the above solution, no code intrusion is required. It is more secure and developers do not need to pay attention to and maintain the desensitization rules in the project. It is only necessary to mount the desensitization agent when the Java service is started. In addition, for different desensitization rules and demand scenarios, the desensitization agent can be mounted after encoding in the desensitization method. When the desensitization rules or requirements change, it is only necessary to re-mount the corresponding desensitization agent.

[0104] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0105] In one embodiment, a log desensitization printing device based on a desensitization agent is provided, and the log desensitization printing device based on a desensitization agent corresponds one-to-one to the log desensitization printing method based on a desensitization agent in the above embodiment. Figure 8 As shown, the log desensitization printing device based on the desensitization agent includes: a parameter specifying module 101, an agent initialization module 102, an interception modification module 103, a desensitization enhancement module 104, and a log printing module 105. The detailed description of each functional module is as follows:

[0106] The parameter specifying module 101 is used to specify the desensitizing agent in the Java service by using the mounting parameters, so that the desensitizing agent is loaded when the Java virtual machine is started;

[0107] The proxy initialization module 102 is used to call the initialization method in the desensitizing proxy to initialize the proxy environment;

[0108] An interception and modification module 103 is used to call an interception and modification method based on the initialization method using the extended interface of the Java virtual machine to register a log class desensitization converter;

[0109] The desensitization enhancement module 104 is used to call the conversion method in the log class desensitization converter when the Java virtual machine loads the class, so as to perform desensitization enhancement on the log content class loaded in the Java virtual machine;

[0110] The log printing module 105 is used to call the information formatting method in the desensitized and enhanced log content class to print the corresponding log content when the application is running.

[0111] In one embodiment, the proxy initialization module 102 is specifically configured to:

[0112] Detecting whether the initialization method associated with the Java virtual machine exists;

[0113] If the initialization method associated with the Java virtual machine exists, before the main method of the Java virtual machine is executed, the initialization method in the desensitizing agent is called to perform pre-cut-in processing to perform bytecode monitoring initialization;

[0114] After the initialization method is executed, the main method continues to be executed through the Java virtual machine.

[0115] In one embodiment, the interception modification module 103 is specifically configured to:

[0116] Initializing the extended interface of the Java virtual machine;

[0117] Obtain an instance of the extended interface based on the initialization method, and instantiate the log class desensitizing converter;

[0118] Call the interception modification method to register the log class desensitizing converter into the Java virtual machine.

[0119] In one embodiment, the interception modification module 103 is further used to:

[0120] Obtaining the extended interface of the Java virtual machine and initializing it;

[0121] Instantiate the log class desensitizing converter through the extended interface;

[0122] The interception modification method of the extended interface is called to register the log class desensitizing converter in the Java virtual machine.

[0123] In one embodiment, the desensitization enhancement module 104 is specifically used to:

[0124] In the conversion method, all classes loaded in the Java virtual machine are traversed to find the log content class;

[0125] Utilize the conversion interface in the log class desensitizing converter to obtain the original bytecode of the log content class;

[0126] Parsing the original bytecode by using a bytecode operation library to obtain structural information of the log content class;

[0127] Locating sensitive fields according to the structural information, and modifying the sensitive fields to obtain new bytecodes;

[0128] The new bytecode is written back to the Java virtual machine.

[0129] In one embodiment, the log printing module 105 is specifically used for:

[0130] Get the return value of the information formatting method to obtain the desensitized log content;

[0131] Passing the desensitized log content to a log output tool, and using the log output tool to print the desensitized log content;

[0132] The anonymized log content is recorded in the log file.

[0133] In one embodiment, the log printing module 105 is further used to:

[0134] Performing secondary formatting on the desensitized log content, and converting the output form of the desensitized log content according to the log output format;

[0135] Verify the availability of the log output tool and configure the output target and output strategy;

[0136] Passing the desensitized log content after secondary formatting to the internal buffer of the verified log output tool;

[0137] Calling the print interface of the log output tool to perform a print operation and obtain a print result;

[0138] Asynchronous callback monitoring is performed on the printing result to ensure that the desensitized log content is successfully written to the specified target.

[0139] For the specific limitations of the log desensitization printing device based on the desensitization agent, please refer to the limitations of the log desensitization printing method based on the desensitization agent above, which will not be repeated here. Each module in the above-mentioned log desensitization printing device based on the desensitization agent can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0140] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the service side of a log desensitization printing method based on a desensitization agent.

[0141] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Fig.10 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of the client side of a log desensitization printing method based on a desensitization agent.

[0142] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed, the steps provided in the above embodiment can be implemented.

[0143] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.

[0144] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0145] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0146] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A log desensitization printing method based on a desensitization agent, characterized in that: include: Specifying the desensitizing agent in the Java service using the mount parameter so that the desensitizing agent is loaded when the Java virtual machine is started; Calling the initialization method in the desensitizing agent to initialize the agent environment; Based on the initialization method, the extended interface of the Java virtual machine is used to call the interception modification method to register the log class desensitization converter; When the Java virtual machine loads a class, a conversion method in the log class desensitization converter is called to desensitize and enhance the log content class loaded in the Java virtual machine; When the application is running, the information formatting method in the desensitized and enhanced log content class is called to print the corresponding log content.

2. The log desensitization printing method based on desensitization agent according to claim 1 is characterized in that: The calling of the initialization method in the desensitizing agent to initialize the agent environment includes: Detecting whether the initialization method associated with the Java virtual machine exists; If the initialization method associated with the Java virtual machine exists, before the main method of the Java virtual machine is executed, the initialization method in the desensitizing agent is called to perform pre-cut-in processing to perform bytecode monitoring initialization; After the initialization method is executed, the main method continues to be executed through the Java virtual machine.

3. The log desensitization printing method based on desensitization agent according to claim 1 is characterized in that: The method of calling the interception modification method based on the initialization method using the extended interface of the Java virtual machine to register the log class desensitization converter includes: Initializing the extended interface of the Java virtual machine; Obtain an instance of the extended interface based on the initialization method, and instantiate the log class desensitizing converter; Call the interception modification method to register the log class desensitizing converter into the Java virtual machine.

4. The log desensitization printing method based on desensitization agent according to claim 3 is characterized in that: The calling interception modification method registers the log class desensitizing converter into the Java virtual machine, including: Obtaining the extended interface of the Java virtual machine and initializing it; Instantiate the log class desensitizing converter through the extended interface; The interception modification method of the extended interface is called to register the log class desensitizing converter in the Java virtual machine.

5. The log desensitization printing method based on desensitization agent according to claim 1 is characterized in that: The calling of the conversion method in the log class desensitization converter to desensitize and enhance the log content class loaded in the Java virtual machine includes: In the conversion method, all classes loaded in the Java virtual machine are traversed to find the log content class; Utilize the conversion interface in the log class desensitizing converter to obtain the original bytecode of the log content class; Parsing the original bytecode by using a bytecode operation library to obtain structural information of the log content class; Locating sensitive fields according to the structural information, and modifying the sensitive fields to obtain new bytecodes; The new bytecode is written back to the Java virtual machine.

6. The log desensitization printing method based on desensitization agent according to claim 1 is characterized in that: The information formatting method in the desensitized and enhanced log content class is called to print the corresponding log content, including: Get the return value of the information formatting method to obtain the desensitized log content; Passing the desensitized log content to a log output tool, and using the log output tool to print the desensitized log content; Record the desensitized log content in the log file.

7. The log desensitization printing method based on desensitization agent according to claim 6 is characterized in that: The method of transferring the desensitized log content to a log output tool and printing the desensitized log content using the log output tool includes: Performing secondary formatting on the desensitized log content, and converting the output form of the desensitized log content according to the log output format; Verify the availability of the log output tool and configure the output target and output strategy; Passing the desensitized log content after secondary formatting to the internal buffer of the verified log output tool; Calling the print interface of the log output tool to perform a print operation and obtain a print result; Asynchronous callback monitoring is performed on the printing result to ensure that the desensitized log content is successfully written to the specified target.

8. A log desensitization printing device based on a desensitization agent, characterized in that: include: A parameter specifying module, used to specify a desensitizing agent in a Java service using a mounting parameter, so that the desensitizing agent is loaded when the Java virtual machine is started; An agent initialization module, used to call the initialization method in the desensitizing agent to initialize the agent environment; An interception and modification module, used to call an interception and modification method based on the initialization method using the extended interface of the Java virtual machine to register a log class desensitization converter; A desensitization enhancement module, used for calling the conversion method in the log class desensitization converter when the Java virtual machine loads a class, so as to perform desensitization enhancement on the log content class loaded in the Java virtual machine; The log printing module is used to call the information formatting method in the desensitized and enhanced log content class to print the corresponding log content when the application is running.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the log desensitization printing method based on the desensitization agent as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the log desensitization printing method based on the desensitization agent as described in any one of claims 1 to 7 are implemented.