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

Unified Diff: components/policy/core/common/schema_map.cc

Issue 134153005: Add strictness to Schema::Validate() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@expand-policy-schema-2
Patch Set: minor fixes Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/schema_map.cc
diff --git a/components/policy/core/common/schema_map.cc b/components/policy/core/common/schema_map.cc
index 488af8d0f5168ee62cf973a4c00c11a6f89b9fd8..4d64fdeba632bc928308ccac218d301475d347a4 100644
--- a/components/policy/core/common/schema_map.cc
+++ b/components/policy/core/common/schema_map.cc
@@ -4,6 +4,7 @@
#include "components/policy/core/common/schema_map.h"
+#include "base/logging.h"
#include "base/values.h"
#include "components/policy/core/common/policy_bundle.h"
#include "components/policy/core/common/policy_map.h"
@@ -63,8 +64,14 @@ void SchemaMap::FilterBundle(PolicyBundle* bundle) const {
const base::Value* policy_value = it_map->second.value;
Schema policy_schema = schema->GetProperty(policy_name);
++it_map;
- if (!policy_value || !policy_schema.Validate(*policy_value))
+ std::string error;
+ if (!policy_value ||
+ !policy_schema.Validate(*policy_value, SCHEMA_STRICT, &error)) {
+ LOG(ERROR) << "Dropping policy " << policy_name << " for "
+ << it->first.component_id
+ << " because it's not valid: " << error;
map->Erase(policy_name);
+ }
}
}
}
« no previous file with comments | « components/policy/core/common/schema.cc ('k') | components/policy/core/common/schema_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698