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

Unified Diff: components/crash/content/app/breakpad_linux.cc

Issue 2717223003: Add WebView-specific whitelist for crash keys. (Closed)
Patch Set: Use non-allocating whitelist implementation. Add instrumentation tests. Created 3 years, 10 months 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/crash/content/app/breakpad_linux.cc
diff --git a/components/crash/content/app/breakpad_linux.cc b/components/crash/content/app/breakpad_linux.cc
index 3c31d7619e49bf56210ff310e3a73905c58a43ec..2bf06867b0f28b91d01ae4cf33ddd18b42032344 100644
--- a/components/crash/content/app/breakpad_linux.cc
+++ b/components/crash/content/app/breakpad_linux.cc
@@ -30,6 +30,7 @@
#include "base/debug/crash_logging.h"
#include "base/debug/dump_without_crashing.h"
#include "base/files/file_path.h"
+#include "base/format_macros.h"
#include "base/lazy_instance.h"
#include "base/linux_util.h"
#include "base/macros.h"
@@ -39,6 +40,7 @@
#include "base/process/memory.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/threading/thread_checker.h"
#include "breakpad/src/client/linux/crash_generation/crash_generation_client.h"
#include "breakpad/src/client/linux/handler/exception_handler.h"
@@ -1098,9 +1100,42 @@ void EnableNonBrowserCrashDumping() {
}
#endif // defined(OS_ANDROID)
+bool g_use_crash_keys_whitelist;
+std::vector<const char*> g_crash_keys_whitelist;
+
+void SetupCrashKeysWhiteList(bool use_white_list,
+ const std::vector<const char*>& keys) {
+ g_use_crash_keys_whitelist = use_white_list;
+ g_crash_keys_whitelist = keys;
+ LOG(ERROR) << "in SetupCrashKeysWhiteList, whitelist length: " << keys.size();
+ for (size_t i = 0; i < keys.size(); ++i) {
+ LOG(ERROR) << "in SetupCrashKeysWhiteList, entry: "
+ << g_crash_keys_whitelist.data()[i];
+ }
+}
+
+bool IsInWhiteList(const base::StringPiece& key) {
+ for (size_t i = 0; i < g_crash_keys_whitelist.size(); ++i) {
+ LOG(ERROR) << "in SetupCrashKeysWhiteList, entry: "
+ << g_crash_keys_whitelist.data()[i];
+ if (0 == my_strcmp(g_crash_keys_whitelist.data()[i], key.data())) {
+ return true;
+ }
+ }
+ return false;
+}
+
void SetCrashKeyValue(const base::StringPiece& key,
const base::StringPiece& value) {
- g_crash_keys->SetKeyValue(key.data(), value.data());
+ LOG(ERROR) << "in SetCrashKeyValue for key " << key.data();
+ if (!g_use_crash_keys_whitelist || IsInWhiteList(key)) {
+ LOG(ERROR) << "in SetCrashKeyValue for key " << key.data()
+ << " it is in the whitelist :D";
+ g_crash_keys->SetKeyValue(key.data(), value.data());
+ } else {
+ LOG(ERROR) << "in SetCrashKeyValue for key " << key.data()
+ << ", not in the whitelist";
+ }
}
void ClearCrashKey(const base::StringPiece& key) {
@@ -1112,6 +1147,8 @@ void ClearCrashKey(const base::StringPiece& key) {
void InitCrashKeys() {
g_crash_keys = new CrashKeyStorage;
GetCrashReporterClient()->RegisterCrashKeys();
+ SetupCrashKeysWhiteList(GetCrashReporterClient()->UseCrashKeysWhiteList(),
+ GetCrashReporterClient()->GetWhiteListedCrashKeys());
base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValue, &ClearCrashKey);
}
@@ -1905,6 +1942,10 @@ void InitCrashReporter(const std::string& process_type) {
InitCrashReporter(process_type, sanitization_info);
}
+void InitCrashKeysForTesting() {
+ InitCrashKeys();
+}
+
void InitCrashReporter(const std::string& process_type,
const SanitizationInfo& sanitization_info) {
#else

Powered by Google App Engine
This is Rietveld 408576698