Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Unified Diff: components/feedback/feedback_common.cc

Issue 1530403003: Add anonymizer tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/feedback/feedback_common.cc
diff --git a/components/feedback/feedback_common.cc b/components/feedback/feedback_common.cc
index e3e27480c7a0c90805a1c316ef4ae35dbb66ef8b..9c20310978930d60891dabc7d6dc16a809392b0b 100644
--- a/components/feedback/feedback_common.cc
+++ b/components/feedback/feedback_common.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "feedback_common.h"
+#include "components/feedback/feedback_common.h"
#include "base/strings/string_util.h"
+#include "components/feedback/anonymizer_tool.h"
#include "components/feedback/proto/common.pb.h"
#include "components/feedback/proto/dom.pb.h"
#include "components/feedback/proto/extension.pb.h"
@@ -32,8 +33,10 @@ const char kArbitraryMimeType[] = "application/octet-stream";
// with the report. This method only converts those logs that we want in
// the compressed zip file sent with the report, hence it ignores any logs
// below the size threshold of what we want compressed.
+// Logs files are anonymized by the AnonymizerTool.
std::string* LogsToString(const FeedbackCommon::SystemLogsMap& sys_info) {
std::string* syslogs_string = new std::string;
+ feedback::AnonymizerTool anonymizer;
for (FeedbackCommon::SystemLogsMap::const_iterator it = sys_info.begin();
it != sys_info.end();
++it) {
@@ -46,6 +49,8 @@ std::string* LogsToString(const FeedbackCommon::SystemLogsMap& sys_info) {
base::TrimString(key, "\n ", &key);
base::TrimString(value, "\n ", &value);
+ value = anonymizer.Anonymize(value);
+
if (value.find("\n") != std::string::npos) {
syslogs_string->append(key + "=" + kMultilineIndicatorString +
kMultilineStartString + value + "\n" +
@@ -57,16 +62,20 @@ std::string* LogsToString(const FeedbackCommon::SystemLogsMap& sys_info) {
return syslogs_string;
}
+// Data is anonymized by the AnonymizerTool.
void AddFeedbackData(userfeedback::ExtensionSubmit* feedback_data,
const std::string& key,
const std::string& value) {
// Don't bother with empty keys or values.
if (key.empty() || value.empty())
return;
+
+ feedback::AnonymizerTool anonymizer;
+
// Create log_value object and add it to the web_data object.
userfeedback::ProductSpecificData log_value;
log_value.set_key(key);
- log_value.set_value(value);
+ log_value.set_value(anonymizer.Anonymize(value));
userfeedback::WebData* web_data = feedback_data->mutable_web_data();
*(web_data->add_product_specific_data()) = log_value;
}

Powered by Google App Engine
This is Rietveld 408576698