redaction_tool: Keeping the source up-to-date

UMA metrics were added to redaction tool; uprev to keep the source
up-to-date.

BUG=b:265030885
TEST=unit tests

Change-Id: Ifb1fadc875ca7f466005bcb015384bcf3072d602
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/redaction_tool/+/4308014
Tested-by: Ramya Gopalan <[email protected]>
Tested-by: Nik K <[email protected]>
Reviewed-by: Nik K <[email protected]>
Reviewed-by: Donna Dionne <[email protected]>
Commit-Queue: Donna Dionne <[email protected]>
Reviewed-by: Ramya Gopalan <[email protected]>
diff --git a/pii_types.h b/pii_types.h
index 733fe31..c052efd 100644
--- a/pii_types.h
+++ b/pii_types.h
@@ -9,49 +9,52 @@
 
 // PII (Personally Identifiable Information) types that can be detected in the
 // debug data.
+// These values are persisted to logs. Entries should not be renumbered and
+// numeric values should never be reused.
+// Keep the order in sync with enums.xml.
 enum class PIIType {
   // Indicates no PII. Mainly for testing.
-  kNone,
+  kNone = 0,
   // Android App Storage paths. The path starts with either
   // /home/root/<hash>/data/data/<package_name>/ or
   // /home/root/<hash>/data/user_de/<number>/<package_name>/, the path
   // components following <package_name>/ are app specific and will be
   // considered as PII sensitive data.
-  kAndroidAppStoragePath,
+  kAndroidAppStoragePath = 1,
   // Email addresses.
-  kEmail,
+  kEmail = 2,
   // GAIA (Google Accounts and ID Administration) ID. Gaia ID is a 64-bit
   // integer.
-  kGaiaID,
+  kGaiaID = 3,
   // IPP (Internet Printing Protocol) Addresses.
-  kIPPAddress,
+  kIPPAddress = 4,
   // IP (Internet Protocol) address. Stores data in two versions: IPv4 (e.g.
   // 127.0.0.1) or IPv6 (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334).
-  kIPAddress,
+  kIPAddress = 5,
   // Location information related to Cell tower object that's used by
   // ModemManager. Contains two type of data:
   // 1- The Location Area Code (LAC) for GSM and WCDMA networks of the Cell
   // tower object that's used by ModemManager.
   // 2- Cell ID as unique identifier of the cell of the Cell tower object that's
   // used by ModemManager.
-  kLocationInfo,
+  kLocationInfo = 6,
   // MAC address is a unique identifier assigned to a network interface
   // controller (NIC) for use as a network address in communications within a
   // network segment (e.g 00:00:5e:00:53:af). MAC addresses with general meaning
   // like ARP failure result MAC and Broadcast MAC won't be treated as PII
   // sensitive data and won't be included in this category.
-  kMACAddress,
+  kMACAddress = 7,
   // Window titles that appear in UI hierarchy.
-  kUIHierarchyWindowTitles,
+  kUIHierarchyWindowTitles = 8,
   // URLs that can appear in logs.
-  kURL,
+  kURL = 9,
   // Serial numbers, which also includes PSM identifiers.
-  kSerial,
+  kSerial = 10,
   // SSID (Service Set Identifier) of wifi networks can be detected in the logs
   // provided by wpa_supplicant and shill. BSSID (Basic Service Set Identifier)
   // of a wifi service, is also categorized under this. This type also contains
   // custom names of WiFi, cellular, Ethernet, etc.
-  kSSID,
+  kSSID = 11,
   // Stable identifiers. Contains information in these main categories:
   // 1- Universal Unique Identifiers (UUIDs): UUID can also be given by 'blkid',
   // 'lvs' and 'pvs' tools.
@@ -59,12 +62,13 @@
   // hashes.
   // 3- Eche specific UID which is a base46 conversion of a 32 byte binary value
   // generated by `ash/webui/eche_app_ui/eche_uid_provider.cc`
-  kStableIdentifier,
+  kStableIdentifier = 12,
   // Volume labels presented in the 'blkid' tool, and as part of removable
   // media paths shown in various logs such as cros-disks (in syslog).
-  kVolumeLabel,
+  kVolumeLabel = 13,
   // Extensible Authentication Protocol (EAP) properties provided by shill.
-  kEAP,
+  kEAP = 14,
+  kMaxValue = kEAP,
 };
 
 }  // namespace redaction
diff --git a/redaction_tool.cc b/redaction_tool.cc
index 5a96288..d30cd6c 100644
--- a/redaction_tool.cc
+++ b/redaction_tool.cc
@@ -9,6 +9,7 @@
 #include <vector>
 
 #include "base/files/file_path.h"
+#include "base/metrics/histogram_macros.h"
 #include "base/strings/strcat.h"
 #include "base/strings/string_number_conversions.h"
 #include "base/strings/string_util.h"
@@ -506,6 +507,8 @@
 };
 constexpr size_t kNumUnredactedMacs = std::size(kUnredactedMacAddresses);
 
+constexpr char kFeedbackRedactionToolHistogramName[] = "Feedback.RedactionTool";
+
 }  // namespace
 
 RedactionTool::RedactionTool(const char* const* first_party_extension_ids)
@@ -638,6 +641,10 @@
   }
 
   text.AppendToString(&result);
+
+  UMA_HISTOGRAM_ENUMERATION(kFeedbackRedactionToolHistogramName,
+                            PIIType::kMACAddress);
+
   return result;
 }
 
@@ -695,6 +702,10 @@
   }
 
   text.AppendToString(&result);
+
+  UMA_HISTOGRAM_ENUMERATION(kFeedbackRedactionToolHistogramName,
+                            PIIType::kStableIdentifier);
+
   return result;
 }
 
@@ -761,6 +772,10 @@
   }
 
   text.AppendToString(&result);
+
+  UMA_HISTOGRAM_ENUMERATION(kFeedbackRedactionToolHistogramName,
+                            PIIType::kAndroidAppStoragePath);
+
   return result;
 #else
   return input;
@@ -833,6 +848,10 @@
     post_matched_id.AppendToString(&result);
   }
   text.AppendToString(&result);
+
+  UMA_HISTOGRAM_ENUMERATION(kFeedbackRedactionToolHistogramName,
+                            pattern.pii_type);
+
   return result;
 }
 
@@ -951,6 +970,10 @@
     result += replacement_id;
   }
   text.AppendToString(&result);
+
+  UMA_HISTOGRAM_ENUMERATION(kFeedbackRedactionToolHistogramName,
+                            pattern.pii_type);
+
   return result;
 }