From 59c73058416130a2c98aa40be4bfabe39ce8b9d9 Mon Sep 17 00:00:00 2001 From: "narrieta@microsoft" Date: Wed, 23 Oct 2024 19:23:10 -0700 Subject: [PATCH] Comments --- azurelinuxagent/ga/policy/policy_engine.py | 50 ++++------------------ 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/azurelinuxagent/ga/policy/policy_engine.py b/azurelinuxagent/ga/policy/policy_engine.py index 778a47ae0..b0c7fb15e 100644 --- a/azurelinuxagent/ga/policy/policy_engine.py +++ b/azurelinuxagent/ga/policy/policy_engine.py @@ -115,20 +115,18 @@ def __read_policy(): @staticmethod def _parse_policy(policy): """ - Parses the given policy document and an equivalent document that has been populated with default values and verified for correctness, i.e. + Parses the given policy document and returns an equivalent document that has been populated with default values and verified for correctness, i.e. that conforms the following schema: { "policyVersion": "0.1.0", "extensionPolicies": { - "allowListedExtensionsOnly": , - "signatureRequired": , - "extensions": { + "allowListedExtensionsOnly": , [Optional; default: false] + "signatureRequired": , [Optional; default: false] + "extensions": { [Optional; default: {} (empty)] "": { - "signatureRequired": - "runtimePolicy": { - - } + "signatureRequired": [Optional; no default] + "runtimePolicy": [Optional; no default] } }, } @@ -165,20 +163,7 @@ def _parse_policy_version(policy): @staticmethod def _parse_extension_policies(policy): """ - Parses the "extensionPolicies" attribute of the policy document. It should conform to the following schema: - - "extensionPolicies": { - "allowListedExtensionsOnly": , - "signatureRequired": , - "extensions": { - "": { - "signatureRequired": - "runtimePolicy": { - - } - } - }, - } + Parses the "extensionPolicies" attribute of the policy document. See _parse_policy() for schema. """ extension_policies = _PolicyEngine._get_dictionary(policy, attribute="extensionPolicies", optional=True, default={}) @@ -195,17 +180,7 @@ def _parse_extension_policies(policy): @staticmethod def _parse_extensions(extensions): """ - Parses the "extensions" attribute. It should conform to the following schema: - - "extensions": { - "": { - "signatureRequired": bool - "runtimePolicy": { - - } - } - } - + Parses the "extensions" attribute. See _parse_policy() for schema. The return value is a case-folded dict. CRP allows extensions to be any case, so we allow for case-insensitive lookup of individual extension policies. """ parsed = _CaseFoldedDict.from_dict({}) @@ -220,14 +195,7 @@ def _parse_extensions(extensions): @staticmethod def _parse_extension(extension): """ - Parses an individual extension. It should conform to the following schema: - - "": { - "signatureRequired": bool - "runtimePolicy": { - - } - } + Parses an individual extension. See _parse_policy() for schema. """ extension_attribute_name = "extensionPolicies.extensions.{0}".format(extension)