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

Unified Diff: chrome/browser/chromeos/cros/onc_network_parser.cc

Issue 10944009: Implementation of ONC signature, validator and normalizer. (Closed) Base URL: http://git.chromium.org/chromium/src.git@gperffix
Patch Set: Addressed remaining nits. Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/cros/onc_network_parser.cc
diff --git a/chrome/browser/chromeos/cros/onc_network_parser.cc b/chrome/browser/chromeos/cros/onc_network_parser.cc
index 213b71623b52058fc5ff077db952e8ee0ea3e329..9bb533ee306a32b13519e637bc6a8681a578192d 100644
--- a/chrome/browser/chromeos/cros/onc_network_parser.cc
+++ b/chrome/browser/chromeos/cros/onc_network_parser.cc
@@ -19,6 +19,8 @@
#include "chrome/browser/chromeos/cros/native_network_parser.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/cros/onc_constants.h"
+#include "chrome/browser/chromeos/network_settings/onc_signature.h"
+#include "chrome/browser/chromeos/network_settings/onc_validator.h"
#include "chrome/browser/chromeos/proxy_config_service_impl.h"
#include "chrome/browser/prefs/proxy_config_dictionary.h"
#include "chrome/common/net/x509_certificate_model.h"
@@ -304,6 +306,26 @@ OncNetworkParser::OncNetworkParser(const std::string& onc_blob,
if (!root_dict_.get())
return;
+ // Validate the ONC dictionary. We are liberal and ignore unknown field
+ // names and ignore invalid field names in kRecommended arrays.
+ bool is_managed = onc_source == NetworkUIData::ONC_SOURCE_USER_POLICY ||
+ onc_source == NetworkUIData::ONC_SOURCE_DEVICE_POLICY;
+ scoped_ptr<onc::Validator> validator(
+ new onc::Validator(false, // Ignore unknown fields.
+ false, // Ignore invalid recommended field names.
+ true, // Fail on missing fields.
+ is_managed));
+
+ // Unknown fields are removed from the result.
+ root_dict_ = validator->ValidateAndRepairObject(
+ &onc::kUnencryptedConfigurationSignature,
+ *root_dict_);
+
+ if (!root_dict_.get()) {
+ LOG(WARNING) << "Provided ONC is invalid and couldn't be repaired";
+ return;
+ }
+
// At least one of NetworkConfigurations or Certificates is required.
bool has_network_configurations =
root_dict_->GetList("NetworkConfigurations", &network_configs_);
« no previous file with comments | « chrome/browser/chromeos/cros/onc_constants.cc ('k') | chrome/browser/chromeos/network_settings/onc_mapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698