Use safer tar extraction. Handle error messages in the build process more intelligently.

This commit is contained in:
jakedt 2014-04-01 13:46:41 -04:00
parent 4f1ae25128
commit 7c44932c87
2 changed files with 62 additions and 3 deletions

View file

@ -17,6 +17,7 @@ from data.queue import dockerfile_build_queue
from data import model
from workers.worker import Worker
from app import app
from util.safetar import safe_extractall
root_logger = logging.getLogger('')
@ -152,8 +153,14 @@ class DockerfileBuildContext(object):
for status in build_status:
fully_unwrapped = ""
if isinstance(status, dict):
if len(status) > 0:
fully_unwrapped = status.values()[0]
keys_to_extract = ['error', 'status', 'stream']
for key in keys_to_extract:
if key in status:
fully_unwrapped = status[key]
break
if not fully_unwrapped:
logger.debug('Status dict did not have any extractable keys and was: %s', status)
elif isinstance(status, basestring):
fully_unwrapped = status
@ -322,7 +329,7 @@ class DockerfileBuildWorker(Worker):
# Save the zip file to temp somewhere
with tarfile.open(mode='r|*', fileobj=request_file.raw) as tar_stream:
tar_stream.extractall(build_dir)
safe_extractall(tar_stream, build_dir)
return build_dir