MASKING SENSITIVE DATA FOR LOGGING
Systems, methods, and computer-executable instructions for protecting data that includes receiving a list of patterns. A request to log a string of text is received. The string of text is searched for a match using the list of patterns. A matching substring within the string of text is found based on one of the patterns from the list of patterns. A replacement string is determined. The substring within the string of text is replaced with the replacement. The updated string of text is logged.
1 . A method for protecting data, the method comprising operations performed using an electronic processor, the operations comprising:
receiving a plurality of patterns;
receiving a request to log a string of text;
searching the string of text for a match using the plurality of patterns;
finding a first substring of the string of text that is a match based on a first pattern of the plurality of patterns;
determining a first replacement string;
replacing within the string of text the first substring with the first replacement string; and
logging the string of text after the replacing to a log.
2 . The method of claim 1 , further comprising:
finding a second substring of the string of text that is a match based on a second pattern of the plurality of patterns;
determining a second replacement string;
replacing, prior to the logging, the second substring of the string of text with the second replacement string.
3 . The method of claim 1 , wherein a length of the first replacement string is different from a length of the first substring.
4 . The method of claim 1 , wherein the determining a first replacement string comprises randomly determining a length, wherein the random length is the length of the first replacement string.
5 . The method of claim 1 , further comprising:
reading a length of the first replacement string from a configuration file, wherein the length of the first replacement string is associated with the first pattern.
6 . The method of claim 1 , wherein the first replacement string is a string comprising one character.
7 . The method of claim 1 , wherein determining the first replacement string comprises:
encrypting the first substring with a first cryptography algorithm; and
creating a first security prefix based on the first cryptography algorithm, wherein the first replacement string comprises the first security prefix and the encrypted first substring.
8 . The method of claim 7 , further comprising:
reading the first security prefix and the encrypted first substring from the log;
determining the first cryptography algorithm from the first security prefix; and
decrypting the first substring using the first cryptography algorithm.
9 . The method of claim 1 , further comprising:
encrypting the first substring value with a first cryptography algorithm; and
storing the encrypted first substring.
10 . The method of claim 9 , further comprising:
creating a first security prefix based on the first cryptography algorithm; and
storing the first security prefix and the encrypted substring in the single field in a table of a database.
11 . The method of claim 1 , wherein the request to log a string of text is from legacy software that is insecurely logging personal information.
12 . A system to protect data, the system comprising:
an electronic processor configured to:
receive a plurality of patterns;
receive a request to log a string of text;
search the string of text for a match using the plurality of patterns;
find a first substring of the string of text that is a match based on a first pattern of the plurality of patterns;
determine a first replacement string;
replace within the string of text the first substring with the first replacement string; and
log the string of text after the replacing to a log.
13 . The system of claim 12 , wherein the electronic processor is further configured to:
find a second substring of the string of text that is a match based on a second pattern of the plurality of patterns;
determine a second replacement string;
replace, prior to the logging, the second substring of the string of text with the second replacement string.
14 . The system of claim 12 , wherein a length of the first replacement string is different from a length of the first substring.
15 . The system of claim 12 , wherein the electronic processor is further configured to read a length of the first replacement string from a configuration file, wherein the length of the first replacement string is associated with the first pattern.
16 . The system of claim 12 , wherein the electronic processor is further configured to:
encrypt the first substring with a first cryptography algorithm; and
create a first security prefix based on the first cryptography algorithm, wherein the first replacement string comprises the first security prefix and the encrypted first substring.
17 . A non-transitory computer-readable storage medium storing computer-executable instructions that when executed by a processor cause the processor to perform operations comprising:
receiving a plurality of patterns;
receiving a request to log a string of text;
searching the string of text for a match using the plurality of patterns;
finding a first substring of the string of text that is a match based on a first pattern of the plurality of patterns;
determining a first replacement string;
replacing within the string of text the first substring with the first replacement string; and
logging the string of text after the replacing to a log.
18 . The non-transitory computer-readable storage medium of claim 17 , wherein the operations further comprise:
finding a second substring of the string of text that is a match based on a second pattern of the plurality of patterns;
determining a second replacement string;
replacing, prior to the logging, the second substring of the string of text with the second replacement string.
19 . The non-transitory computer-readable storage medium of claim 17 , wherein the operations further comprise reading a length of the first replacement string from a configuration file, wherein the length of the first replacement string is associated with the first pattern.
20 . The non-transitory computer-readable storage medium of claim 19 , wherein the operations further comprise:
encrypting the first substring with a first cryptography algorithm; and
creating a first security prefix based on the first cryptography algorithm, wherein the first replacement string comprises the first security prefix and the encrypted first substring.