OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ | 5 #ifndef COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ |
6 #define COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ | 6 #define COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include <base/macros.h> | 12 #include <base/macros.h> |
13 | 13 |
14 namespace feedback { | 14 namespace feedback { |
15 | 15 |
16 struct CustomPatternWithoutContext { | |
vasilii
2015/12/22 12:31:42
A comment.
battre
2016/01/08 14:14:32
Done.
| |
17 const char* alias; | |
18 const char* pattern; | |
19 }; | |
20 | |
16 class AnonymizerTool { | 21 class AnonymizerTool { |
17 public: | 22 public: |
18 AnonymizerTool(); | 23 AnonymizerTool(); |
19 ~AnonymizerTool(); | 24 ~AnonymizerTool(); |
20 | 25 |
21 // Returns an anonymized version of |input|. PII-sensitive data (such as MAC | 26 // Returns an anonymized version of |input|. PII-sensitive data (such as MAC |
22 // addresses) in |input| is replaced with unique identifiers. | 27 // addresses) in |input| is replaced with unique identifiers. |
23 std::string Anonymize(const std::string& input); | 28 std::string Anonymize(const std::string& input); |
24 | 29 |
25 private: | 30 private: |
26 friend class AnonymizerToolTest; | 31 friend class AnonymizerToolTest; |
27 | 32 |
28 std::string AnonymizeMACAddresses(const std::string& input); | 33 std::string AnonymizeMACAddresses(const std::string& input); |
29 std::string AnonymizeCustomPatterns(std::string input); | 34 std::string AnonymizeCustomPatterns(std::string input); |
30 static std::string AnonymizeCustomPattern( | 35 static std::string AnonymizeCustomPatternWithContext( |
31 const std::string& input, | 36 const std::string& input, |
32 const std::string& pattern, | 37 const std::string& pattern, |
33 std::map<std::string, std::string>* identifier_space); | 38 std::map<std::string, std::string>* identifier_space); |
39 static std::string AnonymizeCustomPatternWithoutContext( | |
40 const std::string& input, | |
41 const CustomPatternWithoutContext& pattern, | |
42 std::map<std::string, std::string>* identifier_space); | |
34 | 43 |
35 // Map of MAC addresses discovered in anonymized strings to anonymized | 44 // Map of MAC addresses discovered in anonymized strings to anonymized |
36 // representations. 11:22:33:44:55:66 gets anonymized to 11:22:33:00:00:01, | 45 // representations. 11:22:33:44:55:66 gets anonymized to 11:22:33:00:00:01, |
37 // where the first three bytes represent the manufacturer. The last three | 46 // where the first three bytes represent the manufacturer. The last three |
38 // bytes are used to distinguish different MAC addresses and are incremented | 47 // bytes are used to distinguish different MAC addresses and are incremented |
39 // for each newly discovered MAC address. | 48 // for each newly discovered MAC address. |
40 std::map<std::string, std::string> mac_addresses_; | 49 std::map<std::string, std::string> mac_addresses_; |
41 | 50 |
42 // Like mac addresses, identifiers in custom patterns are anonymized. | 51 // Like mac addresses, identifiers in custom patterns are anonymized. |
43 // custom_patterns_[i] contains a map of original identifier to anonymized | 52 // custom_patterns_with_context_[i] contains a map of original identifier to |
44 // identifier for custom pattern number i. | 53 // anonymized identifier for custom pattern number i. |
45 std::vector<std::map<std::string, std::string>> custom_patterns_; | 54 std::vector<std::map<std::string, std::string>> custom_patterns_with_context_; |
55 std::vector<std::map<std::string, std::string>> | |
56 custom_patterns_without_context_; | |
46 | 57 |
47 DISALLOW_COPY_AND_ASSIGN(AnonymizerTool); | 58 DISALLOW_COPY_AND_ASSIGN(AnonymizerTool); |
48 }; | 59 }; |
49 | 60 |
50 } // namespace feedback | 61 } // namespace feedback |
51 | 62 |
52 #endif // COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ | 63 #endif // COMPONENTS_FEEDBACK_ANONYMIZER_TOOL_H_ |
OLD | NEW |