Skip to content

Commit ef04ea6

Browse files
authored
Verify that sections are dictionaries, and not single values (#712)
1 parent 06a4c0b commit ef04ea6

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

core/src/main/python/wlsdeploy/tool/validate/validator.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_
336336
"""
337337
Validate a root-level section, such as topology, domainInfo
338338
:param model_section_key: the key for the section
339-
:param model_dict: the dictionary under the section
339+
:param model_dict: the top-level model dictionary
340340
:param valid_section_folders: folders that are valid for this section
341341
"""
342342
_method_name = '__validate_model_section'
@@ -365,14 +365,17 @@ def __validate_model_section(self, model_section_key, model_dict, valid_section_
365365
self._logger.finer('WLSDPLY-05013', str(attribute_location), str(path_tokens_attr_keys),
366366
class_name=_class_name, method_name=_method_name)
367367

368+
model_folder_path = model_section_key + ":/"
368369
model_section_dict = model_dict[model_section_key]
370+
if not isinstance(model_section_dict, dict):
371+
self._logger.severe('WLSDPLY-05038', model_folder_path, class_name=_class_name, method_name=_method_name)
372+
return
373+
369374
for section_dict_key, section_dict_value in model_section_dict.iteritems():
370375
# section_dict_key is either the name of a folder in the
371376
# section, or the name of an attribute in the section.
372377
validation_location = LocationContext()
373378

374-
model_folder_path = model_section_key + ":/"
375-
376379
if variables.has_variables(section_dict_key):
377380
self._report_unsupported_variable_usage(section_dict_key, model_folder_path)
378381

@@ -453,6 +456,10 @@ def __validate_section_folder(self, model_node, validation_location):
453456
self._logger.finest('1 model_folder_path={0}', model_folder_path,
454457
class_name=_class_name, method_name=_method_name)
455458

459+
if not isinstance(model_node, dict):
460+
self._logger.severe('WLSDPLY-05038', model_folder_path, class_name=_class_name, method_name=_method_name)
461+
return
462+
456463
if self._aliases.supports_multiple_mbean_instances(validation_location):
457464
self._logger.finer('2 model_node_type={0}',
458465
_ModelNodeTypes.from_value(_ModelNodeTypes.NAME_TYPE),
@@ -537,9 +544,14 @@ def __validate_section_folder(self, model_node, validation_location):
537544
def __process_model_node(self, model_node, validation_location):
538545
_method_name = '__process_model_node'
539546

547+
model_folder_path = self._aliases.get_model_folder_path(validation_location)
548+
549+
if not isinstance(model_node, dict):
550+
self._logger.severe('WLSDPLY-05038', model_folder_path, class_name=_class_name, method_name=_method_name)
551+
return
552+
540553
valid_folder_keys = self._aliases.get_model_subfolder_names(validation_location)
541554
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(validation_location)
542-
model_folder_path = self._aliases.get_model_folder_path(validation_location)
543555

544556
self._logger.finest('5 model_node={0}', str(model_node), class_name=_class_name, method_name=_method_name)
545557
self._logger.finest('5 aliases.get_model_subfolder_names(validation_location) returned: {0}',

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ WLSDPLY-01803=Adding roles: {0}
366366
WLSDPLY-01804=Failed to convert role {0} with expression {1} because {2}
367367
WLSDPLY-01805=Unexpected {0} during role mapper processing: {1}
368368

369-
# wlsdeploy/util/mbean_utils.py
369+
# wlsdeploy/tool/util/credential_map_helper.py
370370
WLSDPLY-01790=Creating default credential mapper initialization file {0}
371371
WLSDPLY-01791=Attribute "{0}" is required for {1} credential mapping {2}
372372

@@ -457,15 +457,16 @@ WLSDPLY-05034=The value for attribute {0} in model location {1} should be a stri
457457
WLSDPLY-05035=The {0} attribute with value {1} in model location {2}, should be a string but was a {3}
458458
WLSDPLY-05036=Attribute {0} in model location {1}, uses the {2} macro expression for an integer or references to other another server template configuration element. The Oracle documentation for server templates, cites this as being not supported.
459459
WLSDPLY-05037=Custom folder {0} will not be validated
460+
WLSDPLY-05038=Expected a section with subfolders and attributes in model location {0}
460461

461462
# wlsdeploy/tools/validate/validation_utils.py
462-
WLSDPLY-05300={0} variable is referenced in the value of the {1} variable, but is not defined in {2}
463+
WLSDPLY-05300={0} variable is referenced in the value of the {1} variable, but is not defined in {2}
463464

464465
# compare_model.py
465466

466467
WLSDPLY-05701=Model Path: {0} does not exist in new model but exists in previous model
467-
WLSDPLY-05702=Found unsupported online update shape changes {0} for Kubernetes Operator
468-
WLSDPLY-05703=Found unsupported online update network changes {0} for Kubernetes Operator
468+
WLSDPLY-05702=Found unsupported online update shape changes {0} for Kubernetes Operator
469+
WLSDPLY-05703=Found unsupported online update network changes {0} for Kubernetes Operator
469470
WLSDPLY-05704=Error in compare model {0}
470471
WLSDPLY-05705=Model {0} is invalid for comparison
471472
WLSDPLY-05706=Comparing Models: new={0} vs old={1}

0 commit comments

Comments
 (0)