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

Side by Side Diff: chromeos/network/onc/onc_validator.cc

Issue 11428078: Rejecting networks/certificates individually from ONC during validation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@add_error_handling_to_validator
Patch Set: Addressed Steven's comment. Created 8 years 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 | « chromeos/network/onc/onc_validator.h ('k') | chromeos/network/onc/onc_validator_unittest.cc » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chromeos/network/onc/onc_validator.h" 5 #include "chromeos/network/onc/onc_validator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 + "Field name '" + field_name + "' is unknown."; 171 + "Field name '" + field_name + "' is unknown.";
172 if (error_on_unknown_field_) 172 if (error_on_unknown_field_)
173 LOG(ERROR) << message; 173 LOG(ERROR) << message;
174 else 174 else
175 LOG(WARNING) << message; 175 LOG(WARNING) << message;
176 } 176 }
177 177
178 return result.Pass(); 178 return result.Pass();
179 } 179 }
180 180
181 scoped_ptr<base::ListValue> Validator::MapArray(
182 const OncValueSignature& array_signature,
183 const base::ListValue& onc_array,
184 bool* nested_error) {
185 bool nested_error_in_current_array = false;
186 scoped_ptr<base::ListValue> result = Mapper::MapArray(
187 array_signature, onc_array, &nested_error_in_current_array);
188
189 // Drop individual networks and certificates instead of rejecting all of
190 // the configuration.
191 if (nested_error_in_current_array &&
192 &array_signature != &kNetworkConfigurationListSignature &&
193 &array_signature != &kCertificateListSignature) {
194 *nested_error = nested_error_in_current_array;
195 }
196 return result.Pass();
197 }
198
181 scoped_ptr<base::Value> Validator::MapEntry(int index, 199 scoped_ptr<base::Value> Validator::MapEntry(int index,
182 const OncValueSignature& signature, 200 const OncValueSignature& signature,
183 const base::Value& onc_value, 201 const base::Value& onc_value,
184 bool* error) { 202 bool* error) {
185 std::string str = base::IntToString(index); 203 std::string str = base::IntToString(index);
186 path_.push_back(str); 204 path_.push_back(str);
187 scoped_ptr<base::Value> result = 205 scoped_ptr<base::Value> result =
188 Mapper::MapEntry(index, signature, onc_value, error); 206 Mapper::MapEntry(index, signature, onc_value, error);
189 DCHECK_EQ(str, path_.back()); 207 DCHECK_EQ(str, path_.back());
190 path_.pop_back(); 208 path_.pop_back();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 &recommended_value)) { 241 &recommended_value)) {
224 return true; 242 return true;
225 } 243 }
226 base::ListValue* recommended_list; 244 base::ListValue* recommended_list;
227 recommended_value->GetAsList(&recommended_list); 245 recommended_value->GetAsList(&recommended_list);
228 CHECK(recommended_list != NULL); 246 CHECK(recommended_list != NULL);
229 247
230 recommended.reset(recommended_list); 248 recommended.reset(recommended_list);
231 249
232 if (!managed_onc_) { 250 if (!managed_onc_) {
251 error_or_warning_found_ = true;
233 LOG(WARNING) << WarningHeader() << "Found the field '" << onc::kRecommended 252 LOG(WARNING) << WarningHeader() << "Found the field '" << onc::kRecommended
234 << "' in an unmanaged ONC. Removing it."; 253 << "' in an unmanaged ONC. Removing it.";
235 return true; 254 return true;
236 } 255 }
237 256
238 scoped_ptr<base::ListValue> repaired_recommended(new base::ListValue); 257 scoped_ptr<base::ListValue> repaired_recommended(new base::ListValue);
239 for (base::ListValue::iterator it = recommended->begin(); 258 for (base::ListValue::iterator it = recommended->begin();
240 it != recommended->end(); ++it) { 259 it != recommended->end(); ++it) {
241 std::string field_name; 260 std::string field_name;
242 if (!(*it)->GetAsString(&field_name)) { 261 if (!(*it)->GetAsString(&field_name)) {
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } 725 }
707 726
708 std::string Validator::MessageHeader(bool is_error) { 727 std::string Validator::MessageHeader(bool is_error) {
709 std::string path = path_.empty() ? "toplevel" : JoinString(path_, "."); 728 std::string path = path_.empty() ? "toplevel" : JoinString(path_, ".");
710 std::string message = "At " + path + ": "; 729 std::string message = "At " + path + ": ";
711 return message; 730 return message;
712 } 731 }
713 732
714 } // namespace onc 733 } // namespace onc
715 } // namespace chromeos 734 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_validator.h ('k') | chromeos/network/onc/onc_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698