Ensure we encode the config in manifest schema 2 via the canonical JSON format

This commit is contained in:
Joseph Schorr 2018-12-18 14:52:19 -05:00
parent 48e584905a
commit feee49be9e
4 changed files with 48 additions and 5 deletions

View file

@ -23,7 +23,7 @@ from image.docker import ManifestException
from image.docker.types import ManifestImageLayer
from image.docker.interfaces import ManifestInterface
from image.docker.v1 import DockerV1Metadata
from image.docker.schemautil import ensure_utf8
from image.docker.schemautil import ensure_utf8, to_canonical_json
logger = logging.getLogger(__name__)
@ -375,7 +375,7 @@ class DockerSchema1Manifest(ManifestInterface):
v1_metadata = json.loads(metadata_string)
command_list = v1_metadata.get('container_config', {}).get('Cmd', None)
command = json.dumps(command_list) if command_list else None
command = to_canonical_json(command_list) if command_list else None
if not 'id' in v1_metadata:
raise MalformedSchema1Manifest('id field missing from v1Compatibility JSON')
@ -597,4 +597,4 @@ def _updated_v1_metadata(v1_metadata_json, updated_id_map):
if existing_image in updated_id_map:
parsed['container_config']['image'] = updated_id_map[existing_image]
return json.dumps(parsed)
return to_canonical_json(parsed)