Index: chrome/renderer/pepper/pepper_uma_host.cc |
diff --git a/chrome/renderer/pepper/pepper_uma_host.cc b/chrome/renderer/pepper/pepper_uma_host.cc |
index dbf605bf2bd8eb322bf52f6218193d0041664b27..d57ce38a2a7d7e261fb0b7828f0338da9fe4e827 100644 |
--- a/chrome/renderer/pepper/pepper_uma_host.cc |
+++ b/chrome/renderer/pepper/pepper_uma_host.cc |
@@ -7,6 +7,7 @@ |
#include "base/metrics/histogram.h" |
#include "base/sha1.h" |
#include "base/strings/string_number_conversions.h" |
+#include "base/strings/string_util.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/render_messages.h" |
#include "chrome/renderer/chrome_content_renderer_client.h" |
@@ -32,9 +33,12 @@ const char* const kWhitelistedHistogramPrefixes[] = { |
"22F67DA2061FFC4DC9A4974036348D9C38C22919" // see http://crbug.com/390221 |
}; |
-const char* const kWhitelistedPluginBaseNames[] = { |
- "libwidevinecdmadapter.so", // see http://crbug.com/368743 |
- "libpdf.so" // see http://crbug.com/405305 |
+// Name patterns in this list should be as specific as possible to avoid |
+// over-whitelisting unexpected plugins. |
+const char* const kWhitelistedPluginNamePatterns[] = { |
+ "*widevinecdmadapter.*", // see http://crbug.com/368743 and |
ddorwin
2014/09/12 16:11:08
How good is the pattern matching? Can we do someth
xhwang
2014/09/12 16:33:58
No, it only supports * and ?. Probably I can find
|
+ // http://crbug.com/410630 |
+ "libpdf.so" // see http://crbug.com/405305 |
}; |
std::string HashPrefix(const std::string& histogram) { |
@@ -61,8 +65,8 @@ PepperUMAHost::PepperUMAHost(content::RendererPpapiHost* host, |
allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]); |
for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i) |
allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]); |
- for (size_t i = 0; i < arraysize(kWhitelistedPluginBaseNames); ++i) |
- allowed_plugin_base_names_.insert(kWhitelistedPluginBaseNames[i]); |
+ for (size_t i = 0; i < arraysize(kWhitelistedPluginNamePatterns); ++i) |
+ allowed_plugin_name_patterns_.insert(kWhitelistedPluginNamePatterns[i]); |
} |
PepperUMAHost::~PepperUMAHost() {} |
@@ -99,9 +103,12 @@ bool PepperUMAHost::IsHistogramAllowed(const std::string& histogram) { |
return true; |
} |
- if (allowed_plugin_base_names_.find(plugin_base_name_.MaybeAsASCII()) != |
- allowed_plugin_base_names_.end()) { |
- return true; |
+ std::string plugin_base_name_string = plugin_base_name_.MaybeAsASCII(); |
+ std::set<std::string>::const_iterator iter = |
ddorwin
2014/09/12 16:11:08
Why is this outside the for loop?
xhwang
2014/09/12 16:33:57
I hated the long line... will fix :) ~~
|
+ allowed_plugin_name_patterns_.begin(); |
+ for (; iter != allowed_plugin_name_patterns_.end(); ++iter) { |
+ if (MatchPattern(plugin_base_name_string, *iter)) |
+ return true; |
} |
LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API."; |