diff options
author | Zuul <zuul@review.opendev.org> | 2023-02-22 18:58:08 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2023-02-22 18:58:08 +0000 |
commit | 6f03ccd47772e02f810de8fa3158afddc4a9c158 (patch) | |
tree | 81fdf52dd86c63f42bd65e86671f46d3b3652b36 /glance/async_/flows/plugins/image_conversion.py | |
parent | 7ffbbebd8815893b47958908be79cddc1a677ba0 (diff) | |
parent | b60fb70c9faf3b73eb4d8a73cd5cb09f2fa70a61 (diff) | |
download | glance-stable/ussuri.tar.gz |
Merge "Enforce image safety during image_conversion" into stable/ussuristable/ussuri
Diffstat (limited to 'glance/async_/flows/plugins/image_conversion.py')
-rw-r--r-- | glance/async_/flows/plugins/image_conversion.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/glance/async_/flows/plugins/image_conversion.py b/glance/async_/flows/plugins/image_conversion.py index 3bfbc4a42..9c96983ed 100644 --- a/glance/async_/flows/plugins/image_conversion.py +++ b/glance/async_/flows/plugins/image_conversion.py @@ -105,6 +105,29 @@ class _ConvertImage(task.Task): image = self.image_repo.get(self.image_id) image.virtual_size = virtual_size + if 'backing-filename' in metadata: + LOG.warning('Refusing to process QCOW image with a backing file') + raise RuntimeError( + 'QCOW images with backing files are not allowed') + + if metadata.get('format') == 'vmdk': + create_type = metadata.get( + 'format-specific', {}).get( + 'data', {}).get('create-type') + allowed = CONF.image_format.vmdk_allowed_types + if not create_type: + raise RuntimeError(_('Unable to determine VMDK create-type')) + if not len(allowed): + LOG.warning(_('Refusing to process VMDK file as ' + 'vmdk_allowed_types is empty')) + raise RuntimeError(_('Image is a VMDK, but no VMDK createType ' + 'is specified')) + if create_type not in allowed: + LOG.warning(_('Refusing to process VMDK file with create-type ' + 'of %r which is not in allowed set of: %s'), + create_type, ','.join(allowed)) + raise RuntimeError(_('Invalid VMDK create-type specified')) + if source_format == target_format: LOG.debug("Source is already in target format, " "not doing conversion for %s", self.image_id) |