Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "components/policy/core/common/policy_loader_win.h" | 5 #include "components/policy/core/common/policy_loader_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <lm.h> // For limits. | 8 #include <lm.h> // For limits. |
| 9 #include <ntdsapi.h> // For Ds[Un]Bind | 9 #include <ntdsapi.h> // For Ds[Un]Bind |
| 10 #include <rpc.h> // For struct GUID | 10 #include <rpc.h> // For struct GUID |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 #include "base/basictypes.h" | 24 #include "base/basictypes.h" |
| 25 #include "base/bind.h" | 25 #include "base/bind.h" |
| 26 #include "base/file_util.h" | 26 #include "base/file_util.h" |
| 27 #include "base/json/json_reader.h" | 27 #include "base/json/json_reader.h" |
| 28 #include "base/json/json_writer.h" | 28 #include "base/json/json_writer.h" |
| 29 #include "base/lazy_instance.h" | 29 #include "base/lazy_instance.h" |
| 30 #include "base/logging.h" | 30 #include "base/logging.h" |
| 31 #include "base/memory/scoped_ptr.h" | 31 #include "base/memory/scoped_ptr.h" |
| 32 #include "base/metrics/histogram.h" | 32 #include "base/metrics/histogram.h" |
| 33 #include "base/metrics/sparse_histogram.h" | |
| 33 #include "base/scoped_native_library.h" | 34 #include "base/scoped_native_library.h" |
| 34 #include "base/sequenced_task_runner.h" | 35 #include "base/sequenced_task_runner.h" |
| 35 #include "base/stl_util.h" | 36 #include "base/stl_util.h" |
| 36 #include "base/strings/string16.h" | 37 #include "base/strings/string16.h" |
| 37 #include "base/strings/string_util.h" | 38 #include "base/strings/string_util.h" |
| 38 #include "base/values.h" | 39 #include "base/values.h" |
| 39 #include "base/win/win_util.h" | 40 #include "base/win/win_util.h" |
| 40 #include "base/win/windows_version.h" | 41 #include "base/win/windows_version.h" |
| 41 #include "components/json_schema/json_schema_constants.h" | 42 #include "components/json_schema/json_schema_constants.h" |
| 42 #include "components/policy/core/common/policy_bundle.h" | 43 #include "components/policy/core/common/policy_bundle.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 65 // TODO(joaodasilva): remove this for M35. http://crbug.com/325349 | 66 // TODO(joaodasilva): remove this for M35. http://crbug.com/325349 |
| 66 const char kLegacyBrowserSupportExtensionId[] = | 67 const char kLegacyBrowserSupportExtensionId[] = |
| 67 "heildphpnddilhkemkielfhnkaagiabh"; | 68 "heildphpnddilhkemkielfhnkaagiabh"; |
| 68 | 69 |
| 69 // The web store url that is the only trusted source for extensions. | 70 // The web store url that is the only trusted source for extensions. |
| 70 const char kExpectedWebStoreUrl[] = | 71 const char kExpectedWebStoreUrl[] = |
| 71 ";https://clients2.google.com/service/update2/crx"; | 72 ";https://clients2.google.com/service/update2/crx"; |
| 72 // String to be prepended to each blocked entry. | 73 // String to be prepended to each blocked entry. |
| 73 const char kBlockedExtensionPrefix[] = "[BLOCKED]"; | 74 const char kBlockedExtensionPrefix[] = "[BLOCKED]"; |
| 74 | 75 |
| 76 const char* kInsecurePolicies[] = { | |
|
Joao da Silva
2014/07/17 09:57:55
Document
pastarmovj
2014/07/17 14:12:59
Done.
| |
| 77 policy::key::kMetricsReportingEnabled, | |
| 78 policy::key::kDefaultSearchProviderEnabled, | |
|
Joao da Silva
2014/07/17 09:57:55
Shouldn't we include all of the search provider po
pastarmovj
2014/07/17 14:12:59
They are gated on this one can be a useful lead if
| |
| 79 policy::key::kHomepageIsNewTabPage, | |
| 80 policy::key::kHomepageLocation, | |
| 81 policy::key::kRestoreOnStartup, | |
| 82 policy::key::kRestoreOnStartupURLs | |
|
Joao da Silva
2014/07/17 09:57:55
policy:: isn't needed
pastarmovj
2014/07/17 14:12:59
Done.
| |
| 83 }; | |
| 84 | |
| 75 // The GUID of the registry settings group policy extension. | 85 // The GUID of the registry settings group policy extension. |
| 76 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; | 86 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; |
| 77 | 87 |
| 78 // The list of possible errors that can occur while collecting information about | 88 // The list of possible errors that can occur while collecting information about |
| 79 // the current enterprise environment. | 89 // the current enterprise environment. |
| 80 enum DomainCheckErrors { | 90 enum DomainCheckErrors { |
| 81 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, | 91 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, |
| 82 DOMAIN_CHECK_ERROR_DS_BIND, | 92 DOMAIN_CHECK_ERROR_DS_BIND, |
| 83 DOMAIN_CHECK_ERROR_LAST, | 93 DOMAIN_CHECK_ERROR_LAST, |
| 84 }; | 94 }; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 if (pos == std::string::npos) | 150 if (pos == std::string::npos) |
| 141 continue; | 151 continue; |
| 142 // Only allow custom update urls in enterprise environments. | 152 // Only allow custom update urls in enterprise environments. |
| 143 if (!LowerCaseEqualsASCII(entry.substr(pos), kExpectedWebStoreUrl)) { | 153 if (!LowerCaseEqualsASCII(entry.substr(pos), kExpectedWebStoreUrl)) { |
| 144 entry = kBlockedExtensionPrefix + entry; | 154 entry = kBlockedExtensionPrefix + entry; |
| 145 invalid_policies++; | 155 invalid_policies++; |
| 146 } | 156 } |
| 147 | 157 |
| 148 filtered_values->AppendString(entry); | 158 filtered_values->AppendString(entry); |
| 149 } | 159 } |
| 150 policy->Set(policy::key::kExtensionInstallForcelist, | 160 if (invalid_policies) { |
| 151 map_entry->level, map_entry->scope, | 161 policy->Set(policy::key::kExtensionInstallForcelist, |
| 152 filtered_values.release(), | 162 map_entry->level, map_entry->scope, |
| 153 map_entry->external_data_fetcher); | 163 filtered_values.release(), |
| 164 map_entry->external_data_fetcher); | |
| 165 | |
| 166 const PolicyDetails* details = policy::GetChromePolicyDetails( | |
| 167 policy::key::kExtensionInstallForcelist); | |
| 168 UMA_HISTOGRAM_SPARSE_SLOWLY("EnterpriseCheck.InvalidPolicies", | |
| 169 details->id); | |
| 170 } | |
| 171 | |
| 172 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInsecurePolicies); ++i) { | |
|
Joao da Silva
2014/07/17 09:57:55
Doesn't arraysize() work here?
pastarmovj
2014/07/17 14:12:59
Done.
| |
| 173 if (policy->Get(kInsecurePolicies[i])) { | |
| 174 policy->Erase(kInsecurePolicies[i]); | |
|
Joao da Silva
2014/07/17 09:57:55
It would be cool to have this somehow surface in a
pastarmovj
2014/07/17 14:12:59
Done.
| |
| 175 invalid_policies++; | |
| 176 const PolicyDetails* details = | |
| 177 policy::GetChromePolicyDetails(kInsecurePolicies[i]); | |
| 178 UMA_HISTOGRAM_SPARSE_SLOWLY("EnterpriseCheck.InvalidPolicies", | |
| 179 details->id); | |
| 180 } | |
| 181 } | |
|
Joao da Silva
2014/07/17 09:57:55
This is in the wrong block: it shouldn't be condit
pastarmovj
2014/07/17 14:12:59
Done.
| |
| 182 | |
| 154 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.InvalidPoliciesDetected", | 183 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.InvalidPoliciesDetected", |
| 155 invalid_policies); | 184 invalid_policies); |
| 156 } | 185 } |
| 157 } | 186 } |
| 158 | 187 |
| 159 // A helper class encapsulating run-time-linked function calls to Wow64 APIs. | 188 // A helper class encapsulating run-time-linked function calls to Wow64 APIs. |
| 160 class Wow64Functions { | 189 class Wow64Functions { |
| 161 public: | 190 public: |
| 162 Wow64Functions() | 191 Wow64Functions() |
| 163 : kernel32_lib_(base::FilePath(L"kernel32")), | 192 : kernel32_lib_(base::FilePath(L"kernel32")), |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 | 675 |
| 647 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { | 676 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { |
| 648 DCHECK(object == user_policy_changed_event_.handle() || | 677 DCHECK(object == user_policy_changed_event_.handle() || |
| 649 object == machine_policy_changed_event_.handle()) | 678 object == machine_policy_changed_event_.handle()) |
| 650 << "unexpected object signaled policy reload, obj = " | 679 << "unexpected object signaled policy reload, obj = " |
| 651 << std::showbase << std::hex << object; | 680 << std::showbase << std::hex << object; |
| 652 Reload(false); | 681 Reload(false); |
| 653 } | 682 } |
| 654 | 683 |
| 655 } // namespace policy | 684 } // namespace policy |
| OLD | NEW |