Commit 11a5186a authored by Yves Arrouye's avatar Yves Arrouye Committed by Commit Bot

Use "allowlist" instead of a less inclusive term

Bug: None
Test: None
Change-Id: I9bed2a106220ab51aa6aa2e7324833e8dd9b5826
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341389Reviewed-by: default avatarAlexander Hendrich <hendrich@chromium.org>
Commit-Queue: Alexander Hendrich <hendrich@chromium.org>
Commit-Queue: Yves Arrouye <drcrash@chromium.org>
Auto-Submit: Yves Arrouye <drcrash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795626}
parent 35460b0e
...@@ -35,7 +35,7 @@ TYPE_TO_SCHEMA = { ...@@ -35,7 +35,7 @@ TYPE_TO_SCHEMA = {
# List of boolean policies that have been introduced with negative polarity in # List of boolean policies that have been introduced with negative polarity in
# the past and should not trigger the negative polarity check. # the past and should not trigger the negative polarity check.
LEGACY_INVERTED_POLARITY_WHITELIST = [ LEGACY_INVERTED_POLARITY_ALLOWLIST = [
'DeveloperToolsDisabled', 'DeveloperToolsDisabled',
'DeviceAutoUpdateDisabled', 'DeviceAutoUpdateDisabled',
'Disable3DAPIs', 'Disable3DAPIs',
...@@ -55,7 +55,7 @@ LEGACY_INVERTED_POLARITY_WHITELIST = [ ...@@ -55,7 +55,7 @@ LEGACY_INVERTED_POLARITY_WHITELIST = [
# List of policies where the 'string' part of the schema is actually a JSON # List of policies where the 'string' part of the schema is actually a JSON
# string which has its own schema. # string which has its own schema.
LEGACY_EMBEDDED_JSON_WHITELIST = [ LEGACY_EMBEDDED_JSON_ALLOWLIST = [
'ArcPolicy', 'ArcPolicy',
'AutoSelectCertificateForUrls', 'AutoSelectCertificateForUrls',
'DefaultPrinterSelection', 'DefaultPrinterSelection',
...@@ -72,7 +72,7 @@ LEGACY_EMBEDDED_JSON_WHITELIST = [ ...@@ -72,7 +72,7 @@ LEGACY_EMBEDDED_JSON_WHITELIST = [
# List of policies where not all properties are required to be presented in the # List of policies where not all properties are required to be presented in the
# example value. This could be useful e.g. in case of mutually exclusive fields. # example value. This could be useful e.g. in case of mutually exclusive fields.
# See crbug.com/1068257 for the details. # See crbug.com/1068257 for the details.
OPTIONAL_PROPERTIES_POLICIES_WHITELIST = [] OPTIONAL_PROPERTIES_POLICIES_ALLOWLIST = []
# 100 MiB upper limit on the total device policy external data max size limits # 100 MiB upper limit on the total device policy external data max size limits
# due to the security reasons. # due to the security reasons.
...@@ -349,24 +349,24 @@ class PolicyTemplateChecker(object): ...@@ -349,24 +349,24 @@ class PolicyTemplateChecker(object):
# Checks that boolean policies are not negated (which makes them harder to # Checks that boolean policies are not negated (which makes them harder to
# reason about). # reason about).
if (policy_type == 'main' and 'disable' in policy.get('name').lower() and if (policy_type == 'main' and 'disable' in policy.get('name').lower()
policy.get('name') not in LEGACY_INVERTED_POLARITY_WHITELIST): and policy.get('name') not in LEGACY_INVERTED_POLARITY_ALLOWLIST):
self._Error(('Boolean policy %s uses negative polarity, please make ' + self._Error(('Boolean policy %s uses negative polarity, please make ' +
'new boolean policies follow the XYZEnabled pattern. ' + 'new boolean policies follow the XYZEnabled pattern. ' +
'See also http://crbug.com/85687') % policy.get('name')) 'See also http://crbug.com/85687') % policy.get('name'))
# Checks that the policy doesn't have a validation_schema - the whole # Checks that the policy doesn't have a validation_schema - the whole
# schema should be defined in 'schema'- unless whitelisted as legacy. # schema should be defined in 'schema'- unless listed as legacy.
if ('validation_schema' in policy and if ('validation_schema' in policy
policy.get('name') not in LEGACY_EMBEDDED_JSON_WHITELIST): and policy.get('name') not in LEGACY_EMBEDDED_JSON_ALLOWLIST):
self._Error(('"validation_schema" is defined for new policy %s - ' + self._Error(('"validation_schema" is defined for new policy %s - ' +
'entire schema data should be contained in "schema"') % 'entire schema data should be contained in "schema"') %
policy.get('name')) policy.get('name'))
# Try to make sure that any policy with a complex schema is storing it as # Try to make sure that any policy with a complex schema is storing it as
# a 'dict', not embedding it inside JSON strings - unless whitelisted. # a 'dict', not embedding it inside JSON strings - unless listed as legacy.
if (self._AppearsToContainEmbeddedJson(policy.get('example_value')) and if (self._AppearsToContainEmbeddedJson(policy.get('example_value'))
policy.get('name') not in LEGACY_EMBEDDED_JSON_WHITELIST): and policy.get('name') not in LEGACY_EMBEDDED_JSON_ALLOWLIST):
self._Error(('Example value for new policy %s looks like JSON. Do ' + self._Error(('Example value for new policy %s looks like JSON. Do ' +
'not store complex data as stringified JSON - instead, ' + 'not store complex data as stringified JSON - instead, ' +
'store it in a dict and define it in "schema".') % 'store it in a dict and define it in "schema".') %
...@@ -785,7 +785,7 @@ class PolicyTemplateChecker(object): ...@@ -785,7 +785,7 @@ class PolicyTemplateChecker(object):
schema = policy.get('schema') schema = policy.get('schema')
example = policy.get('example_value') example = policy.get('example_value')
enforce_use_entire_schema = policy.get( enforce_use_entire_schema = policy.get(
'name') not in OPTIONAL_PROPERTIES_POLICIES_WHITELIST 'name') not in OPTIONAL_PROPERTIES_POLICIES_ALLOWLIST
if not self.has_schema_error: if not self.has_schema_error:
if not self.schema_validator.ValidateValue(schema, example, if not self.schema_validator.ValidateValue(schema, example,
enforce_use_entire_schema): enforce_use_entire_schema):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment