Log desensitization method and device, equipment, storage medium and program product
By receiving and dynamically updating desensitization configuration information, and combining regular expressions and custom scripts to process log desensitization, the problem of desensitization rules not being able to take effect in real time and false desensitization in the existing technology is solved, and the flexibility of log desensitization is achieved. and accuracy to ensure data security.
Patent Information
- Application Number
- CN202410569267.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-08
- Publication Date
- 2024-09-20
AI Technical Summary
Existing log masking technology is not flexible and convenient enough, cannot dynamically modify masking rules to take effect in real time, and is difficult to handle complex types of logs and has problems with mistaken masking and circular references.
By receiving desensitization configuration information, including desensitization objects, attribute names and desensitization rules, the desensitization rules are dynamically updated and object dependency links are recursively processed. Regular expressions and custom scripts are used for desensitization processing to ensure real-time desensitization of desensitization rules. Validity and accuracy.
It achieves the flexibility and accuracy of log desensitization processing, reduces the risk of false desensitization, terminates circular reference processing in a timely manner, avoids program stack overflow errors, and improves data security.
Smart Images

Figure CN118673523A
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data desensitization, and in particular to a log desensitization method, device, equipment, storage medium and program product. Background Art
[0002] Log desensitization refers to processing sensitive information in logs so that it cannot be directly read, thereby protecting data security. For example, desensitizing sensitive information contained in logs output by applications can effectively prevent user privacy data leakage and improve data protection levels.
[0003] At present, the following methods are usually used to desensitize the desensitized logs: based on the pre-written desensitization rules, a configuration file is obtained; the application loads the configuration file and parses it to obtain the desensitization rules; based on the desensitization rules, the desensitized logs are desensitized by the target class of the application to obtain the target log. However, the above methods are not flexible and convenient enough to desensitize the desensitized logs. Summary of the invention
[0004] The present application provides a log desensitization method, device, equipment, storage medium and program product to solve the problem that the current method of desensitizing logs is not flexible and convenient enough.
[0005] In a first aspect, the present application provides a log desensitization method, comprising:
[0006] Receive desensitization configuration information, the desensitization configuration information including a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name;
[0007] Get the attribute information of the desensitized object in the log, which includes the attribute name and attribute value;
[0008] According to the attribute name of the desensitized object, the attribute value is desensitized using the desensitization rule corresponding to the attribute name.
[0009] Optionally, receiving desensitizing configuration information includes: receiving desensitizing configuration information pushed based on a message broadcast mechanism or receiving desensitizing matching information obtained through a listener.
[0010] Optionally, receiving desensitizing configuration information includes: if the desensitizing configuration information is newly created first desensitizing configuration information, then caching the first desensitizing configuration information, the first desensitizing configuration information includes the first attribute name and the desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the first version number; if the first desensitizing configuration information is updated to the second desensitizing configuration information, the second desensitizing configuration information includes the first attribute name and the desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the second version number, if the first version number is inconsistent with the second version number, then the desensitizing rule corresponding to the first attribute name is updated to the cache.
[0011] Optionally, the attribute value is desensitized according to the attribute name of the desensitized object and the desensitization rules corresponding to the attribute name, including at least one of the following: desensitizing the attribute value according to the attribute name and the desensitization starting position; desensitizing the attribute value according to the regular expression corresponding to the attribute name, the desensitization starting position and the desensitization ending position; inputting the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value into the desensitization script, and desensitizing the attribute value using a custom desensitization function.
[0012] Optionally, the log desensitization method further includes: if the object type of the desensitized object is object, and the desensitized object has a desensitizing annotation, then caching the desensitization rules in the desensitizing annotation.
[0013] Optionally, the log desensitization method also includes: if the object type of the desensitized object is object, and the cached desensitization configuration information does not contain the desensitization rule corresponding to the attribute name, then determining that the desensitization rule in the cached desensitization annotation is the desensitization rule corresponding to the attribute name.
[0014] Optionally, according to the attribute name of the desensitized object, the attribute value is desensitized using the desensitization rules corresponding to the attribute name, including: obtaining the value type of the attribute value; if the value type is a string type and the desensitization switch corresponding to the attribute name is in the on state, desensitizing the attribute value using the desensitization rules corresponding to the attribute name; if the value type is a collection type, for each element in the collection, the value of the element is used as a new attribute value, and the step of obtaining the value type of the attribute value is executed; if the value type is an object or dictionary type, the attribute value is used as a new desensitized object, and the step of obtaining the attribute information of the desensitized object in the log is executed.
[0015] Optionally, the log desensitizing method also includes: if the object type of the desensitized object is an object or dictionary type, recursively determining whether there are interdependent object references in the sub-attribute information in the attribute information of the desensitized object, and recording the dependency link of the desensitized object; if the dependency link forms a loop, the desensitizing processing of the desensitized object is terminated.
[0016] Optionally, the log desensitizing method also includes: if the result of the desensitization processing is that the desensitization is successful, obtaining a desensitized message event, the desensitized message event includes at least the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitization count of the attribute name of the desensitized object, and the time of the desensitization processing, and the desensitized message event is triggered asynchronously; caching the desensitized message events to output the desensitized message events when the number of desensitized message events is greater than or equal to the quantity threshold.
[0017] Optionally, obtaining the attribute information of the desensitized object in the log includes: if the desensitization switch of the application where the desensitized object is located is in the on state, obtaining the attribute information of the desensitized object in the log.
[0018] In a second aspect, the present application provides a log desensitization device, comprising:
[0019] A receiving module, used to receive desensitization configuration information, the desensitization configuration information includes a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name;
[0020] The acquisition module is used to obtain the attribute information of the desensitized object in the log, and the attribute information includes the attribute name and attribute value;
[0021] The processing module is used to perform desensitization processing on the attribute value according to the attribute name of the desensitized object and the desensitization rule corresponding to the attribute name.
[0022] Optionally, the receiving module is specifically used to: receive desensitizing configuration information pushed based on the message broadcast mechanism or desensitizing matching information obtained through a listener.
[0023] Optionally, the receiving module is specifically used for: if the desensitizing configuration information is a newly created first desensitizing configuration information, then caching the first desensitizing configuration information, the first desensitizing configuration information includes a first attribute name and a desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the first version number; if the first desensitizing configuration information is updated to the second desensitizing configuration information, the second desensitizing configuration information includes the first attribute name and the desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the second version number, if the first version number is inconsistent with the second version number, then the desensitizing rule corresponding to the first attribute name is updated to the cache.
[0024] Optionally, the processing module is specifically used for at least one of the following: desensitizing the attribute value according to the attribute name and the desensitization starting position; desensitizing the attribute value according to the regular expression corresponding to the attribute name, the desensitization starting position and the desensitization ending position; inputting the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value into the desensitization script, and using a custom desensitization function to desensitize the attribute value.
[0025] Optionally, the acquisition module is also used to: if the object type of the desensitized object is object, and the desensitized object has a desensitizing annotation, then cache the desensitization rules in the desensitizing annotation.
[0026] Optionally, the acquisition module is also used to: if the object type of the desensitizing object is object, and the cached desensitizing configuration information does not contain the desensitizing rules corresponding to the attribute name, then determine that the desensitizing rules in the cached desensitizing annotation are the desensitizing rules corresponding to the attribute name.
[0027] Optionally, the processing module is specifically used to: obtain the value type of the attribute value; if the value type is a string type and the desensitization switch corresponding to the attribute name is in the on state, the attribute value is desensitized using the desensitization rule corresponding to the attribute name; if the value type is a collection type, then for each element in the collection, the value of the element is used as the new attribute value, and the step of obtaining the value type of the attribute value is executed; if the value type is an object or dictionary type, the attribute value is used as a new desensitized object, and the step of obtaining the attribute information of the desensitized object in the log is executed through the acquisition module.
[0028] Optionally, the processing module is also used to: if the object type of the desensitized object is an object or dictionary type, recursively determine whether there are interdependent object references in the sub-attribute information in the attribute information of the desensitized object, and record the dependency link of the desensitized object; if the dependency link forms a loop, end the desensitization processing of the desensitized object.
[0029] Optionally, the processing module is also used to: if the result of the desensitization processing is successful, obtain a desensitized message event, the desensitized message event includes at least the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitization count of the attribute name of the desensitized object, and the time of the desensitization processing, and the desensitized message event is triggered asynchronously; cache the desensitized message events to output the desensitized message events when the number of desensitized message events is greater than or equal to the quantity threshold.
[0030] Optionally, the acquisition module is specifically used to: if the desensitization switch of the application where the desensitized object is located is in the on state, then obtain the attribute information of the desensitized object in the log.
[0031] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0032] Memory stores computer-executable instructions;
[0033] The processor executes the computer-executable instructions stored in the memory to implement the log desensitization method as described in the first aspect of the present application.
[0034] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer program instructions are stored. When the computer program instructions are executed, the log desensitization method described in the first aspect of the present application is implemented.
[0035] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed, implements the log desensitization method described in the first aspect of the present application.
[0036] The log desensitization method, device, equipment, storage medium and program product provided by the present application receive desensitization configuration information, which includes desensitized objects, attribute names of desensitized objects and desensitization rules corresponding to the attribute names; obtain attribute information of desensitized objects in logs, which includes attribute names and attribute values; and desensitize attribute values according to the attribute names of desensitized objects and the desensitization rules corresponding to the attribute names. The present application receives desensitization configuration information, which includes desensitized objects, attribute names of desensitized objects and desensitization rules corresponding to the attribute names. The desensitization rules can be implemented in real time after the desensitization rules are dynamically modified, solving the technical problem that the desensitization configuration information cannot be modified and take effect in real time, making the desensitization process more flexible and convenient; and desensitize attribute values using the desensitization rules corresponding to the attribute names, so that different desensitization rules are used for different desensitized objects, thereby desensitizing the logs more accurately. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 A schematic diagram of an application scenario provided for an embodiment of the present application;
[0039] Figure 2 A flow chart of a log desensitization method provided in an embodiment of the present application;
[0040] Figure 3 A flowchart of a log desensitization method provided by another embodiment of the present application;
[0041] Figure 4 A schematic diagram of accurate desensitization classification corresponding to different attribute names provided in an embodiment of the present application;
[0042] Figure 5 A schematic diagram of a design scheme of a log desensitization method provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of the software architecture of a log desensitization method provided in an embodiment of the present application;
[0044] Figure 7 A modular functional diagram of a log desensitization method provided in an embodiment of the present application;
[0045] Figure 8 A schematic diagram of the structure of a log desensitization device provided in one embodiment of the present application;
[0046] Fig. 9 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] 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 analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0049] First, some technical terms involved in this application are explained:
[0050] The Business Operation Support System (BOSS) is centered on customer service, business operation and management, with key transaction operations (focusing on customer service and billing) as the main functions of the system. It provides network operators with a comprehensive business operation and management platform and provides comprehensive solutions; this application mainly refers to the desensitizing BOSS, which can be used to configure the desensitizing rules of the application where the desensitized object is located, manage the desensitizing rule versions, and roll back the desensitizing rules in the event of errors in the desensitizing rule configuration.
[0051] A project management tool (Maven) is an open source project developed in pure Java (a programming language). Based on the concept of Project Object Model (POM), Maven uses a central information fragment to manage the construction, reporting, and documentation steps of a project; it can build and manage dependencies for Java projects.
[0052] A log file is a file that records events and activities that occur when a system or application is running. These events and activities can be system errors, warnings, information, and debugging information. Log files usually contain information such as timestamp, event type, event description, and event level. Log files are very useful for diagnosing and solving system problems, and can help developers and system administrators determine the status, performance, and stability of the system. Common log file formats include text format, eXtensible Markup Language (XML) format, and JSON format (a lightweight data exchange format). Log files are usually saved on local disks or remote servers and can be accessed and analyzed through various tools and technologies.
[0053] Log desensitization refers to processing sensitive information in logs so that it cannot be directly read, thereby protecting data security. Log desensitization usually includes desensitizing sensitive fields, such as replacing, deleting or encrypting. Desensitized logs can still be used for analysis and monitoring, but cannot be used to directly obtain sensitive information.
[0054] A software development kit (SDK) is a collection of related documents, examples, and tools used to assist in the development of a certain type of software. In this application, it mainly refers to the desensitizing SDK, which is a collection of desensitizing tools that can be integrated into applications that require desensitization.
[0055] At present, the following methods are usually used to desensitize the desensitized logs: based on the pre-written desensitization rules, a configuration file is obtained; the application loads the configuration file and parses it to obtain the desensitization rules; based on the desensitization rules, the desensitized logs are desensitized by the target class of the application to obtain the target log. However, when desensitizing the desensitized logs in the above method, the configuration of the desensitization rules needs to be loaded in advance, and the desensitization rules cannot be dynamically edited when the application is running and take effect in real time. Therefore, there is a problem that the desensitization process is not flexible and convenient enough. In addition, the above-mentioned method for desensitizing logs has the following disadvantages: (1) Sensitive log identification is implemented based on regular expressions, and complex type logs cannot be desensitized. For example, the personal identification number (PIN) field may contain the user's mobile phone number, bank card or mobile phone number, and it is impossible to desensitize all sensitive fields through regular expressions; there is also the possibility of mis-desensitization, and non-sensitive fields may be desensitized; (2) Different desensitization rules cannot be implemented according to different applications and different Java objects; (3) The desensitization operation status cannot be monitored, such as the use of various desensitization rules, desensitization objects, and desensitization system; (4) No solution is provided for the problem of circular references in desensitized objects.
[0056] Based on the above problems, the present application provides a log desensitization method. By receiving desensitization configuration information, the desensitization configuration information includes the desensitized object, the attribute name of the desensitized object and the desensitization rules corresponding to the attribute name. The modified desensitization rules can be taken into effect in real time after the desensitization rules are dynamically modified, making the desensitization processing more flexible and convenient; by using different desensitization rules for different desensitized objects for desensitization processing, the logs can be desensitized more accurately, and the probability of the occurrence of incorrect desensitized log problems can be effectively reduced; the present application can also monitor the desensitization operation status, and when a circular reference is detected in the desensitized object, the desensitization processing can be terminated in time to avoid program stack overflow errors.
[0057] In the following, the application scenarios of the solutions provided in this application are first illustrated.
[0058] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of the present application. Figure 1 As shown, the application scenario may include: a server cluster 11 and a terminal 12. Among them, the server cluster 11 includes multiple servers 111 and a memory 112, and the terminal 12 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, an intelligent voice interaction device, a smart home appliance or a car terminal, etc. The user accesses the application on the terminal 12, and the application integrates the desensitization SDK; during the operation of the application, the log output by the application is obtained through the server 111, and the desensitized objects in the log are desensitized to obtain the desensitized log, and the desensitized log is stored in the memory 112. Among them, the specific implementation process of the server 111 desensitizing the desensitized objects in the log can be referred to the schemes of the following embodiments.
[0059] It should be noted that Figure 1 This is only a schematic diagram of an application scenario provided by the embodiment of the present application. Figure 1 does not limit the equipment included in Figure 1 The positional relationship between the devices is limited.
[0060] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0061] Figure 2 Flow chart of a log desensitization method provided in an embodiment of the present application. The method of the embodiment of the present application can be applied to an electronic device, which can be a server or a server cluster. Figure 2 As shown, the method of the embodiment of the present application includes:
[0062] S201. Receive desensitization configuration information, where the desensitization configuration information includes a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name.
[0063] In the embodiment of the present application, it should be understood that the application to be desensitized for log is integrated with desensitization SDK, and the embodiment of the present application desensitizes the desensitized object in the log by desensitization SDK. Wherein, desensitization SDK is written based on SpringBoot-stater (a set of predefined dependency sets), and the factory loading (SpringFactoritesLoader) mechanism is adopted, and the bean (a reusable component of Java language) related to desensitization SDK is initialized and injected when the application that relies on desensitization SDK is started, so as to realize the initialization of desensitization SDK. Applications such as applications using SpringBoot (a kind of microservice framework) services support maven (a kind of open source project management tool) and gradle (a kind of project automation construction open source tool) projects. Applications do not need to pay attention to how desensitization SDK is loaded internally, and desensitization SDK can be used directly, so that desensitization SDK can be integrated more conveniently. Specifically, for example, desensitization objects can be desensitized by calling the interface Vmask.toJson() of desensitization SDK.
[0064] In this step, for example, the desensitizing configuration information pushed based on the message broadcast mechanism can be received through the desensitizing SDK, and the received desensitizing configuration information can be newly created desensitizing configuration information, or updated desensitizing configuration information, to ensure that the desensitizing configuration information takes effect in real time. For specific information on how to receive the desensitizing configuration information, please refer to the subsequent embodiments, which will not be repeated here. The desensitizing configuration information includes a desensitizing object, the attribute name of the desensitizing object, and the desensitizing rules corresponding to the attribute name. Among them, the attribute name of the desensitizing object is, for example, "phone", which means a mobile phone number. Different attribute names can correspond to different desensitizing rules.
[0065] S202: Obtain attribute information of the desensitized object in the log, where the attribute information includes an attribute name and an attribute value.
[0066] In this step, exemplarily, the object type of the desensitized object can be obtained, and the object type of the desensitized object is, for example, an object or a dictionary type, and the attribute information corresponding to the desensitized object is obtained according to the object type of the desensitized object. Specifically, the desensitized object is, for example, {"phone":"18888888888","name":"abc","amount":"4000"}, where "phone" is the attribute name, indicating the mobile phone number, and the corresponding attribute value is "18888888888"; "name" is the attribute name, indicating the user's name, and the corresponding attribute value is "abc"; "amount" is the attribute name, indicating the user's account balance, and the corresponding attribute value is "4000".
[0067] S203. Perform desensitization processing on the attribute value according to the attribute name of the desensitization object and using the desensitization rule corresponding to the attribute name.
[0068] In this step, illustratively, referring to the example of step S202, assuming that the attribute name is "phone", the attribute value "18888888888" can be desensitized using the desensitization rule corresponding to the attribute name to obtain the desensitized attribute value "1*********8". For how to desensitize the attribute value according to the attribute name of the desensitized object and the desensitization rule corresponding to the attribute name, please refer to the subsequent embodiments, which will not be repeated here. For example, for the desensitized object {"phone":"18888888888","name":"abc","amount":"4000"}, after the attribute value is desensitized, the desensitized object is {"phone":"1************8","name":"a**","amount":"4000"}, wherein the attribute values corresponding to "phone" and "name" are desensitized. Since the attribute name "amount" is not configured with a desensitization rule, the attribute value "4000" is output as is.
[0069] The log desensitization method provided in the embodiment of the present application receives desensitization configuration information, which includes a desensitized object, an attribute name of the desensitized object, and a desensitization rule corresponding to the attribute name; obtains the attribute information of the desensitized object in the log, and the attribute information includes an attribute name and an attribute value; and desensitizes the attribute value according to the attribute name of the desensitized object and the desensitization rule corresponding to the attribute name. The embodiment of the present application receives desensitization configuration information, which includes a desensitized object, an attribute name of the desensitized object, and a desensitization rule corresponding to the attribute name. This can realize that the modified desensitization rules can take effect in real time after the desensitization rules are dynamically modified, solve the technical problem that the desensitization configuration information cannot be modified and take effect in real time, and make the desensitization processing more flexible and convenient; and uses the desensitization rules corresponding to the attribute name to desensitize the attribute value, so that different desensitization rules are used for different desensitized objects for desensitization processing, so that the log can be desensitized more accurately.
[0070] Based on the above embodiments, in the embodiments of the present application, Figure 2 Step S201 may further include: receiving desensitization configuration information pushed based on a message broadcast mechanism or desensitization matching information obtained through a listener.
[0071] Exemplarily, desensitization configuration information is such as configured by BOSS, and can be configured by BOSS desensitization rules, management desensitization rule version and in the case of errors in desensitization rule configuration, desensitization rules can be rolled back to avoid user sensitive information leakage. In this embodiment, the ability of dynamic naming and configuration service (dynamic naming and configuration service, nacos) hot update editing can be utilized, such as after updating desensitization configuration information by BOSS, first the updated desensitization configuration information is persistently stored in the database, and then pushed to nacos server, nacos server broadcasts desensitization configuration information update event to nacos client, i.e., integrated desensitization SDK application, so that the updated desensitization configuration information can be received by desensitization SDK. Optionally, nacos can be replaced by rocketMQ (a kind of distributed message middleware system of open source), and the updated desensitization configuration information is pushed by message broadcast mechanism, so as to maximize the update message of desensitization configuration information without loss.
[0072] In order to prevent problems with nacos's push of desensitized message events, a listener can also be maintained in the desensitization SDK, and the listener will be initialized as the application starts. For example, the desensitization matching information can be obtained every minute through the listener. For example, a request message is sent to BOSS every minute through the listener, and the request message carries the application identifier of the application where the desensitized object is located, so as to obtain the desensitization configuration information through the listener.
[0073] This embodiment can make the desensitizing configuration information take effect immediately in the application integrated with the desensitizing SDK after it is updated, so that the desensitizing configuration information can be modified and take effect in real time.
[0074] Optionally, if the desensitizing configuration information is a newly created first desensitizing configuration information, the first desensitizing configuration information is cached, and the first desensitizing configuration information includes the first attribute name and the desensitizing rules corresponding to the first attribute name, and the version number of the desensitizing rules is the first version number; if the first desensitizing configuration information is updated to the second desensitizing configuration information, the second desensitizing configuration information includes the first attribute name and the desensitizing rules corresponding to the first attribute name, and the version number of the desensitizing rules is the second version number. If the first version number is inconsistent with the second version number, the desensitizing rules corresponding to the first attribute name are updated to the cache.
[0075] Exemplarily, if the desensitizing configuration information is the newly created first desensitizing configuration information, the first desensitizing configuration information is cached locally to reduce the network overhead of accessing the first desensitizing configuration information. If the first desensitizing configuration information is updated to the second desensitizing configuration information, the first desensitizing configuration information and the second desensitizing configuration information can be compared in an asynchronous manner. If the first version number of the desensitizing rule corresponding to the first attribute name is inconsistent with the second version number, the desensitizing rule corresponding to the first attribute name of the second version number is updated to the cache, that is, the desensitizing rule corresponding to the attribute name with inconsistent desensitizing rule version numbers is updated to the cache to ensure that the updated desensitizing configuration information can take effect in real time.
[0076] Figure 3 This is a flow chart of a log desensitization method provided by another embodiment of the present application. Based on the above embodiment, the present application embodiment further illustrates the log desensitization method. Figure 3 As shown, the method of the embodiment of the present application may include:
[0077] S301. Receive desensitization configuration information, where the desensitization configuration information includes a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name.
[0078] The detailed description of this step can be found in Figure 2 The relevant description of S201 in the illustrated embodiment will not be repeated here.
[0079] S302: Determine whether the desensitization switch of the application where the desensitization object in the log is located is in the on state.
[0080] In this step, the desensitization switch of the application where the desensitization object is located is configurable, such as being configurable by BOSS, to flexibly control whether the log of the application is desensitized, and the desensitization switch can be understood as a master switch. Exemplarily, after the application where the desensitization object is located is started, the desensitization configuration information of the local cache will be initialized. When Vmask.toJson() is called, the internal logic of the desensitization SDK can first read the cached desensitization configuration information. If the cached desensitization configuration information is not read (i.e., the cached desensitization configuration information is empty), it is determined that the desensitization object is not desensitized, and the desensitization object is directly returned; if the cached desensitization configuration information is read, it can continue to determine whether the desensitization switch of the application is in the on state, and the desensitization switch is configurable. If the desensitization switch of the application is in the off state, it is determined that the desensitization object is not desensitized, and the S317 step is executed to directly return the desensitization object; if the desensitization switch of the application is in the on state, it means that the desensitization object needs to be desensitized, and the S303 step is executed.
[0081] S303: Obtain the object type of the desensitized object.
[0082] Exemplarily, the object type includes basic type, object and dictionary type, and the basic type includes string type (string), integer (int), long integer (long) and floating point type (float), etc.; the dictionary type is Map type. If the object type of the desensitized object is object or dictionary type, step S304 is executed; if the object type of the desensitized object is a basic type, step S317 is executed.
[0083] S304: If the object type of the desensitized object is an object or dictionary type, then obtain the attribute information corresponding to the desensitized object, where the attribute information includes an attribute name and an attribute value.
[0084] If the object type of the desensitized object is an object, execute steps S305 to S310; if the object type of the desensitized object is a dictionary type, execute step S311.
[0085] S305: If the object type of the desensitized object is object, determine whether there is a desensitized annotation for the desensitized object.
[0086] If the desensitized object has a desensitizing annotation, execute step S306; if the desensitized object does not have a desensitizing annotation, execute step S307.
[0087] S306. Cache the desensitization rules in the desensitization annotation.
[0088] Exemplarily, the desensitizing annotation is, for example, the @Mask annotation. Specifically, the desensitizing annotation is, for example: @Mask(type="regexType", "rule": "^(1[3-9][0-9])d{4}(d{4}$")), indicating that the desensitizing rule in the desensitizing annotation is regular desensitization, and the desensitizing rule in the desensitizing annotation is cached locally, and step S307 is continued.
[0089] S307: Determine whether the cached desensitization configuration information contains a desensitization rule corresponding to the attribute name.
[0090] It can be understood that for the desensitization rules in the cached desensitization annotations and the desensitization rules in the cached desensitization configuration information, it is preferred to determine whether the desensitization rules in the cached desensitization configuration information contain the desensitization rules corresponding to the attribute name. Exemplarily, the class name of the desensitized object can be obtained, and the class name of the desensitized object is, for example, com.abcUserVO. According to the class name of the desensitized object, the desensitization rules of the desensitized object are matched in the cached desensitization configuration information. Specifically, in the cached desensitization configuration information, the full path class name of the desensitized object (such as com.abcUserVO) can be matched first. If it is not matched, the specific class name UserVO can be matched to determine whether the cached desensitization configuration information contains the desensitization rules of the desensitized object. After determining that the cached desensitization configuration contains the desensitization rules of the desensitized object, the properties of the desensitized object can be traversed to obtain the attribute information corresponding to the desensitized object, so that the desensitization rules in the cached desensitization configuration information can be matched according to the attribute name, and it is determined whether the desensitization rules in the cached desensitization configuration information contain the desensitization rules corresponding to the attribute name. If the desensitization rules in the cached desensitization configuration information do not include the desensitization rules corresponding to the attribute name, execute steps S308 and S309; if the desensitization rules in the cached desensitization configuration information include the desensitization rules corresponding to the attribute name, execute step S310.
[0091] S308. Determine whether the desensitization rules in the cached desensitization annotations include the desensitization rules corresponding to the attribute name.
[0092] If the desensitization rules in the cached desensitization annotation do not include the desensitization rules corresponding to the attribute name, execute step S317; if the desensitization rules in the cached desensitization annotation include the desensitization rules corresponding to the attribute name, execute step S309.
[0093] S309. Obtain the desensitization rule corresponding to the attribute name from the desensitization rules in the cached desensitization annotation.
[0094] S310. Obtain the desensitization rule corresponding to the attribute name from the cached desensitization configuration information.
[0095] S311. If the object type of the desensitizing object is a dictionary type, determine whether the cached desensitizing configuration information contains the desensitizing rules corresponding to the attribute name.
[0096] If the desensitization rules in the cached desensitization configuration information include the desensitization rules corresponding to the attribute name, execute step S310; if the desensitization rules in the cached desensitization configuration information do not include the desensitization rules corresponding to the attribute name, execute step S317 ( Figure 3 not shown).
[0097] S312: Determine whether the desensitization switch corresponding to the attribute name is in an on state.
[0098] For example, the desensitization switch corresponding to the attribute name can be configured through BOSS. If the desensitization switch corresponding to the attribute name is in the on state, step S313 is executed; if the desensitization switch corresponding to the attribute name is in the off state, step S317 is executed.
[0099] S313: Determine whether the value type of the attribute value is a string type.
[0100] If the value type is a string type, execute steps S314 to S316; if the value type is an object or dictionary type, execute step S304; if the value type is a collection type, for each element in the collection, use the value of the element as the new attribute value and execute step S313; if the value type is other types, execute step S317 ( Figure 3 The collection types include, for example, array[], list List, and set Set.
[0101] S314. Desensitize the attribute value using the desensitization rule corresponding to the attribute name according to the attribute name and the desensitization starting position.
[0102] The desensitization rule of this embodiment can be understood as precise desensitization. For example, Figure 4 A schematic diagram of accurate desensitization classification corresponding to different attribute names provided in an embodiment of the present application, such as Figure 4 As shown, on the configuration interface of the precise desensitizing classification, you can click the virtual control 401 to display different precise desensitizing classifications in the pop-up window 402, and you can choose a precise desensitizing classification such as a mobile phone number. Referring to the example of step S203, assuming that the attribute name is "phone", and the precise desensitizing classification configured for this attribute name is "mobile phone number", then the attribute value "18888888888" can be desensitized according to "mobile phone number" to obtain the desensitized attribute value "1*********8". It can be understood that the built-in precise desensitizing classification can cover most sensitive information types. For more special types: it may be a sensitive field. When performing desensitization, regular expressions can be used to judge the desensitized information. For example, the attribute information of the desensitized object is: "pin":"abc18888888888", and the attribute value is a concatenation of the name and the mobile phone number. At this time, the precise desensitizing classification corresponding to the attribute name can be configured as "sensitive field type" ( Figure 4 (not shown in the figure), so the attribute information after desensitization processing can be obtained as: "pin":"a**1*******888".
[0103] S315. Desensitize the attribute value using the desensitization rule corresponding to the attribute name according to the regular expression corresponding to the attribute name, the desensitization start position, and the desensitization end position.
[0104] The desensitization rules of this embodiment can be understood as regular desensitization. Exemplarily, the regular expression can be customized as needed to configure the desensitization starting position and desensitization ending position. For example, the regular expression corresponding to the landline number is: (0[0-9]{2,3}\-?)[0-9]{7,8}, desensitization starting position: 3, desensitization ending position: 3. Assuming that the attribute value before desensitization is: 000-0000000, the attribute value is desensitized according to the regular expression corresponding to the landline number, the desensitization starting position and the desensitization ending position, and the attribute value after desensitization is: 000-****000.
[0105] S316. Using the desensitization rules corresponding to the attribute names, the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value are input into the desensitization script, and a custom desensitization function is used to desensitize the attribute value.
[0106] The desensitization rules of this embodiment can be understood as script desensitization. In this step, the desensitization rules for complex sensitive information can be customized by writing groovy or python scripts, so that the desensitization method can be made more flexible and can be used to solve more complex sensitive log problems. After the application is started, the custom desensitization script will be compiled. The desensitization script is built-in by default: the application name of the application where the desensitized object is applied, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value, and the output parameter can only be a string. Exemplarily, assuming that the attribute name is the user key name (userKey), the attribute value is the user key value (userValue), and the desensitization rule corresponding to the attribute name may be that when userKey is a specified number of values, desensitization is performed, for example, when userKey is a password (password), a bank card number (bankCard) and an ID number (idNo), the corresponding userValue value needs to be desensitized, then it can be determined by the desensitization script whether to perform desensitization, and the desensitization script is such as a desensitization script written in python language. Among them, userValue can be desensitized by calling the desensitization function. The embodiment of the present application does not limit the implementation logic of the desensitization function, and the corresponding logic code can be written as needed.
[0107] S317. No desensitization treatment is performed.
[0108] In this step, after determining that the desensitized object is not to be desensitized, the desensitized object is output as it is, that is, the original log content is output.
[0109] The log desensitization method provided in the embodiment of the present application receives desensitization configuration information, wherein the desensitization configuration information includes a desensitized object, an attribute name of the desensitized object, and a desensitization rule corresponding to the attribute name; determines whether the desensitization switch of the application where the desensitized object is located in the log is in an on state; if the desensitization switch of the application is in an off state, determines not to perform desensitization processing on the desensitized object; if the desensitization switch of the application is in an on state, obtains the object type of the desensitized object, and if the object type of the desensitized object is an object or a dictionary type, obtains the attribute information corresponding to the desensitized object, and the attribute information includes an attribute name and an attribute value; if the object type of the desensitized object is an object, obtains the desensitization rule corresponding to the attribute name according to the desensitization rule in the cached desensitization configuration information or the desensitization rule in the cached desensitization annotation; if the object type of the desensitized object is a dictionary type, obtains the desensitization rule corresponding to the attribute name according to the desensitization rule in the cached desensitization configuration information. In the case of determining that the desensitization switch corresponding to the attribute name is in the on state, determine whether the value type of the attribute value is a string type. If the value type of the attribute value is a string type, desensitize the attribute value according to the desensitization rule. If the value type of the attribute value is not a string type, perform corresponding processing according to the value type. The embodiment of the present application receives desensitization configuration information, and can realize that the modified desensitization rules can be effective in real time after the desensitization rules are dynamically modified, making the desensitization processing more flexible and convenient; through the desensitization switch of the application where the desensitization object is located and the desensitization switch corresponding to the attribute name, it is possible to flexibly control whether to perform desensitization processing on the application log; when the object type of the desensitization object is an object, the desensitization rules corresponding to the attribute name can be obtained according to the desensitization rules in the cached desensitization configuration or the desensitization rules in the cached desensitization annotation. By providing a variety of desensitization rules, different desensitization rules can be used for different desensitization objects for desensitization processing, so that the log can be desensitized more accurately, effectively reducing the probability of the occurrence of the problem of mis-desensitized logs, especially the script desensitization in the desensitization rules, which can make the desensitization method more flexible and can be used to solve more complex sensitive log problems.
[0110] On the basis of the above embodiment, optionally, if the object type of the desensitized object is an object or dictionary type, it is recursively determined whether there are interdependent object references in the sub-attribute information in the attribute information of the desensitized object, and the dependency link of the desensitized object is recorded; if the dependency link forms a loop, the desensitization processing of the desensitized object is terminated.
[0111] Exemplarily, if the object type is an object or dictionary type, recursively determine whether there are interdependent object references in the sub-attribute information in the attribute information of the desensitized object, and record the dependency link of the desensitized object at the beginning of the recursion. If there is repeated dependent sub-attribute information (i.e., the dependency link forms a loop), then directly jump out of the recursion and end the desensitization processing of the desensitized object. For example, the attribute information of object A references object B, the attribute information of object B references object C, and the attribute information of object C references object A. Objects A, B, and C are interdependent. The dependency link of the desensitized object will cache the record "A:$.ABCA". When repeated references to object A appear, the desensitization processing is terminated to avoid program stack overflow errors.
[0112] On the basis of the above embodiments, taking into account the statistics and display of the results of the desensitization processing, optionally, if the result of the desensitization processing is successful, a desensitized message event is obtained, and the desensitized message event at least includes the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitization count of the attribute name of the desensitized object, and the time of the desensitization processing. The desensitized message event is triggered asynchronously; the desensitized message event is cached to output the desensitized message event when the number of desensitized message events is greater than or equal to the quantity threshold.
[0113] This embodiment can be understood as outputting desensitized message events through the desensitization collector in the desensitization SDK, and the desensitization collector can be initialized with the startup of the application. If the result of the desensitization process is desensitization success, then asynchronous desensitization message events are sent inside the desensitization SDK, and the desensitization message events can be implemented based on the event listener (EventListener) interface in JDK (a software development kit of Java language). Desensitization message events can be received by the asynchronous listener in the desensitization collector, and the desensitization message events are temporarily stored in the cache. When the number of cached desensitization message events is greater than or equal to the quantity threshold (such as 500), the 500 desensitization message events are pushed to the desensitization service end (such as BOSS) by the asynchronous thread. After receiving the 500 desensitization message events, the desensitization service end can store the 500 desensitization message events in the database and perform statistics, and the statistical results are displayed in the desensitization statistics page, and users (such as administrators) can see the desensitization count of a certain application, a certain class name, a certain desensitization field (i.e., attribute name) and the time and other information of desensitization process. It can be understood that in the internal maintenance of the desensitizing SDK, asynchronous collection of successfully desensitized message events will not block the main process of the application. Desensitized message events can be collected and counted more efficiently through batch notifications.
[0114] Based on the above embodiments, Figure 5 A schematic diagram of a design scheme for a log desensitization method provided in an embodiment of the present application. Figure 5As shown, users can configure desensitization rules through BOSS. After configuring the desensitization rules according to the application name of the application where the desensitized object is located, the object class name of the desensitized object, and the attribute name of the desensitized object, the desensitization rules are stored in the database, where the desensitization rules include at least one of precise desensitization, regular desensitization, and script desensitization; users can publish desensitization rules or roll back desensitization rules if errors occur in the desensitization rule configuration. The configured desensitization rules can be pushed to the application by means of message broadcasting, so that the configured desensitization rules can be cached locally in the application. Figure 5 Taking nacos as an example, the configured desensitization configuration information is pushed to the nacos client through the nacos server, that is, the application that integrates the desensitization SDK. Figure 5 Take application A, application B and application C that integrate desensitization SDK as examples. In order to ensure the accuracy of the updated desensitization configuration information pushed by nacos, a timer can also be set to synchronize the updated desensitization configuration information to the local cache of the application in a timely manner. The application integrates desensitization SDK, which is written based on SpringBoot-stater (a set of predefined dependency sets). The desensitization SDK performs desensitization on the desensitized objects in the log. Specifically, the attribute information corresponding to the desensitized object in the log is obtained, and the attribute information includes the attribute name and the attribute value; the desensitization rule discriminator is used to determine whether the cached desensitization configuration contains the desensitization rule corresponding to the attribute name; if the cached desensitization configuration contains the desensitization rule corresponding to the attribute name, the attribute value is desensitized according to the desensitization rule. It is also possible to flexibly control whether the application log is desensitized by the desensitization switch of the application where the desensitized object is located and the desensitization switch corresponding to the attribute name.
[0115] based on Figure 5 , Figure 6 A schematic diagram of the software architecture of the log desensitization method provided in one embodiment of the present application. Figure 6As shown, the application integrates the desensitizing SDK, performs system management through BOSS (such as managing applications, etc.), configures the desensitizing rules of the application where the desensitizing object is located, manages the desensitizing rule version, and pushes the configured desensitizing rules to the nacos client (that is, the application that integrates the desensitizing SDK) through the nacos server. By counting and displaying the results of the desensitizing processing, the desensitizing processing of the application log is monitored, and in the event of an error in the desensitizing rule configuration, the desensitizing rules can be rolled back. The application log is desensitized through the desensitization SDK. Specifically, the desensitized objects in the log are desensitized according to different desensitization rules, and the desensitization rules include at least one of precise desensitization, regular desensitization and script desensitization; the desensitization switch of the application where the desensitized object is located and the desensitization switch corresponding to the attribute name can also be used to flexibly control whether to desensitize the application log; the desensitization collector in the desensitization SDK can also output desensitized message events for statistics and display; the listener in the desensitization SDK can also periodically send request messages to BOSS to synchronize the updated desensitization configuration information to the local cache of the application in a timely manner. Among them, the relevant data configured in BOSS can be persistently stored in the database, such as MySQL (a relational database management system), and the updated desensitization configuration information is pulled from the database through the nacos server and pushed to the local cache of the application integrated with the desensitization SDK. The desensitization SDK performs related desensitization processing based on local memory operations, without remote interactive calls, which can greatly reduce network overhead. There is no lock competition blocking the main process of the application. For the logic that requires network interaction, asynchronous process processing will be enabled, such as collectors, desensitization configuration information updates, and desensitization script compilation.
[0116] based on Figure 6 , Figure 7 This is a modular functional diagram of a log desensitization method provided in an embodiment of the present application. Figure 7 As shown, BOSS can include a system management module, a desensitization rule version management module, a desensitization configuration rollback module, a desensitization rule configuration module, a desensitization configuration push module, and a desensitization monitoring module for counting and displaying desensitized message events. The desensitization SDK can include a desensitization switch module, a precise desensitization module, a regular desensitization module, a script desensitization module, a listener, and a collector. The application uses the microservice framework SpringBoot service, introduces an open source log component (logback), integrates the desensitization SDK, and caches the desensitization configuration locally. Figure 7 The specific functions of each module can be found in Figure 6 The relevant description of the illustrated embodiment will not be repeated here.
[0117] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0118] Figure 8 A structural diagram of a log desensitization device provided in an embodiment of the present application is shown in FIG. Figure 8 As shown, the log desensitization device 800 of the embodiment of the present application includes: a receiving module 801, an acquisition module 802 and a processing module 803. Among them:
[0119] The receiving module 801 is used to receive desensitization configuration information, where the desensitization configuration information includes a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name.
[0120] The acquisition module 802 is used to obtain the attribute information of the desensitized object in the log, and the attribute information includes the attribute name and the attribute value.
[0121] The processing module 803 is used to perform desensitization processing on the attribute value according to the attribute name of the desensitization object and using the desensitization rule corresponding to the attribute name.
[0122] In some embodiments, the receiving module 801 may be specifically used to: receive desensitization configuration information pushed based on a message broadcast mechanism or desensitization matching information obtained through a listener.
[0123] In some embodiments, the receiving module 801 can be specifically used for: if the desensitizing configuration information is the newly created first desensitizing configuration information, then caching the first desensitizing configuration information, the first desensitizing configuration information includes the first attribute name and the desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the first version number; if the first desensitizing configuration information is updated to the second desensitizing configuration information, the second desensitizing configuration information includes the first attribute name and the desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the second version number, if the first version number is inconsistent with the second version number, then the desensitizing rule corresponding to the first attribute name is updated to the cache.
[0124] In some embodiments, the processing module 803 can be specifically used for at least one of the following: desensitizing the attribute value according to the attribute name and the desensitization starting position; desensitizing the attribute value according to the regular expression corresponding to the attribute name, the desensitization starting position and the desensitization ending position; inputting the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value into the desensitization script, and using a custom desensitization function to desensitize the attribute value.
[0125] Optionally, the acquisition module 802 may also be used for: if the object type of the desensitized object is object, and the desensitized object has a desensitizing annotation, then caching the desensitization rules in the desensitizing annotation.
[0126] Optionally, the acquisition module 802 can also be used for: if the object type of the desensitizing object is object, and the cached desensitizing configuration information does not contain the desensitizing rule corresponding to the attribute name, then determine that the desensitizing rule in the cached desensitizing annotation is the desensitizing rule corresponding to the attribute name.
[0127] In some embodiments, the processing module 803 can be specifically used to: obtain the value type of the attribute value; if the value type is a string type and the desensitization switch corresponding to the attribute name is in the on state, the attribute value is desensitized using the desensitization rule corresponding to the attribute name; if the value type is a collection type, then for each element in the collection, the value of the element is used as the new attribute value, and the step of obtaining the value type of the attribute value is executed; if the value type is an object or dictionary type, the attribute value is used as a new desensitized object, and the step of obtaining the attribute information of the desensitized object in the log is executed through the acquisition module 802.
[0128] Optionally, the processing module 803 can also be used for: if the object type of the desensitized object is an object or dictionary type, recursively determine whether there are interdependent object references in the sub-attribute information in the attribute information of the desensitized object, and record the dependency link of the desensitized object; if the dependency link forms a loop, end the desensitization processing of the desensitized object.
[0129] Optionally, the processing module 803 can also be used for: if the result of the desensitization processing is successful, then obtain a desensitized message event, the desensitized message event includes at least the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitization count of the attribute name of the desensitized object, and the time of the desensitization processing, and the desensitized message event is triggered asynchronously; cache the desensitized message event to output the desensitized message event when the number of desensitized message events is greater than or equal to the quantity threshold.
[0130] In some embodiments, the acquisition module 802 may be specifically used for: if the desensitization switch of the application where the desensitized object is located is in an on state, then acquiring the attribute information of the desensitized object in the log.
[0131] The device of the present application can be used to execute the technical solution of any of the above-mentioned method embodiments, and its implementation principle and technical effects are similar, which will not be repeated here.
[0132] Fig. 9 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Fig. 9 As shown, the electronic device 900 may include: at least one processor 901 and a memory 902 .
[0133] The memory 902 is used to store programs. Specifically, the programs may include program codes, and the program codes include computer-executable instructions.
[0134] The memory 902 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0135] The processor 901 is used to execute the computer execution instructions stored in the memory 902 to implement the log desensitization method described in the aforementioned method embodiment. Among them, the processor 901 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. Specifically, when implementing the log desensitization method described in the aforementioned method embodiment, the electronic device can be, for example, an electronic device with processing functions such as a server.
[0136] Optionally, the electronic device 900 may further include a communication interface 903. In a specific implementation, if the communication interface 903, the memory 902 and the processor 901 are implemented independently, the communication interface 903, the memory 902 and the processor 901 may be interconnected through a bus and communicate with each other. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.
[0137] Optionally, in a specific implementation, if the communication interface 903, the memory 902 and the processor 901 are integrated on a chip, the communication interface 903, the memory 902 and the processor 901 can communicate through an internal interface.
[0138] The present application also provides a computer-readable storage medium, in which computer program instructions are stored. When a processor executes the computer program instructions, the above log desensitization method is implemented.
[0139] The present application also provides a computer program product, including a computer program, which implements the above log desensitization method when executed by a processor.
[0140] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0141] An exemplary readable storage medium is coupled to the processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in a dedicated integrated circuit. Of course, the processor and the readable storage medium can also exist as discrete components in the log desensitization device.
[0142] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0143] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A log desensitization method, characterized in that: include: Receive desensitization configuration information, the desensitization configuration information including a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name; Obtaining attribute information of the desensitized object in the log, the attribute information including the attribute name and attribute value; According to the attribute name of the desensitized object, the attribute value is desensitized using the desensitization rule corresponding to the attribute name.
2. The log desensitization method according to claim 1, characterized in that: The receiving desensitization configuration information includes: Receive desensitization configuration information pushed based on the message broadcast mechanism or desensitization matching information obtained through the listener.
3. The log desensitization method according to claim 2, characterized in that: The receiving desensitization configuration information includes: If the desensitizing configuration information is newly created first desensitizing configuration information, the first desensitizing configuration information is cached, wherein the first desensitizing configuration information includes a first attribute name and a desensitizing rule corresponding to the first attribute name, and the version number of the desensitizing rule is the first version number; If the first desensitizing configuration information is updated to the second desensitizing configuration information, the second desensitizing configuration information includes the first attribute name and the desensitizing rules corresponding to the first attribute name, and the version number of the desensitizing rules is the second version number. If the first version number is inconsistent with the second version number, the desensitizing rules corresponding to the first attribute name are updated to the cache.
4. The log desensitization method according to claim 1, characterized in that: The desensitizing the attribute value according to the attribute name of the desensitized object and using the desensitizing rule corresponding to the attribute name includes at least one of the following: Desensitizing the attribute value according to the attribute name and the desensitization starting position; Desensitize the attribute value according to the regular expression, desensitization start position and desensitization end position corresponding to the attribute name; The application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitized object, the attribute name and the attribute value are input into a desensitization script, and a custom desensitization function is used to perform desensitization processing on the attribute value.
5. The log desensitization method according to claim 3, characterized in that: Also includes: If the object type of the desensitized object is object, and a desensitizing annotation exists for the desensitized object, the desensitizing rules in the desensitizing annotation are cached.
6. The log desensitization method according to claim 5, characterized in that: Also includes: If the object type of the desensitized object is object, and the cached desensitization configuration information does not include the desensitization rule corresponding to the attribute name, then the desensitization rule in the cached desensitization annotation is determined to be the desensitization rule corresponding to the attribute name.
7. The log desensitization method according to claim 6, characterized in that: The desensitizing the attribute value according to the attribute name of the desensitized object and using the desensitizing rule corresponding to the attribute name includes: Get the value type of the attribute value; If the value type is a string type and the desensitization switch corresponding to the attribute name is in the on state, the attribute value is desensitized using the desensitization rule corresponding to the attribute name; If the value type is a set type, for each element in the set, the value of the element is used as a new attribute value, and the step of obtaining the value type of the attribute value is performed; If the value type is an object or a dictionary type, the attribute value is used as a new desensitized object, and the step of obtaining the attribute information of the desensitized object in the log is performed.
8. The log desensitization method according to claim 7, characterized in that: Also includes: If the object type of the desensitized object is an object or a dictionary type, recursively determine whether the sub-attribute information in the attribute information of the desensitized object has mutually dependent object references, and record the dependency link of the desensitized object; If the dependent link forms a loop, the desensitization processing of the desensitized object is terminated.
9. The log desensitization method according to any one of claims 1 to 8, characterized in that: Also includes: If the result of the desensitization processing is that the desensitization is successful, a desensitization message event is obtained, and the desensitization message event at least includes the application name of the application where the desensitized object is located, the object class name of the desensitized object, the desensitization count of the attribute name of the desensitized object, and the time of the desensitization processing. The desensitization message event is triggered asynchronously; The desensitized message events are cached to output the desensitized message events when the number of the desensitized message events is greater than or equal to a number threshold.
10. The log desensitization method according to any one of claims 1 to 8, characterized in that: The obtaining of attribute information of the desensitized object in the log includes: If the desensitization switch of the application where the desensitized object is located is in the turned-on state, the attribute information of the desensitized object in the log is obtained.
11. A log desensitization device, characterized in that: include: A receiving module, used to receive desensitization configuration information, wherein the desensitization configuration information includes a desensitization object, an attribute name of the desensitization object, and a desensitization rule corresponding to the attribute name; An acquisition module, used to acquire the attribute information of the desensitized object in the log, wherein the attribute information includes the attribute name and attribute value; The processing module is used to perform desensitization processing on the attribute value according to the attribute name of the desensitized object and using the desensitization rule corresponding to the attribute name.
12. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the log desensitization method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the log desensitization method according to any one of claims 1 to 10 is implemented.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed, the log desensitization method according to any one of claims 1 to 10 is implemented.
