Log desensitization method and device
By identifying and replacing sensitive data in logs through preset sensitive data field pools and desensitization rules, the problem of leakage of user personal information in the log system is solved, desensitization of logs is achieved, and the security of user privacy is ensured.
Patent Information
- Application Number
- CN202210329961.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2042-03-31
AI Technical Summary
Existing technology is difficult to effectively protect users' personal information from being leaked in the log system, resulting in users' private information being exposed on the Internet platform.
By presetting the field pool and desensitization rules of sensitive data, the sensitive data existing in the log is identified and replaced to achieve desensitization of the log and avoid direct exposure of sensitive information during the printing process.
It effectively protects users' sensitive information and prevents it from being printed directly in the log, ensuring the security of user privacy.
Smart Images

Figure CN114707180B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a log desensitization method and device. Background Art
[0002] With the rapid development of Internet business, the protection of personal information of users of various online platforms, such as user name, ID number, mobile phone number, bank card number, residential address and email address, etc., which involves user privacy, has become particularly important.
[0003] However, due to business needs, the online platform system usually records the personal information entered by users on the Internet page directly into the system log of the online platform. Therefore, how to provide a log desensitization method to avoid the leakage of user personal information still requires further solutions. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a log desensitization method and device for avoiding the leakage of user personal information during the log printing process.
[0005] In a first aspect, a log desensitization method is provided, including:
[0006] Get the target log to be printed;
[0007] Determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in the field pool of sensitive data;
[0008] Based on the desensitization rules corresponding to the multiple preset categories of sensitive data, desensitize the data to be desensitized to obtain desensitized data;
[0009] The data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
[0010] In a second aspect, a log desensitization device is provided, including:
[0011] The log acquisition module is used to obtain the target log to be printed;
[0012] A data determination module, used to determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in a field pool of sensitive data;
[0013] A desensitization processing module, used for performing desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the sensitive data of the plurality of preset categories, to obtain desensitized data;
[0014] The log desensitization module is used to replace the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log and print the desensitized target log.
[0015] In a third aspect, an electronic device is provided, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and when the computer program is executed by the processor, the steps of the log desensitization method of the first aspect are implemented.
[0016] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the log desensitization method of the first aspect are implemented.
[0017] In an embodiment of the present application, before the log is printed, based on multiple preset categories of sensitive data in a pre-set field pool of sensitive data, sensitive data existing in the log, i.e., data to be desensitized, can be determined, and then based on the desensitization rules corresponding to the multiple preset categories of sensitive data, the data to be desensitized can be desensitized to obtain desensitized data. Finally, the data to be desensitized in the log is replaced with the desensitized data to obtain a desensitized log, and the desensitized log is printed, thereby avoiding the data involving user sensitive information in the log from being directly printed out, and effectively protecting the user's sensitive information. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0019] Figure 1 It is a flowchart of a log desensitization method provided by an embodiment of the present application.
[0020] Figure 2 This is an example diagram of an actual scenario of the application of the log desensitization method provided by an embodiment of the present application.
[0021] Figure 3 It is a detailed flowchart of an actual scenario of the application of the log desensitization method provided by an embodiment of the present application.
[0022] Figure 4 It is a structural schematic diagram of a log desensitization device provided by an embodiment of the present application.
[0023] Figure 5 It is a structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than 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. The numbering of the drawings in this application is only used to distinguish the various steps in the scheme, and is not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.
[0025] As described in the background technology, after the user enters personal information, the system of the online platform often directly prints the personal information entered by the user into the log. This makes the personal information entered by the user completely exposed in the printed log, which is easy to cause the leakage of the user's personal information.
[0026] In view of this, an embodiment of the present application provides a log desensitization method, which can classify and enumerate sensitive data that may appear in the log and store them in the field pool of sensitive data, and create corresponding desensitization rules for each type of sensitive data. At the same time, the log printing method is rewritten so that before the log is printed, the desensitized data that matches the category of sensitive data stored in the field pool of sensitive data in the log can be obtained as the input parameter data of the rewritten log printing method, so as to desensitize these desensitized data through the corresponding desensitization rules, and replace the desensitized data with the desensitized data, and finally print the desensitized log. It avoids the data involving user sensitive information in the log from being directly printed, and effectively protects the user's sensitive information.
[0027] First, introduce the concepts of NodeJS, JSON, key-value pairs, JSON.parse() method, and JSON.stringify() method:
[0028] NodeJS: Node.js is a JavaScript runtime environment based on the Chrome V8 engine.
[0029] JSON: JSON stands for JavaScript Object Notation, a lightweight data exchange format. It is based on a subset of ECMAScript (the full name in Chinese is the js specification developed by the European Computer Association) and uses a text format that is completely independent of the programming language to store and represent data.
[0030] Key-value pair: It can be written as key+value in English, abbreviated as k+v, which refers to a field and value of JSON data, such as: {"name":"Zhang San","age":20}, where name and age are both key names, and Zhang San and 20 are both key values corresponding to the key name.
[0031] JSON.parse() method: It is a JSON string parsing method used to convert data into JavaScript objects.
[0032] JSON.stringify() method: is a JSON string conversion method used to convert a JavaScript object into a JSON string.
[0033] The present application embodiment provides a log desensitization method, which is applied to a log desensitization device. Figure 1 As shown, the solution provided by the embodiment of the present application includes:
[0034] S110, obtaining a target log to be printed.
[0035] Among them, the target log to be printed is the target log obtained when the user enters information containing personal information on the page when handling online business and initiates the API request of the page. At this time, the target log has not yet been printed to the log system.
[0036] Normally, when users handle online business, they often need to fill in personal information, such as mobile phone number, ID number, home address, email address, and other sensitive information involving the user's personal privacy. After the user completes the filling of such sensitive information and initiates the API request for the page, in order to avoid this information being completely printed in the log, the embodiment of the present application can obtain the target log to be printed each time the user initiates the API request for the page, and when it is determined that there is sensitive information in the target log, the sensitive information is desensitized to protect the sensitive information involving the user's personal privacy in the page.
[0037] S120, determining the data to be desensitized in the target log based on multiple preset categories of sensitive data in the field pool of sensitive data.
[0038] It should be understood that in order to improve the efficiency of determining sensitive information in the target log, the embodiment of the present application can pre-enumerate all possible categories of sensitive data and corresponding sensitive data rules, and record these categories of sensitive data and corresponding sensitive data rules in the field pool of sensitive data. For example, the sensitive data rule of the ID card number is usually composed of 18 digits or 17 digits and a letter X, the sensitive data rule of the mobile phone number is usually composed of 11 digits, and the sensitive data rule of the email address is usually composed of letters such as @ and .com or .cn. Specifically, based on multiple preset categories of sensitive data in the field pool of sensitive data, the data to be desensitized in the target log is determined, including:
[0039] The target log is traversed to determine the data to be desensitized that matches the sensitive data rules of multiple preset categories of sensitive data in the target log.
[0040] As an example, assuming that the target log contains a mobile phone number and an ID card number, you can traverse the target log and match the data in the target log one by one with the sensitive data rules of multiple preset categories of sensitive data in the field pool of sensitive data, and determine the data to be desensitized in the target log that matches the sensitive data rules of multiple preset categories of sensitive data.
[0041] Optionally, the target log may include two types of data, one is key-value pair type data, that is, including key and value, and the other is data with only key value but no key name, that is, only including value. In order to improve the security of the desensitized log and avoid data involving sensitive information from being missed during the desensitization process, the preset sensitive data features in the embodiment of the present application may include sensitive key name identifiers and sensitive key value features. Specifically, the sensitive data of the multiple preset categories include sensitive key value identifiers and sensitive key values, traverse the target log, and determine the data to be desensitized in the target log that matches the sensitive data rules of the sensitive data of the multiple preset categories, including:
[0042] Traverse the target log and obtain the key-value pair data in the target log;
[0043] Determine, from the key-value pair data, target key-value pair data that matches the sensitive key-value identifier in the sensitive key-value pair data; and
[0044] Obtain target key value data matching the sensitive data rule of the sensitive key value from the target log excluding the target key value pair data;
[0045] Based on the key-value data in the target key-value pair data and the target key-value data, the data to be desensitized in the target log is determined.
[0046] As an example, sensitive key name identifiers may include key name identifiers of names, key name identifiers of mobile phone numbers, key name identifiers of ID card numbers, key name identifiers of bank card numbers, key name identifiers of email addresses, and key name identifiers of home addresses. Among them, the key name identifier of names may be represented as "name" or "username", the key name identifier of mobile phone numbers may be represented as "mobile" or "mobilephone", the key name identifier of ID card numbers may be represented as "idNo" or "IDNUM", the key name identifier of bank card numbers may be represented as "bankCardNo", the key name identifier of email addresses may be represented as "e-add" or "emailaddress", and the key name identifier of home addresses may be represented as "add" or "address".
[0047] As an example, the sensitive data rules of sensitive key values may include the sensitive data rules of names, mobile phone numbers, ID card numbers, bank card numbers, and email addresses. Among them, the sensitive data rule of names is composed of 2 to 4 Chinese characters, the sensitive data rule of mobile phone numbers is composed of 11 digits starting with 1, the sensitive data rule of ID card numbers is composed of 18 digits or 17 digits plus 1 x or X, the sensitive data rule of bank card numbers is composed of 14 to 19 digits, the sensitive data rule of email addresses is composed of any character at the beginning + @ symbol + letters or numbers + decimal point + letters, and the sensitive data rule of home addresses is composed of characters including province, city, county / district, etc.
[0048] As an example, assume that the target log contains an array: ["189012345678", "501234123412341234", "621234123412341234", "hello world", {userName: "Zhang San", userMobile: "189012345678"}]. Traverse this array. First, obtain the key-value pair data "userName: Zhang San" and "userMobile: 189012345678" in the target log. Then, from these two key-value pair data, determine the target key-value pair data "userName: Zhang San" and "userMobile: 189012345678" that match the sensitive key name identifier, and the log in the target log excluding the target key-value pair data: "189012345678", "501234123412341234", "621234123412341234", "hello world". Obtain the target key-value data "189012345678", "501234123412341234", "621234123412341234" that match the sensitive data rules of the sensitive values of the sensitive data.
[0049] As an example, if the target log contains a JSON object or an array containing a JSON object, then based on the sensitive data rules of multiple preset categories of sensitive data in the field pool of sensitive data, match them one by one with the JSON object or the array containing the JSON object in the target log to determine the data to be desensitized in the target log. And if the JSON object or the array containing the JSON object is nested with another JSON object or an array containing a JSON object, then continue to judge the nested JSON object or the array containing the JSON object, and match the nested JSON object or the array containing the JSON object one by one with the sensitive data rules corresponding to multiple preset categories of sensitive data to determine the data to be desensitized contained in the nested JSON object or the array containing the JSON object, until all the data to be desensitized in the target log is determined.
[0050] S130. Based on the desensitization rules corresponding to multiple preset categories of sensitive data, desensitize the data to be desensitized to obtain the desensitized data.
[0051] As an example, the desensitization rule for sensitive data of the name type is to only display the first character, and replace the other characters with x or *. The desensitization rule for sensitive data of the mobile phone number type is to display the first 3 and the last 4 digits, and replace the other digits with x or *. The desensitization rule for sensitive data of the ID card number type is to display the first 4 and the last 4 digits, and replace the other digits with x or *. The desensitization rule for sensitive data of the email address type is to display the first character, and replace the other characters with x or *. The desensitization rule for sensitive data of the home address type is to only display up to the city, county / district, and replace the other characters with x or *.
[0052] As an example, assume the data to be desensitized is the string: msdemo@msxf.com. By matching the type of the data to be desensitized, it is determined that the data to be desensitized is sensitive data of the email address type. Then, the desensitization rule corresponding to the sensitive data of the email address type can be used to desensitize the data to be desensitized and obtain m*****@msxf.com.
[0053] As another example, assume the data to be desensitized is an array: ["189012345678", "501234123412341234", "621234123412341234", "hello world", {userName: "张三", userMobile: "188012345678"}]. Traverse this array and match the type of the data to be desensitized. It is found that the data to be desensitized "189012345678" and "188012345678" are sensitive data of the mobile phone number type, the data to be desensitized "501234123412341234" is sensitive data of the ID card number type, the data to be desensitized "621234123412341234" is sensitive data of the bank card number type, and the data to be desensitized "张三" is sensitive data of the name type. Then, use the desensitization rules corresponding to the sensitive data of the mobile phone number type, the ID card number type, the ID card number type, the bank card number type, and the name type to desensitize the corresponding data to be desensitized in sequence, and obtain ["189****2212", "5****************x", "6212**********4510", "hello world", {username: "张*", userMobile: "188****7766"}].
[0054] Optionally, when the type of the data to be desensitized is a JSON object or an array containing a JSON object, in order to avoid the problem of direct reference to the desensitized data after the desensitization processing when the desensitized data is subsequently used, resulting in a reference error, the embodiment of the present application can perform a deep copy of such data to be desensitized, and perform desensitization processing on the deeply copied data to be desensitized. Specifically, based on the desensitization rules corresponding to multiple preset categories of sensitive data, the data to be desensitized is desensitized to obtain the desensitized data, including:
[0055] Determine the type of data to be desensitized;
[0056] If the type of the data to be desensitized is a JSON object or an array containing a JSON object, the data to be desensitized is deeply copied to obtain the copied data to be desensitized;
[0057] Determine the desensitization rules corresponding to the data to be desensitized based on the desensitization rules corresponding to multiple preset categories of sensitive data;
[0058] Based on the desensitization rules corresponding to the data to be desensitized, the copied data to be desensitized is desensitized to obtain desensitized data.
[0059] Among them, deep copying is to reallocate the address of the newly applied variable and assign the data to be desensitized to the newly applied variable, so that the desensitized data will not affect the newly applied variable after desensitization, thereby avoiding the problem of directly referencing the desensitized data when using the data to be desensitized later, resulting in reference errors.
[0060] As an example, if the type of the data to be desensitized is a JSON object or an array containing a JSON object, the data to be desensitized is deeply copied to obtain the copied data to be desensitized, and then the copied data to be desensitized is matched one by one with the desensitization rules corresponding to multiple preset categories of sensitive data to determine the desensitization rules corresponding to the data to be desensitized. If the copied data to be desensitized contains a JSON object or an array containing a JSON object, the JSON object or array containing a JSON object in which the copied data to be desensitized is deeply copied, and the copied JSON object or array containing a JSON object is matched one by one with the desensitization rules corresponding to multiple preset categories of sensitive data to determine the desensitization rules corresponding to the data to be desensitized, until the desensitization rules corresponding to all the sensitive data in the data to be desensitized are matched.
[0061] Optionally, when the type of the data to be desensitized is a JSON string or an array containing a JSON string, since the JSON string or the array containing a JSON string cannot be traversed, such data should be parsed using a JSON string parsing method, that is, its format is converted to obtain a JavaScript object that can be traversed. Specifically, based on the desensitization rules corresponding to multiple preset categories of sensitive data, the data to be desensitized is desensitized to obtain the desensitized data, including:
[0062] If the type of the data to be desensitized is a JSON string or an array containing a JSON string, the data to be desensitized is parsed using a JSON string parsing method to obtain the parsed data to be desensitized;
[0063] Determine the desensitization rules corresponding to the data to be desensitized based on the desensitization rules corresponding to multiple preset categories of sensitive data;
[0064] Based on the desensitization rules corresponding to the data to be desensitized, the parsed data to be desensitized is desensitized to obtain desensitized data.
[0065] The JSON string parsing method may be represented as a JSON.parse() method, which may convert a JSON string or other data containing a JSON string into a JavaScript object.
[0066] Figure 2 This is an example diagram of an actual scenario of the application of the log desensitization method provided by an embodiment of the present application, including:
[0067] S21, obtaining the target log to be desensitized.
[0068] S22, determining whether the target log contains a JSON object, an array containing a JSON object, a JSON string, and an array containing a JSON string.
[0069] If the target log contains a JSON object, an array containing a JSON object, a JSON string, and an array containing a JSON string, execute S23; otherwise, execute S26.
[0070] S23, parsing the target log.
[0071] Deeply copy the JSON objects and arrays containing JSON objects in the target log, and convert the JSON strings and arrays containing JSON strings in the target log to JavaScript objects.
[0072] S24, determining whether the key name in the key-value pair in the parsed target log is in the sensitive key name identifier.
[0073] If it is determined that the key name in the key-value pair in the parsed target log is in the sensitive key name identifier, then execute S25.
[0074] S25, perform desensitization processing using the desensitization rule of the sensitive data corresponding to the sensitive key name identifier.
[0075] S26, determine whether it matches the sensitive key-value feature.
[0076] If it is determined that it matches the sensitive key-value feature, then execute S27.
[0077] S27, perform desensitization processing using the desensitization rule of the sensitive data corresponding to the sensitive key-value feature.
[0078] S140, replace the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
[0079] Optionally, replacing the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log includes:
[0080] Replace the key-value data and the target key-value data in the target key-value pair data in the target log with their respective corresponding desensitized data to obtain the desensitized target log.
[0081] As an example, assume that the target log contains an array: ["189012345678", "501234123412341234", "621234123412341234", "hello world", {userName: "张三", userMobile: "188012345678"}]. After performing desensitization processing on the data to be desensitized in the target log to obtain "189****2212", "5****************x", "6228**********4510", "张*", and "188****7766", the key-value data in the key-value pair data in the target log corresponding to the sensitive key name, as well as the target key-value data, can be replaced with their respective corresponding desensitized data to obtain the desensitized target log as ["189****2212", "5****************x", "6212**********4510", "hello world", {username: "张*", userMobile: "188****7766"}].
[0082] Optionally, after desensitization, in order to restore the JSON string converted into a JavaScript object and facilitate subsequent processing of the data in the original target log, the embodiment of the present application can convert the desensitized data into a desensitized string through a JSON string conversion method. Specifically, the data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, including:
[0083] Convert the desensitized data into a desensitized string using the JSON string conversion method;
[0084] The data to be desensitized in the target log is replaced with the desensitized string to obtain the desensitized target log.
[0085] The JSON string conversion method may be represented as the JSON.stringify() method, which is used to convert a JavaScript value into a JSON string.
[0086] Figure 3 This is a detailed flow chart of an actual scenario of the application of the log desensitization method provided by an embodiment of the present application, including:
[0087] S31, enumerate the categories of data to be desensitized, such as: name, mobile phone number, email address, bank card number, ID card number, etc.
[0088] S32, creating a sensitive data field pool and sensitive data rules according to the category of the data to be desensitized.
[0089] The sensitive data field pool stores all possible categories of data to be desensitized, including sensitive data such as name, mobile phone number, email address, bank card number, ID card number, and home address. The sensitive data rules of sensitive data indicate the composition rules of sensitive data. For example, the sensitive data rule for sensitive data such as name is composed of 2 to 4 Chinese characters, and the sensitive data rule for sensitive data such as mobile phone number is composed of 11 numbers starting with 1, and so on.
[0090] S33, creating corresponding desensitization rules according to the field pool of sensitive data and sensitive data rules.
[0091] For example, the desensitization rule for sensitive data such as names is to display only the first character, and replace other characters with x or *; the desensitization rule for sensitive data such as mobile phone numbers is to display the first 3 and last 4 digits, and replace other digits with x or *; the desensitization rule for sensitive data such as ID card numbers is to display the first 4 and last 4 digits, and replace other digits with x or *; the desensitization rule for sensitive data such as email addresses is to display the first character, and replace other characters with x or *; the desensitization rule for sensitive data such as home addresses, etc.
[0092] S34, rewrite the log printing method.
[0093] That is, before the log is printed, a log desensitization process is added to obtain the input parameter data in the log to be printed, and determine whether the input parameter data contains the data to be desensitized.
[0094] S35, obtaining input parameter data of the log to be printed.
[0095] S36, determining the data type of the input parameter data of the log to be printed.
[0096] If it is a JSON string or an array including a JSON string, execute S37; if it is a JSON object or an array including a JSON object, execute S38; if it is another data type, execute S321.
[0097] S37, use the JSON.parse method to parse the input data to obtain new data.
[0098] S38, deeply copy the input parameter data to obtain new data.
[0099] S39, determining the data type of the new data.
[0100] If the data type of the new data is an array, S310 is executed; if the data type of the new data is a JSON object, S311 is executed.
[0101] S310, looping to determine the data type of each item of data in the array.
[0102] S311, recursively parse all keys in the JSON object.
[0103] S312, determine the data type.
[0104] If the data type is a JSON object, execute S311; if the data type is an array, execute S310; if the data type is another data type, execute S321.
[0105] S313, determine whether the key is in the field pool of sensitive data.
[0106] If it is determined that the key is in the field pool of sensitive data, execute S315; if it is determined that the key is not in the field pool of sensitive data, execute S314.
[0107] S314, obtain the value corresponding to the key.
[0108] S315, determining the corresponding desensitization rule.
[0109] S316, use the desensitization rule to desensitize the value of key in the new data to obtain value1.
[0110] S317, replace the value of key in the new data with value1.
[0111] S318, until the recursion ends, new data after desensitization processing is obtained.
[0112] S319, determining whether to convert the new data after the desensitization processing back into a character string.
[0113] If it is determined that the new data after the desensitization processing needs to be converted back into a string, S320 is executed. If it is determined that the new data after the desensitization processing does not need to be converted back into a string, S324 is executed.
[0114] S320, use the JSON.stringify method to convert the new data after the desensitization processing into a string.
[0115] S321, whether to match the sensitive data rule.
[0116] If it is determined that there is a matching sensitive data rule, S322 is executed; if it is determined that there is no matching sensitive data rule, S324 is executed.
[0117] S322, determine the desensitization rule corresponding to the sensitive data rule.
[0118] S323, use the desensitization rules to desensitize the input data.
[0119] In an embodiment of the present application, before the log is printed, based on multiple preset categories of sensitive data in a pre-set field pool of sensitive data, sensitive data existing in the log, i.e., data to be desensitized, can be determined, and then based on the desensitization rules corresponding to the multiple preset categories of sensitive data, the data to be desensitized can be desensitized to obtain desensitized data. Finally, the data to be desensitized in the log is replaced with the desensitized data to obtain a desensitized log, and the desensitized log is printed, thereby avoiding the data involving user sensitive information in the log from being directly printed out, and effectively protecting the user's sensitive information.
[0120] In order to solve the problems existing in the prior art, such as Figure 4 As shown, the embodiment of the present application also provides a log desensitization device 400, including:
[0121] The log acquisition module 410 is used to acquire the target log to be printed;
[0122] A data determination module 420, configured to determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in a field pool of sensitive data;
[0123] The desensitization processing module 430 is used to perform desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the sensitive data of the plurality of preset categories to obtain desensitized data;
[0124] The log desensitizing module 440 is used to replace the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
[0125] The log desensitizing device provided by the embodiment of the present application can determine the sensitive data to be desensitized existing in the log based on multiple preset categories of sensitive data in a pre-set field pool of sensitive data before the log is printed, and then perform desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data to obtain desensitized data. Finally, the data to be desensitized in the log is replaced with the desensitized data to obtain the desensitized log, and the desensitized log is printed, thereby avoiding the data involving user sensitive information in the log from being directly printed out, and effectively protecting the user's sensitive information.
[0126] Optionally, in one implementation, the data determination module 420 is used to:
[0127] The target log is traversed to determine the data to be desensitized that matches the sensitive data rules of the multiple preset categories of sensitive data in the target log.
[0128] Optionally, in one implementation, the data determination module 420 is used to:
[0129] Traversing the target log to obtain key-value pair data in the target log;
[0130] Determining, from the key-value pair data, target key-value pair data that matches the sensitive key-value identifier in the sensitive key-value pair data; and
[0131] Obtaining target key value data matching the sensitive data rule of the sensitive key value from the target log excluding the target key value pair data;
[0132] Based on the key-value data in the target key-value pair data and the target key-value data, the data to be desensitized in the target log is determined.
[0133] Optionally, in one implementation, the log desensitization module 440 is used to:
[0134] The key-value data in the target key-value pair data in the target log and the target key-value data are replaced with the corresponding desensitized data to obtain the desensitized target log.
[0135] Optionally, in one implementation, the desensitization processing module 430 is used to:
[0136] Determine the type of the data to be desensitized;
[0137] If the type of the data to be desensitized is a JSON object or an array containing a JSON object, the data to be desensitized is deeply copied to obtain the copied data to be desensitized;
[0138] Determine the desensitization rule corresponding to the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data;
[0139] Based on the desensitization rules corresponding to the data to be desensitized, the copied data to be desensitized is desensitized to obtain the desensitized data.
[0140] Optionally, in one implementation, the desensitization processing module 430 is used to:
[0141] If the type of the data to be desensitized is a JSON string or an array containing a JSON string, the data to be desensitized is parsed by a JSON string parsing method to obtain the parsed data to be desensitized;
[0142] Determine the desensitization rule corresponding to the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data;
[0143] Based on the desensitization rules corresponding to the data to be desensitized, the parsed data to be desensitized is desensitized to obtain the desensitized data.
[0144] Optionally, in one implementation, the log desensitization module 440 is used to:
[0145] The desensitized data is converted into the desensitized string through a JSON string conversion method;
[0146] The data to be desensitized in the target log is replaced with the desensitized character string to obtain the desensitized target log.
[0147] Among them, the above modules in the device provided by the embodiment of the present application can also implement the method steps provided by the above method embodiment. Alternatively, the device provided by the embodiment of the present application can also include other modules in addition to the above modules to implement the method steps provided by the above method embodiment. And the device provided by the embodiment of the present application can achieve the technical effects that can be achieved by the above method embodiment.
[0148] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 5 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0149] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0150] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0151] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a log desensitization device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0152] Get the target log to be printed;
[0153] Determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in the field pool of sensitive data;
[0154] Based on the desensitization rules corresponding to the multiple preset categories of sensitive data, desensitize the data to be desensitized to obtain desensitized data;
[0155] The data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
[0156] The electronic device provided in the embodiments of the present specification can, before the log is printed, determine the sensitive data, i.e., the data to be desensitized, present in the log based on multiple preset categories of sensitive data in a pre-set field pool of sensitive data, and then desensitize the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data to obtain the desensitized data, and finally, replace the data to be desensitized in the log with the desensitized data to obtain the desensitized log, and print the desensitized log, thereby avoiding the data involving the user's sensitive information in the log from being directly printed out, and effectively protecting the user's sensitive information.
[0157] The above is as in this manual Figure 1 to Figure 3 The method performed by the log desensitization device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in software form. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of this specification can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0158] The electronic device may also perform Figure 1 to Figure 3 Method, and implement log desensitization device in Figure 1 to Figure 3 The functions of the illustrated embodiments will not be described in detail in the embodiments of this specification.
[0159] The embodiment of the present specification also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 to Figure 3 The method of the embodiment shown is specifically used to perform the following operations:
[0160] Get the target log to be printed;
[0161] Determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in the field pool of sensitive data;
[0162] Based on the desensitization rules corresponding to the multiple preset categories of sensitive data, desensitize the data to be desensitized to obtain desensitized data;
[0163] The data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
[0164] The computer-readable storage medium provided in the embodiments of the present specification can, before the log is printed, determine the sensitive data, i.e., the data to be desensitized, in the log based on multiple preset categories of sensitive data in a pre-set field pool of sensitive data, and then desensitize the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data to obtain the desensitized data. Finally, the data to be desensitized in the log is replaced with the desensitized data to obtain the desensitized log, and the desensitized log is printed, thereby avoiding the data involving the user's sensitive information in the log from being directly printed out, and effectively protecting the user's sensitive information.
[0165] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0166] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0167] In short, the above description is only a preferred embodiment of this specification and is not intended to limit the protection scope of this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.
[0168] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0169] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0170] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0171] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A log desensitization method, characterized in that: include: Obtain a target log to be printed, wherein the target log includes key-value pair data and key-value data, and the key-value data does not include a key name; Based on multiple preset categories of sensitive data in the field pool of sensitive data, determine the data to be desensitized in the target log; the sensitive data includes a sensitive key value identifier and a sensitive key value, and the data to be desensitized includes target key value pair data matching the sensitive key value identifier, and target key value data matched based on the sensitive key value in the log of the target log excluding the target key value pair data; Based on the desensitization rules corresponding to the multiple preset categories of sensitive data, desensitize the data to be desensitized to obtain desensitized data; The data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, so as to print the desensitized target log.
2. The method according to claim 1, characterized in that Based on multiple preset categories of sensitive data in the field pool of sensitive data, determining the data to be desensitized in the target log includes: The target log is traversed to determine the data to be desensitized that matches the sensitive data rules of the multiple preset categories of sensitive data in the target log.
3. The method according to claim 2, characterized in that The traversing the target log to determine the data to be desensitized that matches the sensitive data rules of the multiple preset categories of sensitive data in the target log includes: Traversing the target log to obtain key-value pair data in the target log; Determining, from the key-value pair data, target key-value pair data that matches the sensitive key-value identifier in the sensitive key-value pair data; and Obtaining target key value data matching the sensitive data rule of the sensitive key value from the target log excluding the target key value pair data; Based on the key-value data in the target key-value pair data and the target key-value data, the data to be desensitized in the target log is determined.
4. The method according to claim 3, characterized in that Replacing the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log, including: The key-value data in the target key-value pair data in the target log and the target key-value data are replaced with the corresponding desensitized data to obtain the desensitized target log.
5. The method according to any one of claims 1 to 4, performing desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data to obtain desensitized data, comprising: Determine the type of the data to be desensitized; If the type of the data to be desensitized is a JSON object or an array containing a JSON object, the data to be desensitized is deeply copied to obtain the copied data to be desensitized; Determine the desensitization rule corresponding to the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data; Based on the desensitization rules corresponding to the data to be desensitized, the copied data to be desensitized is desensitized to obtain the desensitized data.
6. The method according to claim 5, performing desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data to obtain desensitized data, comprising: If the type of the data to be desensitized is a JSON string or an array containing a JSON string, the data to be desensitized is parsed by a JSON string parsing method to obtain the parsed data to be desensitized; Determine the desensitization rule corresponding to the data to be desensitized based on the desensitization rules corresponding to the multiple preset categories of sensitive data; Based on the desensitization rules corresponding to the data to be desensitized, the parsed data to be desensitized is desensitized to obtain the desensitized data.
7. The method according to claim 6, wherein the data to be desensitized in the target log is replaced with the desensitized data to obtain the desensitized target log, comprising: The desensitized data is converted into the desensitized string through a JSON string conversion method; The data to be desensitized in the target log is replaced with the desensitized character string to obtain the desensitized target log.
8. A log desensitization device, characterized in that: include: A log acquisition module, used to acquire a target log to be printed, wherein the target log includes key-value pair data and key-value data, and the key-value data does not include a key name; A data determination module, configured to determine the data to be desensitized in the target log based on multiple preset categories of sensitive data in a field pool of sensitive data; the sensitive data includes a sensitive key value identifier and a sensitive key value, the data to be desensitized includes target key value pair data matching the sensitive key value identifier, and the target key value data is matched based on the sensitive key value in the log of the target log excluding the target key value pair data; A desensitization processing module, used to perform desensitization processing on the data to be desensitized based on the desensitization rules corresponding to the sensitive data of the plurality of preset categories, to obtain desensitized data; The log desensitization module is used to replace the data to be desensitized in the target log with the desensitized data to obtain the desensitized target log and print the desensitized target log.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the log desensitization method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the log desensitization method according to any one of claims 1 to 7.
