Beispiel #1
0
    def validate(self):
        """Normalizes and validates the data in the secimage xml.
        
        :raises: RuntimeError if config is determined to be invalid
        """
        c_config.CoreConfig.validate(self, defines.CONFIG_STRUCTURE)

        # Validate root config rules
        from rule import ConfigRulesManager
        rules = ConfigRulesManager()
        rules.validate(self, defines.CONFIG_STRUCTURE)

        # Check that the version matches
        config_version = self.version
        if config_version != self.__version__:
            raise RuntimeError('Version of parser: "' + self.__version__ +
                               '" does not match version from config "' +
                               config_version + '"')

        # Check that atleast one image_type was provided
        image_type_id_list = [
            image_type.id
            for image_type in self._get_parsegen_image_type_list()
        ]
        if len(image_type_id_list) == 0:
            raise RuntimeError(
                'Config file must contain at least one image_type under parsegen->image_types_list'
            )

        # Check that the ids of the image_type objects are unique
        dup_image_type_id_list = get_dups_in_list(image_type_id_list)
        if len(dup_image_type_id_list):
            raise RuntimeError(
                'image_type ids must be unique. Found multiple image_types with same id: '
                + str(dup_image_type_id_list))

        # Check that the ids of the cert_configs_list are unique
        cert_config_id_list = [
            cert_config.id
            for cert_config in self._get_signing_local_cert_config_list()
        ]
        dup_cert_config_id_list = get_dups_in_list(cert_config_id_list)
        if len(dup_cert_config_id_list):
            raise RuntimeError(
                'cert_config ids must be unique. Found multiple cert_configs with same id: '
                + str(dup_cert_config_id_list))

        # Check that atleast one image was provided
        sign_id_list = self.sign_id_list
        if len(sign_id_list) == 0:
            raise RuntimeError(
                'Config file must contain at least one image under the images_list'
            )

        # Check that the ids of the image objects are unique
        dup_sign_id_list = get_dups_in_list(sign_id_list)
        if len(dup_sign_id_list):
            raise RuntimeError(
                'image sign_ids must be unique. Found multiple images with the same sign_id: '
                + str(dup_sign_id_list))
Beispiel #2
0
    def validate(self):
        """Normalizes and validates the data in the secimage xml.

        :raises: RuntimeError if config is determined to be invalid
        """
        c_config.CoreConfig.validate(self,
                                     self.cfgparser.defines.CONFIG_STRUCTURE)

        # Validate root config rules
        self.cfgparser.rules.validate(self,
                                      self.cfgparser.defines.CONFIG_STRUCTURE)

        # Check that the version matches
        config_version = self.version
        if config_version != self.cfgparser.version:
            raise RuntimeError('Version of parser: "' +
                               self.cfgparser.version +
                               '" does not match version from config "' +
                               config_version + '"')

        # Check that atleast one image was provided
        sign_id_list = self.sign_id_list
        if len(sign_id_list) == 0:
            raise RuntimeError(
                'Config file must contain at least one image under the images_list'
            )

        # Check that the ids of the image objects are unique
        dup_sign_id_list = get_dups_in_list(sign_id_list)
        if len(dup_sign_id_list):
            raise RuntimeError(
                'image sign_ids must be unique. Found multiple images with the same sign_id: '
                + str(dup_sign_id_list))
    def validate(self):
        """Normalizes and validates the data in the secimage xml.

        :raises: RuntimeError if config is determined to be invalid
        """
        c_config.CoreConfig.validate(self, defines.CONFIG_STRUCTURE)

        # Validate root config rules
        from rule import ConfigRulesManager
        rules = ConfigRulesManager()
        rules.validate(self, defines.CONFIG_STRUCTURE)

        # Check that the version matches
        config_version = self.version
        if config_version != self.__version__:
            raise RuntimeError('Version of parser: "' + self.__version__ + '" does not match version from config "' + config_version + '"')

        # Check that atleast one image_type was provided
        image_type_id_list = [image_type.id for image_type in self._get_parsegen_image_type_list()]
        if len(image_type_id_list) == 0:
            raise RuntimeError('Config file must contain at least one image_type under parsegen->image_types_list')

        # Check that the ids of the image_type objects are unique
        dup_image_type_id_list = get_dups_in_list(image_type_id_list)
        if len(dup_image_type_id_list):
            raise RuntimeError('image_type ids must be unique. Found multiple image_types with same id: ' + str(dup_image_type_id_list))

        # Check that the ids of the cert_configs_list are unique
        cert_config_id_list = [cert_config.id for cert_config in self._get_signing_local_cert_config_list()]
        dup_cert_config_id_list = get_dups_in_list(cert_config_id_list)
        if len(dup_cert_config_id_list):
            raise RuntimeError('cert_config ids must be unique. Found multiple cert_configs with same id: ' + str(dup_cert_config_id_list))

        # Check that atleast one image was provided
        sign_id_list = self.sign_id_list
        if len(sign_id_list) == 0:
            raise RuntimeError('Config file must contain at least one image under the images_list')

        # Check that the ids of the image objects are unique
        dup_sign_id_list = get_dups_in_list(sign_id_list)
        if len(dup_sign_id_list):
            raise RuntimeError('image sign_ids must be unique. Found multiple images with the same sign_id: ' + str(dup_sign_id_list))
    def validate(self):
        """Normalizes and validates the data in the secimage xml.

        :raises: RuntimeError if config is determined to be invalid
        """
        c_config.CoreConfig.validate(self, defines.CONFIG_STRUCTURE)

        # Check that the id list contains at least 1 image_type
        image_type_id_list = [image_type.id for image_type in self._get_parsegen_image_type_list()]
        if len(image_type_id_list) == 0:
            raise RuntimeError('Config file must contain at least one image_type under parsegen->image_types_list')

        # Check that the ids of the image_type objects are unique
        dup_image_type_id_list = get_dups_in_list(image_type_id_list)
        if len(dup_image_type_id_list):
            raise RuntimeError('image_type ids must be unique. Found multiple image_types with same id: ' + str(dup_image_type_id_list))