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 // List of policies that are considered only if the user is part of a AD domain. |
| 77 const char* kInsecurePolicies[] = { |
| 78 key::kMetricsReportingEnabled, |
| 79 key::kDefaultSearchProviderEnabled, |
| 80 key::kHomepageIsNewTabPage, |
| 81 key::kHomepageLocation, |
| 82 key::kRestoreOnStartup, |
| 83 key::kRestoreOnStartupURLs |
| 84 }; |
| 85 |
75 // The GUID of the registry settings group policy extension. | 86 // The GUID of the registry settings group policy extension. |
76 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; | 87 GUID kRegistrySettingsCSEGUID = REGISTRY_EXTENSION_GUID; |
77 | 88 |
78 // The list of possible errors that can occur while collecting information about | 89 // The list of possible errors that can occur while collecting information about |
79 // the current enterprise environment. | 90 // the current enterprise environment. |
80 enum DomainCheckErrors { | 91 enum DomainCheckErrors { |
81 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, | 92 DOMAIN_CHECK_ERROR_GET_JOIN_INFO = 0, |
82 DOMAIN_CHECK_ERROR_DS_BIND, | 93 DOMAIN_CHECK_ERROR_DS_BIND, |
83 DOMAIN_CHECK_ERROR_LAST, | 94 DOMAIN_CHECK_ERROR_LAST, |
84 }; | 95 }; |
(...skipping 30 matching lines...) Expand all Loading... |
115 base::JSONWriter::Write(json.get(), &serialized); | 126 base::JSONWriter::Write(json.get(), &serialized); |
116 return serialized; | 127 return serialized; |
117 } | 128 } |
118 | 129 |
119 // Verifies that untrusted policies contain only safe values. Modifies the | 130 // Verifies that untrusted policies contain only safe values. Modifies the |
120 // |policy| in place. | 131 // |policy| in place. |
121 void FilterUntrustedPolicy(PolicyMap* policy) { | 132 void FilterUntrustedPolicy(PolicyMap* policy) { |
122 if (base::win::IsEnrolledToDomain()) | 133 if (base::win::IsEnrolledToDomain()) |
123 return; | 134 return; |
124 | 135 |
| 136 int invalid_policies = 0; |
125 const PolicyMap::Entry* map_entry = | 137 const PolicyMap::Entry* map_entry = |
126 policy->Get(policy::key::kExtensionInstallForcelist); | 138 policy->Get(policy::key::kExtensionInstallForcelist); |
127 if (map_entry && map_entry->value) { | 139 if (map_entry && map_entry->value) { |
128 int invalid_policies = 0; | |
129 const base::ListValue* policy_list_value = NULL; | 140 const base::ListValue* policy_list_value = NULL; |
130 if (!map_entry->value->GetAsList(&policy_list_value)) | 141 if (!map_entry->value->GetAsList(&policy_list_value)) |
131 return; | 142 return; |
132 | 143 |
133 scoped_ptr<base::ListValue> filtered_values(new base::ListValue); | 144 scoped_ptr<base::ListValue> filtered_values(new base::ListValue); |
134 for (base::ListValue::const_iterator list_entry(policy_list_value->begin()); | 145 for (base::ListValue::const_iterator list_entry(policy_list_value->begin()); |
135 list_entry != policy_list_value->end(); ++list_entry) { | 146 list_entry != policy_list_value->end(); ++list_entry) { |
136 std::string entry; | 147 std::string entry; |
137 if (!(*list_entry)->GetAsString(&entry)) | 148 if (!(*list_entry)->GetAsString(&entry)) |
138 continue; | 149 continue; |
139 size_t pos = entry.find(';'); | 150 size_t pos = entry.find(';'); |
140 if (pos == std::string::npos) | 151 if (pos == std::string::npos) |
141 continue; | 152 continue; |
142 // Only allow custom update urls in enterprise environments. | 153 // Only allow custom update urls in enterprise environments. |
143 if (!LowerCaseEqualsASCII(entry.substr(pos), kExpectedWebStoreUrl)) { | 154 if (!LowerCaseEqualsASCII(entry.substr(pos), kExpectedWebStoreUrl)) { |
144 entry = kBlockedExtensionPrefix + entry; | 155 entry = kBlockedExtensionPrefix + entry; |
145 invalid_policies++; | 156 invalid_policies++; |
146 } | 157 } |
147 | 158 |
148 filtered_values->AppendString(entry); | 159 filtered_values->AppendString(entry); |
149 } | 160 } |
150 policy->Set(policy::key::kExtensionInstallForcelist, | 161 if (invalid_policies) { |
151 map_entry->level, map_entry->scope, | 162 policy->Set(policy::key::kExtensionInstallForcelist, |
152 filtered_values.release(), | 163 map_entry->level, map_entry->scope, |
153 map_entry->external_data_fetcher); | 164 filtered_values.release(), |
154 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.InvalidPoliciesDetected", | 165 map_entry->external_data_fetcher); |
155 invalid_policies); | 166 |
| 167 const PolicyDetails* details = policy::GetChromePolicyDetails( |
| 168 policy::key::kExtensionInstallForcelist); |
| 169 UMA_HISTOGRAM_SPARSE_SLOWLY("EnterpriseCheck.InvalidPolicies", |
| 170 details->id); |
| 171 } |
156 } | 172 } |
| 173 |
| 174 for (size_t i = 0; i < arraysize(kInsecurePolicies); ++i) { |
| 175 if (policy->Get(kInsecurePolicies[i])) { |
| 176 // TODO(pastarmovj): Surface this issue in the about:policy page. |
| 177 policy->Erase(kInsecurePolicies[i]); |
| 178 invalid_policies++; |
| 179 const PolicyDetails* details = |
| 180 policy::GetChromePolicyDetails(kInsecurePolicies[i]); |
| 181 UMA_HISTOGRAM_SPARSE_SLOWLY("EnterpriseCheck.InvalidPolicies", |
| 182 details->id); |
| 183 } |
| 184 } |
| 185 |
| 186 UMA_HISTOGRAM_COUNTS("EnterpriseCheck.InvalidPoliciesDetected", |
| 187 invalid_policies); |
157 } | 188 } |
158 | 189 |
159 // A helper class encapsulating run-time-linked function calls to Wow64 APIs. | 190 // A helper class encapsulating run-time-linked function calls to Wow64 APIs. |
160 class Wow64Functions { | 191 class Wow64Functions { |
161 public: | 192 public: |
162 Wow64Functions() | 193 Wow64Functions() |
163 : kernel32_lib_(base::FilePath(L"kernel32")), | 194 : kernel32_lib_(base::FilePath(L"kernel32")), |
164 is_wow_64_process_(NULL), | 195 is_wow_64_process_(NULL), |
165 wow_64_disable_wow_64_fs_redirection_(NULL), | 196 wow_64_disable_wow_64_fs_redirection_(NULL), |
166 wow_64_revert_wow_64_fs_redirection_(NULL) { | 197 wow_64_revert_wow_64_fs_redirection_(NULL) { |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 677 |
647 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { | 678 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { |
648 DCHECK(object == user_policy_changed_event_.handle() || | 679 DCHECK(object == user_policy_changed_event_.handle() || |
649 object == machine_policy_changed_event_.handle()) | 680 object == machine_policy_changed_event_.handle()) |
650 << "unexpected object signaled policy reload, obj = " | 681 << "unexpected object signaled policy reload, obj = " |
651 << std::showbase << std::hex << object; | 682 << std::showbase << std::hex << object; |
652 Reload(false); | 683 Reload(false); |
653 } | 684 } |
654 | 685 |
655 } // namespace policy | 686 } // namespace policy |
OLD | NEW |