Data de-sensitization method and apparatus
Patent Information
- Application Number
- CN202210437681.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-19
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2042-04-19
AI Technical Summary
[0004]然而,当需进行脱敏处理的数据量较大时,利用正则表达式对数据进行扫描匹配需要较长的时间,从而导致确定数据中的敏感信息所需的时间较长,进而造成脱敏处理效率低
本申请实施例中,在对待处理数据进行脱敏处理的情况下,确定该待处理数据中的各个对象以及各个对象所对应的属性信息,并确定各个对象所对应的类,即对象所属类中的敏感标签,该敏感标签是为对象所属类中的敏感属性设置的标记。对于每个对象的属性信息,判断该属性信息是否对应于敏感标签,即判断该对象所对应的类中的该属性信息是否存在相应的敏感标签,以确定该属性信息是否为敏感属性,也即确定是否需对该属性信息进行脱敏处理。在该属性信息对应于敏感标签的情况下,表明该属性信息为敏感属性,即表明需对该属性信息进行脱敏处理,则利用该敏感标签对应的脱敏方法,对该属性信息进行脱敏处理,实现敏感信息的快速确定,从而实现数据的快速脱敏处理,提高数据脱敏效率,且由于无需利用正则表达式对数据进行扫描匹配,可以减少资源的占用。
Smart Images

Figure CN114861218B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to data desensitization methods and apparatus. Background Technology
[0002] Data anonymization refers to the process of transforming sensitive information using anonymization rules to reliably protect sensitive and private data. Common sensitive information includes names, phone numbers, and passwords.
[0003] Currently, when performing data anonymization processing (e.g., logs), the data is generally scanned and matched using regular expressions. That is, by using the regular expression corresponding to each sensitivity type, it is determined whether there is sensitive information (e.g., name) corresponding to that sensitivity type in the data. Then, when it is determined that there is sensitive information corresponding to that sensitivity type, the sensitive information is anonymized.
[0004] However, when the amount of data to be de-identified is large, it takes a long time to scan and match the data using regular expressions, which in turn takes a long time to identify sensitive information in the data, resulting in low de-identification efficiency. Summary of the Invention
[0005] To overcome the problems existing in related technologies, this application provides a data desensitization method and apparatus.
[0006] According to a first aspect of the embodiments of this application, a data desensitization method is provided, the method comprising: Identify the objects in the data to be processed, and obtain the attribute information of the objects from the data to be processed; When the attribute information of the object corresponds to a sensitive tag, the attribute information is desensitized based on the sensitive tag; wherein, the sensitive tag represents a marker pre-set for sensitive attributes in the class to which the object belongs.
[0007] Optionally, the desensitization process for the attribute information based on the sensitive label includes: Obtain the set attribute parameters in the sensitive tag, and perform desensitization processing on the attribute information based on the desensitization rules corresponding to the set attribute parameters.
[0008] Optionally, the desensitization process for the attribute information based on the sensitive label includes: Determine the target desensitization variable marker corresponding to the object; the target desensitization variable marker is used to indicate whether the object should be desensitized. When the target desensitization variable tag indicates that the object should be desensitized, the attribute information is desensitized based on the sensitive tag.
[0009] Optionally, determining the target de-identification variable tag corresponding to the object includes: Determine the target processing thread for processing the attribute information corresponding to the object; Obtain the desensitized variable tag corresponding to the target processing thread, and determine the target desensitized variable tag corresponding to the object based on the desensitized variable tag.
[0010] Optionally, the method further includes: In response to the tag update operation, the de-identified variable tag corresponding to the target processing thread is updated.
[0011] Optionally, the data to be processed includes logs; The process of determining the objects in the data to be processed includes: Determine the first logging method for outputting the log, and determine the first method type corresponding to the first logging method; When the first log method is a preset de-identified log method corresponding to the first method type, the objects in the logs included in the data to be processed are determined.
[0012] Optionally, determining the objects in the logs included in the data to be processed includes: Obtain the log level corresponding to the log, and obtain the preset level corresponding to the first logging method; If the log level is greater than or equal to the preset level, determine the objects in the logs included in the data to be processed.
[0013] Optionally, the method further includes: In response to receiving a method replacement request, obtain the second method type in the method replacement request; Replace the second logging method corresponding to the second method type in the target code with the preset de-identified logging method corresponding to the second method type.
[0014] Optionally, the method further includes: If it is determined that the attribute information does not have a corresponding sensitive tag, the attribute information is subjected to standard serialization.
[0015] Optionally, the method further includes: If the data to be processed contains non-object information, determine the data type corresponding to the non-object information; When the data type is a preset desensitized data type, the non-object information is desensitized based on the desensitization rules corresponding to the data type.
[0016] According to a second aspect of the embodiments of this application, a time determination apparatus is provided, comprising: The attribute acquisition module is used to identify objects in the data to be processed and to acquire the attribute information of the objects from the data to be processed. The data desensitization module is used to desensitize the attribute information based on the sensitive tag when the attribute information of the object corresponds to the sensitive tag; wherein the sensitive tag represents a marker that is pre-set for the sensitive attributes in the class to which the object belongs.
[0017] Optionally, the data anonymization module is specifically used for: Obtain the set attribute parameters in the sensitive tag, and perform desensitization processing on the attribute information based on the desensitization rules corresponding to the set attribute parameters.
[0018] Optionally, the data anonymization module is specifically used for: Determine the target desensitization variable marker corresponding to the object; wherein, the target desensitization variable marker is used to indicate whether the object should be desensitized; When the target desensitization variable tag indicates that the object should be desensitized, the attribute information is desensitized based on the sensitive tag.
[0019] Optionally, the data anonymization module is also used for: Determine the target processing thread for processing the attribute information corresponding to the object; Obtain the desensitized variable tag corresponding to the target processing thread, and determine the target desensitized variable tag corresponding to the object based on the desensitized variable tag.
[0020] Optionally, the data anonymization module is also used for: In response to the tag update operation, the de-identified variable tag corresponding to the target processing thread is updated.
[0021] Optionally, the data to be processed includes logs; The attribute acquisition module is specifically used for: Determine the first logging method for outputting the log, and determine the first method type corresponding to the first logging method; When the first log method is a preset de-identified log method corresponding to the first method type, the objects in the logs included in the data to be processed are determined.
[0022] Optionally, the attribute acquisition module is specifically used for: Obtain the log level corresponding to the log, and obtain the preset level corresponding to the first logging method; If the log level is greater than or equal to the preset level, determine the objects in the logs included in the data to be processed.
[0023] Optionally, the data desensitization module is further used for: In response to receiving a method replacement request, obtain the second method type in the method replacement request; Replace the second logging method corresponding to the second method type in the target code with the preset de-identified logging method corresponding to the second method type.
[0024] Optionally, the data desensitization module is further used for: If it is determined that the attribute information does not have a corresponding sensitive tag, the attribute information is subjected to standard serialization.
[0025] Optionally, the data desensitization module is further used for: If the data to be processed contains non-object information, determine the data type corresponding to the non-object information; When the data type is a preset desensitized data type, the non-object information is desensitized based on the desensitization rules corresponding to the data type.
[0026] According to a third aspect of the embodiments of this application, a computer device is provided, comprising: processor; Memory used to store processor-executable instructions; The processor is configured as follows: Identify the objects in the data to be processed, and obtain the attribute information of the objects from the data to be processed; When the attribute information of the object corresponds to a sensitive tag, the attribute information is desensitized based on the sensitive tag; wherein, the sensitive tag represents a marker pre-set for sensitive attributes in the class to which the object belongs.
[0027] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein computer-executable instructions are stored in the computer-readable storage medium, and when a processor executes the computer-executable instructions, the data desensitization method described in the first aspect and various possible designs of the first aspect is implemented.
[0028] According to a fifth aspect of the embodiments of this application, a computer program product is provided, including a computer program that, when executed by a processor, implements the data desensitization method described in the first aspect and various possible designs of the first aspect.
[0029] The technical solutions provided by the embodiments of this application may include the following beneficial effects: In this embodiment, when desensitizing the data to be processed, each object in the data to be processed and its corresponding attribute information are determined, and the class corresponding to each object is determined, i.e., the sensitive label in the class to which the object belongs. The sensitive label is a marker set for the sensitive attributes in the class to which the object belongs. For the attribute information of each object, it is determined whether the attribute information corresponds to a sensitive label, that is, whether the attribute information in the class to which the object belongs has a corresponding sensitive label, to determine whether the attribute information is a sensitive attribute, that is, to determine whether the attribute information needs to be desensitized. If the attribute information corresponds to a sensitive label, it indicates that the attribute information is a sensitive attribute, that is, it indicates that the attribute information needs to be desensitized. Then, the desensitization method corresponding to the sensitive label is used to desensitize the attribute information, realizing the rapid identification of sensitive information, thereby realizing the rapid data desensitization process, improving the data desensitization efficiency, and reducing resource consumption since there is no need to use regular expressions to scan and match the data.
[0030] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0031] The accompanying drawings, which are incorporated in and form part of this application, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0032] Figure 1 This is a flowchart illustrating a data desensitization method according to an exemplary embodiment of this application.
[0033] Figure 2 This is a flowchart illustrating another data desensitization method according to an exemplary embodiment of this application.
[0034] Figure 3 This is a parameter method mapping diagram illustrated in this application according to an exemplary embodiment.
[0035] Figure 4 This is a schematic diagram illustrating the data desensitization process according to an exemplary embodiment of this application.
[0036] Figure 5 This is a hardware structure diagram of a computer device containing the data desensitization device in an embodiment of this application.
[0037] Figure 6 This is a block diagram illustrating a data desensitization apparatus according to an exemplary embodiment of this application. Detailed Implementation
[0038] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0039] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used herein are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.
[0040] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0041] The embodiments of this application will now be described in detail.
[0042] like Figure 1 As shown, Figure 1 This is a flowchart illustrating a data anonymization method according to an exemplary embodiment of this application, applied to a computer device. The method includes the following steps: Step 101: Identify the objects in the data to be processed and obtain the attribute information of the objects from the data to be processed.
[0043] In this embodiment, after obtaining the data (i.e. the data to be processed), when it is necessary to perform desensitization processing on the data, the data of each object included in the data is obtained, and the object data includes all attribute information corresponding to the object.
[0044] An object is an instance of a class. The attribute information corresponding to an object includes the attribute name and the attribute value. For example, in obj2.address = 'X city', obj2 is an object, address is an attribute of the obj2 object, and 'X city' is the corresponding attribute value.
[0045] Optionally, the data to be processed includes one or more of logs and application data (e.g., business data). Logs are the logs output by the program during its execution; application data is the data generated by the program (e.g., the application system) during its operation. Business data is the data generated by related business operations performed during program execution; for example, a business operation instructing a transfer operation may include recipient-related information.
[0046] Step 102: If the object's attribute information corresponds to a sensitive tag, perform desensitization processing on the attribute information based on the sensitive tag. Here, the sensitive tag refers to a marker pre-set for sensitive attributes in the object's class.
[0047] In this embodiment, for each attribute information corresponding to an object, it is determined whether the attribute information corresponds to a sensitive tag, that is, whether the attribute information in the class corresponding to the object has a corresponding sensitive tag, i.e., whether the attribute information is sensitive information. When it is determined that the attribute information corresponds to a sensitive tag, it indicates that the attribute information is sensitive information, that is, information in the object that needs to be desensitized, and then the attribute information is desensitized, that is, the attribute value in the attribute information is desensitized.
[0048] Sensitive tags are markers pre-set by developers for sensitive attributes within the class to which an object belongs, based on actual needs. Specifically, when relevant personnel determine that a certain attribute within a class is sensitive information, a sensitive tag is added to that attribute when defining the class; for example, the sensitive tag could be `@SensitiveMaskField`. Correspondingly, when the data to be processed includes that attribute information corresponding to an object of that class, the presence of the sensitive tag indicates that the attribute is sensitive and requires desensitization processing, enabling rapid identification of sensitive information.
[0049] Here, the object corresponding to the class is the object obtained by instantiating the class.
[0050] For example, developers, based on requirements, determine that user name and user phone number are sensitive information. When a defined class includes these two attributes, they add sensitive tags to them. This allows them to directly identify the user name and / or user phone number as sensitive information when processing data containing the user name and / or user phone number associated with an instance of this class. The specific code for adding sensitive tags to this class is as follows: Java @Data @Sensitive public class UserDto { / ** . * User Name * @SensitiveField(SensitiveEnum.NAME) private String name; / ** *User's mobile phone number @SensitiveField(SensitiveEnum.PHONE) private String phone; / ** *User address private String address.
[0051] Optionally, before determining whether the object's attribute information corresponds to a sensitive tag, the class to which the object belongs can be determined first, that is, whether the class to which the object belongs is a set class, which is a class that contains sensitive tags. If it is determined that the type to which the object belongs is a set class, then it can be further determined whether the object's attribute information corresponds to a sensitive tag.
[0052] In this embodiment, when most of the sensitive information is carried by objects, sensitive tags can be set for the specific attributes of the relevant objects (i.e., the relevant classes corresponding to the objects) as needed. The sensitive tags are only used for identification to transform the attributes of the objects and achieve non-intrusive modification of the code without affecting the normal operation of the code.
[0053] In this embodiment, after obtaining the data to be processed, it is determined whether there are sensitive tags in the attributes of the objects in the data. If there are, it indicates that the attribute is a sensitive attribute and needs to be desensitized. In this case, the desensitization is performed directly without the need to use regular expressions for scanning and matching, which can effectively reduce the CPU usage, thereby reducing resource consumption and shortening the response time of other services.
[0054] As described above, when performing data anonymization on the data to be processed, the process involves identifying each object in the data and its corresponding attribute information, as well as determining the sensitive tags in the classes to which each object belongs. These sensitive tags are markers set for sensitive attributes within the class to which the object belongs. For each object's attribute information, it is determined whether the attribute information corresponds to a sensitive tag, i.e., whether the attribute information in the class to which the object belongs has a corresponding sensitive tag. This determines whether the attribute information is a sensitive attribute and whether it needs to be anonymized. If the attribute information corresponds to a sensitive tag, it indicates that the attribute information is sensitive and requires anonymization. The anonymization method corresponding to the sensitive tag is then used to anonymize the attribute information, achieving rapid identification of sensitive information and thus enabling rapid data anonymization, improving data anonymization efficiency. Furthermore, since there is no need to use regular expressions to scan and match the data, resource consumption can be reduced.
[0055] like Figure 2 As shown, Figure 2 This is a flowchart illustrating another data desensitization method according to an exemplary embodiment of this application. Based on the foregoing embodiments, this implementation describes how to desensitize sensitive information. The process will be described in detail below with reference to a specific embodiment, such as... Figure 2 As shown, the method includes the following steps: Step 201: Determine the objects in the data to be processed, and obtain the attribute information of the objects from the data to be processed.
[0056] In this embodiment, since logs are output by executing relevant logging methods, to improve the efficiency of data anonymization, the relevant logging methods can be replaced to directly determine whether logs output by these methods need anonymization when outputting logs. The specific process is as follows: In response to receiving a method replacement request, the second method type in the method replacement request is obtained. The second logging method corresponding to the second method type in the target code is replaced with a preset anonymized logging method corresponding to the second method type.
[0057] Specifically, upon receiving a method replacement request, the request includes a second method type, which is the type corresponding to the log method that needs to be replaced. The log method (i.e., the second log method) corresponding to this second method type in the target code related to generating the log (e.g., the code corresponding to the program that outputs the log) is replaced with a preset de-identified log method corresponding to this second method type. This preset de-identified log method replaces the log method, indicating that de-identification processing is required when the data to be processed includes logs output based on this preset de-identified log method. This allows for the diversion of de-identified data at the source.
[0058] The second logging method is provided by the slf4j interface, and the preset de-identified logging method corresponding to the second method type is obtained by extending the slf4j interface. The function implemented by the preset de-identified logging method corresponding to the second method type is the same as the function implemented by the second logging method corresponding to the second method type. Accordingly, the logs output by the preset de-identified logging method (e.g., log content, format, etc.) are the same as the logs output by the second logging method.
[0059] Optionally, the second method type includes one or more of the following: Info, Trace, Debug, Warn, and Error. For example, when the second method type is Info, the second logging method corresponding to the second method type is logger.info(), and the default de-identified logging method corresponding to the second method type is logger.maskInfo(). The logger.info() method in the target code is replaced with logger.maskInfo().
[0060] The target code can be a portion of the code corresponding to the specified program (e.g., the code corresponding to a functional module) or all the code corresponding to the program, to achieve a full replacement of the logging method.
[0061] In this embodiment, the org.slf4j.Logger interface is copied and placed in the corresponding project of the program, with the package name remaining unchanged as org.slf4j, to overwrite the original Logger interface. Similarly, org.apache.logging.slf4j.Log4jLogger is copied, and the de-identification processing method is added, while the original method remains unchanged.
[0062] Optionally, after replacing the logging method in the target code, the data to be processed will include logs when it is obtained. The first logging method for outputting logs is determined, and the first method type corresponding to the first logging method is also determined. If the first logging method is a preset de-identified logging method corresponding to the first method type, the objects in the data to be processed are determined.
[0063] Specifically, for each log entry, the logging method that outputs the log (i.e., the first logging method) is determined; that is, the log entry is output when the first logging method is called. If the method type corresponding to the first logging method (i.e., the first method type) is a preset de-identified logging method corresponding to that first method type, it indicates that the first logging method is a preset de-identified logging method. In other words, the logs output by the first logging method need to involve de-identification processing. Then, the objects in the logs included in the data to be processed are determined to determine whether the attribute information of the objects has been de-identified.
[0064] Optionally, since different logging methods output different logs, log levels can be used to filter the logs output by that logging method to determine which logs require de-identification processing. This involves obtaining the corresponding log level and the preset level for the first logging method. If the log level is greater than or equal to the preset level, the objects in the logs included in the data to be processed are determined.
[0065] Specifically, the process involves obtaining the log level of the log entry and the preset level of the first logging method that output the log. This preset level is used to determine whether the log requires anonymization. If the log level of the log entry is greater than the preset level of the first logging method, it indicates that the log requires anonymization, and the attribute information of the objects in the log entry is obtained. If the log level of the log entry is greater than the preset level of the first logging method, it is determined that the log does not require anonymization, and the attribute information of the objects in the log entry does not need to be obtained. The process can continue to the next log entry to determine whether anonymization is required for that next log entry.
[0066] The preset levels can be set according to actual needs. For example, when the first logging method is logger.maskTrace(), its corresponding preset level is trace level; when the first logging method is logger.maskDebug(), its corresponding preset level is debug level; when the first logging method is logger.maskInfo(), its corresponding preset level is info level; when the first logging method is logger.maskkWarn(), its corresponding preset level is warn level; and when the first logging method is logger.maskError(), its corresponding preset level is error level.
[0067] Optionally, the first method type includes one or more of the following types: Info, Trace, Debug, Warn, and Error.
[0068] Optionally, the logging level can be the default level set by the original logging methods of the slf4j interface, or it can be set by the developers according to actual needs. There are no restrictions on it here.
[0069] Optionally, if the data to be processed contains non-object information, the data type corresponding to the non-object information is determined; if the data type is a preset desensitized data type, the non-object information is desensitized based on the desensitization rules corresponding to the data type.
[0070] The preset desensitized data types can be set according to actual needs. For example, the preset desensitized data types include String type and Date type.
[0071] Specifically, the process retrieves all data from the data to be processed, excluding object data (i.e., the attribute information corresponding to objects), i.e., non-object information. When the data type of this non-object information is a preset desensitized data type, the desensitization rules corresponding to that data type are used to desensitize the non-object information, ensuring the comprehensiveness of data desensitization. For example, if the non-object information is "The weather is very nice today," and the corresponding data type is String, then the desensitization rule for that String type is retrieved, i.e., the desensitization method is SensitiveUtils.maskContext. This method indicates that three characters are displayed and then three characters are hidden, thus the desensitized non-object information is "The weather is very nice today."
[0072] Step 202: If the object's attribute information corresponds to a sensitive tag, obtain the set attribute parameters in the sensitive tag. Here, the sensitive tag represents a marker pre-set for sensitive attributes in the object's class.
[0073] In this embodiment, after obtaining the data to be processed, it needs to be serialized. During the serialization process, for each attribute information in the object of the data to be processed, it is determined whether the attribute information corresponds to a sensitive tag, that is, whether the attribute information has a corresponding sensitive tag. When it is determined that the attribute information corresponds to a sensitive tag, it indicates that the sensitive information needs to be de-identified. Then, the set attribute parameters in the sensitive tag are obtained so as to determine the de-identification method for processing the attribute information.
[0074] Optionally, the attribute parameters set in the sensitive label correspond to the attribute names in the attribute information of the sensitive label. These parameters are used to find the corresponding desensitization methods, i.e., desensitization rules. Different developers may have different naming habits, and different attribute names may correspond to the same format (for example, creation date and deletion date both correspond to date formats, and desensitization methods corresponding to date formats can be used to desensitize both). Therefore, based on the meaning represented by the attribute name and its corresponding format, the corresponding attribute parameters are set. For example, NAME in the above code for adding a sensitive label is the attribute parameter corresponding to the attribute name name. Even if the name of the attribute name name changes later, it will not affect the attribute parameter. The corresponding desensitization rules can still be found using this attribute parameter. Attribute names in other formats can also use this attribute parameter to find the corresponding desensitization rules, reducing the workload of developers.
[0075] Optionally, based on Jackson's serialization extension interface, an executor object, namely the executor class SensitiveMaskDataSerializer, is constructed to identify, i.e., determine whether the attribute information contains corresponding sensitive tags. This executor class inherits from JsonSerializer, that is, public class SensitiveMaskDataSerializer extends JsonSerializer implements ContextualSerializer.
[0076] Step 203: Based on the desensitization rules corresponding to the set attribute parameters, perform desensitization processing on the attribute information.
[0077] In this embodiment, when it is determined that there is a corresponding sensitive tag for the attribute information, the desensitization rule, i.e. the desensitization method, corresponding to the set attribute parameter in the sensitive tag is searched, and the attribute information is desensitized.
[0078] The attribute parameters are defined as properties of the constructed enumeration object `SensitiveMaskEnum`. Each object within this enumeration object represents a defined attribute parameter, corresponding to a desensitization method. The code for constructing this enumeration object is as follows: public enum SensitiveMaskEnum { CONTEXT, / / text CN_ID, / / Chinese citizen ID card DATE DATE, / / date EMAIL CH_NAME, / / Chinese name, blurring the part except the surname, for example, Wang Xiaoxiao -> Wang** CH_NAME_MID, / / Chinese name with ambiguous middle, for example, Wang Xiaoxiao -> Wang*Xiao PHONE, / / mobile phone number ADDRESS, / / address; CODE, / / User ID }
[0079] For example, when the set attribute parameter in the sensitive tag corresponding to the attribute information is EMAIL, the desensitization processing method corresponding to that EMAIL is searched, and the desensitization processing method is used to desensitize the attribute information.
[0080] Optionally, to determine the desensitization rules using set attribute parameters, it is necessary to set the enumeration object corresponding to the set attribute parameter when creating sensitive tags. The specific creation code is as follows: / ** *Description: sensitive annotation for field of class. / @Retention(RetentionPolicy.RUNTIME) @Inherited @Target(value = {ElementType.FIELD}) @JacksonAnnotationsInside @JsonSerialize(using = SensitiveDataSerializer.class) public @interface SensitiveMaskField { / ** *value from SensitiveEnum / sensitiveMaskEnum value(); }
[0081] Optionally, when creating sensitive tags, you need to use a serialization tool, such as JackSon's extended serialization interface, to create them.
[0082] Optionally, the desensitization method can be determined from the SensitiveUtils toolset, which contains different types of desensitization methods pre-configured by developers according to actual needs. These desensitization methods correspond to the attribute parameters set in the sensitive tags, for example, such as... Figure 3 As shown, when the attribute parameter is set to NAME, it indicates that the desensitization method corresponding to NAME needs to be searched from the SensitiveUtils toolset, i.e., the desensitization method set, in order to mask the name in the attribute information, i.e., desensitize it.
[0083] In this embodiment, a SensitiveUtils toolset containing various desensitization methods is established, which can perform desensitization processing on different attributes and according to different requirements, thereby achieving diversified data desensitization.
[0084] Optionally, the desensitization method, i.e., the specific rules for desensitization, can be set according to actual needs. For example, when desensitizing names, the middle part of the name can be blurred. For example, Zhang San becomes Zhang* after desensitization; Wang Xiaoxiao becomes Wang*Xiao after desensitization. Alternatively, the part of the name other than the surname can be blurred. For example, Wang Xiaoxiao becomes Wang** after desensitization. As another example, when desensitizing phone numbers (e.g., mobile phone numbers, landline numbers, etc.), the middle four digits of the phone number can be blurred. For example, the phone number 11122223333 becomes 111****3333 after desensitization. Alternatively, a preset number of digits in other positions can be blurred. For example, the last four digits can be blurred. For example, the phone number 11122223333 becomes 1112222*** after desensitization.
[0085] The specific code for blurring the middle four digits of a phone number is as follows: / ** * sensitive name, miaName would be mask. * example; * Zhang San, Wang Xiaoxiao -> Zhang*, Wang* Xiao *@param name @return mask 'name' / / Returns the name after the mask. / public static string maskChMidName(String name){ / / If the name has only one character, no mask is needed. if (StringUtils.length(name)<3){ return maskChName(name); } String firstName = StringUtils.substring(name, start: 0, end: 1); int padLength = name.lengthO - 1; String lastName = StringUtils.substring(name, padLength); return StringUtils.rightPad(firstName, padLength, MASK_FLAG).concat(lastName); }
[0086] The specific code for blurring the middle four digits of a phone number is as follows: / ** * if phone's length greater than 7, sensitive phoneNm need wouldbe mask. * exomple; * 11122223333 ->111****3333 * +8611122223333 ->+86111****3333 * 010-66611166 ->010-****1166 *@param phone *@return maskMobilePhone * / public static String maskPhone(String phone){ / / just 4 character dont need mask, is not mobilePhone if (StringUtils.length(phone)<7){ return phone; } / / No mask required int length = phone.length(); if (length>9){ / / Mask the middle 4 digits String firstNane = StringUtils.substring(phone, start: 0, end:length -8); String lastName = StringUtils.substring(phone, start: length - 4); return StringUtils.rightPad(firstNane, size:length-4, MASK_FLAG).concat(lastName); }; / / Less than 9 digits String firstNane = StringUtils.substring(phone, start:0, end:2); String lastName = StringUtils.substring(phone, start: length - 4); return StringUtils.rightPad(firstName, size:length - 4, MASK_FLAG).concat(lastName); }.
[0087] Optionally, when desensitizing attribute information, first determine whether the attribute information needs to be desensitized, that is, determine the target desensitization variable tag corresponding to the object. The target desensitization variable tag is used to indicate whether the object needs to be desensitized. If the target desensitization variable tag indicates that the object needs to be desensitized, it means that the object's attribute information needs to be desensitized, and then the attribute information is desensitized based on the sensitive tag.
[0088] Optionally, determine the target desensitization variable markers corresponding to the object, including: Determine the target thread for processing the attribute information corresponding to the object being processed.
[0089] Obtain the desensitized variable tag corresponding to the target processing thread, and determine the target desensitized variable tag corresponding to the object based on the desensitized variable tag, that is, determine the object as the target desensitized variable tag based on the desensitized variable tag.
[0090] Specifically, the target processing thread is the thread that processes object data. Multiple threads running on the computer device process the data to be processed. When a thread processes its assigned data, if the desensitization variable flag for that thread indicates that the object needs desensitization, it means the data being processed by that thread requires desensitization. In this case, the attribute information corresponding to the object in the data to be processed is obtained, and the sensitivity label is used to determine whether this attribute information needs desensitization. If the desensitization variable flag for that thread indicates that the object does not need desensitization, it means the data being processed by that thread does not require desensitization. Therefore, it is not necessary to continue obtaining the attribute information corresponding to the object in the data to be processed, thus achieving rapid identification and routing of desensitized data and improving data desensitization efficiency.
[0091] For example, there are two threads: thread 1 processes data 1 and 2, and thread 2 processes data 3. When the desensitization variable flag corresponding to thread 1 is set to the first flag, that is, when the desensitization variable flag indicates that the object needs to be desensitized, the sensitive label needs to be used to determine whether data 1 and 2 need to be desensitized. When the desensitization variable flag corresponding to thread 2 is set to the second flag, that is, when the desensitization variable flag indicates that the object is desensitized, there is no need to desensitize data 3.
[0092] Optionally, the de-identification scalar marker corresponding to the thread can be modified as needed. That is, in response to the marker update operation, the de-identification variable marker corresponding to the target processing thread is updated. For example, if the de-identification variable marker corresponding to the target processing thread indicates that the object is de-identified, after receiving the marker update operation, the de-identification variable marker corresponding to the target processing thread is updated to indicate that the object is not de-identified.
[0093] Optionally, the de-identified variable tag can be a fixed variable of MDC (Mapped Diagnostic Context). MDC is a function provided by log4j and logback to facilitate logging under multi-threaded conditions. This application is used to determine whether de-identification is required.
[0094] Optionally, if it is determined that there is no corresponding sensitive tag for the attribute information, the attribute information can be serialized using standard serialization.
[0095] Specifically, for each attribute of an object, if it is determined that the attribute does not have a corresponding sensitive tag, it indicates that the attribute is not sensitive information and does not require desensitization. Standard serialization can then be performed. For example, the `address` attribute in the code above that adds sensitive tags does not have a corresponding sensitive tag. Therefore, when the attribute of an object is the `address` attribute, no desensitization is required.
[0096] Optionally, the standard serialization operation can be the default StringSerializer processing operation. Of course, since JackSon can have multiple tags (i.e., labels), when the attribute information corresponds to a tag other than a sensitive tag, the attribute information can be processed according to the serialization operation corresponding to that tag.
[0097] Optionally, after obtaining the anonymized attribute information of the object, the writeObject method of JsonGenerator can be called to combine or process the anonymized attribute information of the object to obtain the corresponding anonymized data.
[0098] Optionally, after obtaining the anonymized data, it can also be output so that relevant users can access it. For example, such as... Figure 4 As shown, when users A / B input a query request, the application system responds to the query request, performs relevant business processing, determines the data to be processed, and then determines whether the data contains sensitive tags, i.e., de-identification tags. If sensitive tags exist, the data to be processed is de-identified, and the de-identified data is returned to the user; if no sensitive tags exist, the original data obtained from the query is directly returned to the user.
[0099] Optionally, the target data type in the data to be processed can be directly de-identified. The target data type can be set according to the requirements, for example, the target data type is String.
[0100] In this embodiment, considering that most application data is based on object data format, the unified desensitization processing of object data can be achieved by marking the attribute as sensitive data on the object's attributes and specifying the desensitization method to be used.
[0101] Optionally, after obtaining the desensitized attribute information, the desensitized attribute information, i.e., the desensitized object data, is also displayed.
[0102] In this embodiment, when it is determined that the attribute information of an object corresponds to a sensitive tag, the set attribute parameters corresponding to the sensitive tag are obtained, and the desensitization rules are determined using the set attribute parameters. The desensitization rules can be set according to actual needs, thereby ensuring the diversity of desensitization methods and meeting the personalized needs of users while achieving data desensitization.
[0103] In this embodiment, the native interface of slf4j is extended, and a new de-identified logging method is added to the native interface. By replacing the logging method in part or all of the corresponding business code (i.e., target code) of the program, data de-identification and diversion can be achieved at the source, avoiding de-identification of data that does not need to be de-identified, ensuring the effectiveness of data de-identification, avoiding waste of resources, and with low modification cost.
[0104] Corresponding to the embodiments of the aforementioned methods, this application also provides embodiments of a data desensitization device and the terminal to which it is applied.
[0105] Embodiments of the data anonymization device of this application can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by the processor handling the file reading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, such as... Figure 5 The diagram shown is a hardware structure diagram of a computer device containing the data anonymization device according to an embodiment of this application. Except for... Figure 5 In addition to the processor 510, memory 530, network interface 520, and non-volatile memory 540 shown, the computer device where the data desensitization device 531 is located in the embodiment may also include other hardware depending on the actual function of the computer device, which will not be described in detail here.
[0106] like Figure 6 As shown, Figure 6 This is a block diagram illustrating a data desensitization apparatus according to an exemplary embodiment of this application, the apparatus comprising: The attribute acquisition module 610 is used to identify objects in the data to be processed and to acquire the attribute information of the objects from the data to be processed. The data desensitization module 620 is used to desensitize attribute information based on sensitive tags when the attribute information of an object corresponds to sensitive tags; wherein, the sensitive tags represent the markers that are pre-set for sensitive attributes in the class to which the object belongs.
[0107] Optionally, the data anonymization module 620 is specifically used for: Obtain the set attribute parameters in the sensitive tags, and perform desensitization processing on the attribute information based on the desensitization rules corresponding to the set attribute parameters.
[0108] Optionally, the data anonymization module 620 is specifically used for: Determine the target desensitization variable markers corresponding to the object. These target desensitization variable markers indicate whether the object should undergo desensitization processing.
[0109] When the target desensitization variable tag indicates that the object should be desensitized, the attribute information is desensitized based on the sensitive tag.
[0110] Optionally, the data anonymization module 620 is also used for: Determine the target thread for processing the attribute information corresponding to the object being processed.
[0111] Obtain the desensitized variable tag corresponding to the target processing thread, and determine the target desensitized variable tag corresponding to the object based on the desensitized variable tag.
[0112] Optionally, the data anonymization module 620 is also used for: In response to the tag update operation, the de-identified variable tag corresponding to the target processing thread is updated.
[0113] Optional, the data to be processed includes logs.
[0114] The attribute acquisition module 610 is specifically used for: Determine the first logging method for outputting logs, and determine the first method type corresponding to the first logging method.
[0115] If the first log method is the preset de-identified log method corresponding to the first method type, determine the objects in the logs included in the data to be processed.
[0116] Optionally, the attribute acquisition module 610 is specifically used for: Get the log level corresponding to the log, and get the preset level corresponding to the first logging method.
[0117] If the log level is greater than or equal to the preset level, determine the objects in the logs included in the data to be processed.
[0118] Optionally, the data anonymization module 620 is also used for: In response to receiving a method replacement request, retrieve the second method type from the method replacement request.
[0119] Replace the second logging method corresponding to the second method type in the target code with the preset de-identified logging method corresponding to the second method type.
[0120] Optionally, the data anonymization module 620 is also used for: If it is determined that there is no corresponding sensitive tag for the attribute information, the attribute information is serialized according to standard procedures.
[0121] Optionally, the data anonymization module 620 is also used for: When the data to be processed contains non-object information, determine the data type corresponding to the non-object information.
[0122] When the data type is a preset desensitized data type, the non-object information is desensitized based on the desensitization rules corresponding to the data type.
[0123] The specific implementation process of the functions and roles of each module in the above device can be found in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0124] In another embodiment, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the data desensitization method described above.
[0125] In another embodiment, this application provides a computer program product, including a computer program that, when executed by a processor, implements the data desensitization method described above.
[0126] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0127] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0128] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention filed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not claimed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims. Furthermore, the data involved in this application may be data authorized by the user or fully authorized by the parties.
[0129] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
[0130] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A data anonymization method, characterized in that, include: The process involves: identifying objects in the data to be processed, including logs; determining a first logging method for outputting the logs and a first method type corresponding to the first logging method; identifying objects in the logs included in the data to be processed if the first logging method is a preset de-identified logging method corresponding to the first method type; obtaining the log level corresponding to the logs and a preset level corresponding to the first logging method; and identifying objects in the logs included in the data to be processed if the log level is greater than or equal to the preset level. The data to be processed is serialized. During serialization, the target processing thread for processing the attribute information corresponding to the object is determined; Obtain the desensitization variable flag corresponding to the target processing thread, wherein the desensitization variable flag corresponding to the target processing thread is used to indicate whether the object is desensitized; When the desensitization variable marker corresponding to the target processing thread indicates that the object should be desensitized, the attribute information of the object is obtained; When the Jackson-based serialization extension interface identifies that the attribute information of the object corresponds to a sensitive tag, the set attribute parameters in the sensitive tag are obtained, the serialization process of the attribute information is intercepted, and the attribute information is desensitized based on the set attribute parameters; wherein, the sensitive tag represents a mark set in advance for the sensitive attributes in the class to which the object belongs during the class definition stage; If the desensitization variable flag corresponding to the target processing thread indicates that the object will not be desensitized, then the attribute information of the object will not be obtained, and the object will not be desensitized.
2. The method according to claim 1, characterized in that, The process of desensitizing the attribute information based on the set attribute parameters includes: Based on the desensitization rules corresponding to the set attribute parameters, the attribute information is desensitized.
3. The method according to claim 1, characterized in that, The method further includes: In response to the tag update operation, the de-identified variable tag corresponding to the target processing thread is updated.
4. The method according to claim 1, characterized in that, The method further includes: In response to receiving a method replacement request, obtain the second method type in the method replacement request; Replace the second logging method corresponding to the second method type in the target code with the preset de-identified logging method corresponding to the second method type.
5. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If it is determined that the attribute information does not have a corresponding sensitive tag, the attribute information is subjected to standard serialization.
6. The method according to any one of claims 1 to 3, characterized in that, The method further includes: If the data to be processed contains non-object information, determine the data type corresponding to the non-object information; When the data type is a preset desensitized data type, the non-object information is desensitized based on the desensitization rules corresponding to the data type.
7. A data anonymization device, characterized in that, include: An attribute acquisition module is used to determine objects in data to be processed, including logs; determine a first logging method for outputting the logs, and determine a first method type corresponding to the first logging method; if the first logging method is a preset de-identified logging method corresponding to the first method type, determine the objects in the logs included in the data to be processed; obtain the log level corresponding to the logs, and obtain a preset level corresponding to the first logging method; if the log level is greater than or equal to the preset level, determine the objects in the logs included in the data to be processed; and perform serialization processing on the data to be processed. During serialization, the target processing thread for processing the attribute information corresponding to the object is determined; Obtain the desensitization variable marker corresponding to the target processing thread, wherein the desensitization variable marker corresponding to the target processing thread is used to indicate whether the object is desensitized; if the desensitization variable marker corresponding to the target processing thread indicates that the object is desensitized, obtain the attribute information of the object; if the desensitization variable marker corresponding to the target processing thread indicates that the object is not desensitized, do not obtain the attribute information of the object, and do not desensitize the object. The data desensitization module is used to, when the Jackson-based serialization extension interface identifies that the attribute information of the object corresponds to a sensitive tag, obtain the set attribute parameters in the sensitive tag, intercept the serialization process of the attribute information, and perform desensitization processing on the attribute information based on the set attribute parameters; wherein, the sensitive tag represents a mark set in advance for the sensitive attribute in the class to which the object belongs during the class definition stage.
8. A computer device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the following method: The process involves: identifying objects in the data to be processed, including logs; determining a first logging method for outputting the logs and a first method type corresponding to the first logging method; identifying objects in the logs included in the data to be processed if the first logging method is a preset de-identified logging method corresponding to the first method type; obtaining the log level corresponding to the logs and a preset level corresponding to the first logging method; and identifying objects in the logs included in the data to be processed if the log level is greater than or equal to the preset level. The data to be processed is serialized; during the serialization process, the target processing thread for processing the attribute information corresponding to the object is determined. Obtain the desensitization variable flag corresponding to the target processing thread, wherein the desensitization variable flag corresponding to the target processing thread is used to indicate whether the object is desensitized; When the desensitization variable marker corresponding to the target processing thread indicates that the object should be desensitized, the attribute information of the object is obtained; When the Jackson-based serialization extension interface identifies that the attribute information of the object corresponds to a sensitive tag, the set attribute parameters in the sensitive tag are obtained, the serialization process of the attribute information is intercepted, and the attribute information is desensitized based on the set attribute parameters; wherein, the sensitive tag represents a mark set in advance for the sensitive attributes in the class to which the object belongs during the class definition stage; If the desensitization variable flag corresponding to the target processing thread indicates that the object will not be desensitized, then the attribute information of the object will not be obtained, and the object will not be desensitized.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the data desensitization method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Log desensitization method, log desensitization equipment, electronic equipment and readable storage medium
CN114021185A