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

Side by Side Diff: chrome/browser/chrome_elf_init_win.cc

Issue 300933002: Finch Blacklist is now added to the Hardcoded blacklist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final changes? Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/chrome_elf_init_win.h ('k') | chrome_elf/blacklist/blacklist.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/metrics/field_trial.h" 6 #include "base/metrics/field_trial.h"
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/win/registry.h" 10 #include "base/win/registry.h"
11 #include "chrome/browser/chrome_elf_init_win.h" 11 #include "chrome/browser/chrome_elf_init_win.h"
12 #include "chrome_elf/blacklist/blacklist.h" 12 #include "chrome_elf/blacklist/blacklist.h"
13 #include "chrome_elf/chrome_elf_constants.h" 13 #include "chrome_elf/chrome_elf_constants.h"
14 #include "chrome_elf/dll_hash/dll_hash.h" 14 #include "chrome_elf/dll_hash/dll_hash.h"
15 #include "components/variations/variations_associated_data.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
16 #include "version.h" // NOLINT 17 #include "version.h" // NOLINT
17 18
18 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist"; 19 const char kBrowserBlacklistTrialName[] = "BrowserBlacklist";
19 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist"; 20 const char kBrowserBlacklistTrialDisabledGroupName[] = "NoBlacklist";
20 21
21 namespace { 22 namespace {
22 23
23 // How long to wait, in seconds, before reporting for the second (and last 24 // How long to wait, in seconds, before reporting for the second (and last
24 // time), what dlls were blocked from the browser process. 25 // time), what dlls were blocked from the browser process.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 } // namespace 82 } // namespace
82 83
83 void InitializeChromeElf() { 84 void InitializeChromeElf() {
84 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) == 85 if (base::FieldTrialList::FindFullName(kBrowserBlacklistTrialName) ==
85 kBrowserBlacklistTrialDisabledGroupName) { 86 kBrowserBlacklistTrialDisabledGroupName) {
86 // Disable the blacklist for all future runs by removing the beacon. 87 // Disable the blacklist for all future runs by removing the beacon.
87 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER); 88 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER);
88 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath); 89 blacklist_registry_key.DeleteKey(blacklist::kRegistryBeaconPath);
89 } else { 90 } else {
91 AddFinchBlacklistToRegistry();
90 BrowserBlacklistBeaconSetup(); 92 BrowserBlacklistBeaconSetup();
91 } 93 }
92 94
93 // Report all successful blacklist interceptions. 95 // Report all successful blacklist interceptions.
94 ReportSuccessfulBlocks(); 96 ReportSuccessfulBlocks();
95 97
96 // Schedule another task to report all sucessful interceptions later. 98 // Schedule another task to report all sucessful interceptions later.
97 // This time delay should be long enough to catch any dlls that attempt to 99 // This time delay should be long enough to catch any dlls that attempt to
98 // inject after Chrome has started up. 100 // inject after Chrome has started up.
99 content::BrowserThread::PostDelayedTask( 101 content::BrowserThread::PostDelayedTask(
100 content::BrowserThread::UI, 102 content::BrowserThread::UI,
101 FROM_HERE, 103 FROM_HERE,
102 base::Bind(&ReportSuccessfulBlocks), 104 base::Bind(&ReportSuccessfulBlocks),
103 base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec)); 105 base::TimeDelta::FromSeconds(kBlacklistReportingDelaySec));
104 } 106 }
105 107
108 void AddFinchBlacklistToRegistry() {
109 base::win::RegKey finch_blacklist_registry_key(
110 HKEY_CURRENT_USER, blacklist::kRegistryFinchListPath, KEY_SET_VALUE);
111
112 // No point in trying to continue if the registry key isn't valid.
113 if (!finch_blacklist_registry_key.Valid())
114 return;
115
116 std::map<std::string, std::string> params;
117 chrome_variations::GetVariationParams(kBrowserBlacklistTrialName, &params);
118
119 for (std::map<std::string, std::string>::iterator it = params.begin();
120 it != params.end();
121 ++it) {
122 std::wstring name = base::UTF8ToWide(it->first);
123 std::wstring val = base::UTF8ToWide(it->second);
124
125 finch_blacklist_registry_key.WriteValue(name.c_str(), val.c_str());
126 }
127 }
128
106 void BrowserBlacklistBeaconSetup() { 129 void BrowserBlacklistBeaconSetup() {
107 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER, 130 base::win::RegKey blacklist_registry_key(HKEY_CURRENT_USER,
108 blacklist::kRegistryBeaconPath, 131 blacklist::kRegistryBeaconPath,
109 KEY_QUERY_VALUE | KEY_SET_VALUE); 132 KEY_QUERY_VALUE | KEY_SET_VALUE);
110 133
111 // No point in trying to continue if the registry key isn't valid. 134 // No point in trying to continue if the registry key isn't valid.
112 if (!blacklist_registry_key.Valid()) 135 if (!blacklist_registry_key.Valid())
113 return; 136 return;
114 137
115 // Record the results of the last blacklist setup. 138 // Record the results of the last blacklist setup.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 LONG set_state = blacklist_registry_key.WriteValue( 176 LONG set_state = blacklist_registry_key.WriteValue(
154 blacklist::kBeaconState, 177 blacklist::kBeaconState,
155 blacklist::BLACKLIST_ENABLED); 178 blacklist::BLACKLIST_ENABLED);
156 179
157 // Only report the blacklist as getting setup when both registry writes 180 // Only report the blacklist as getting setup when both registry writes
158 // succeed, since otherwise the blacklist wasn't properly setup. 181 // succeed, since otherwise the blacklist wasn't properly setup.
159 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS) 182 if (set_version == ERROR_SUCCESS && set_state == ERROR_SUCCESS)
160 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED); 183 RecordBlacklistSetupEvent(BLACKLIST_SETUP_ENABLED);
161 } 184 }
162 } 185 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_elf_init_win.h ('k') | chrome_elf/blacklist/blacklist.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698