Skip to content

Commit

Permalink
Use extract_tar to extract images and layers #407
Browse files Browse the repository at this point in the history
    * extract_tar uses the built in tar command, which does not do filename sanitization

Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Jun 15, 2022
1 parent 08d7b16 commit b04621b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions scanpipe/pipes/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
from pathlib import Path

from container_inspector.image import Image
from container_inspector.utils import extract_tar

from scanpipe import pipes
from scanpipe.pipes import rootfs
from scanpipe.pipes.scancode import extract_archive

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -62,7 +62,10 @@ def extract_image_from_tarball(input_tarball, extract_target, verify=True):
Returns the `images` and an `errors` list of error messages that may have
happen during the extraction.
"""
errors = list(extract_archive(location=input_tarball, target=extract_target))
errors = extract_tar(
location=input_tarball,
target_dir=extract_target
)
images = Image.get_images_from_dir(
extracted_location=str(extract_target),
verify=verify,
Expand Down Expand Up @@ -101,9 +104,9 @@ def extract_layers_from_images_to_base_path(base_path, images):

for layer in image.layers:
extract_target = target_path / layer.layer_id
extract_errors = extract_archive(
extract_errors = extract_tar(
location=layer.archive_location,
target=extract_target,
target_dir=extract_target,
)
errors.extend(extract_errors)
layer.extracted_location = str(extract_target)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ install_requires =
# WSGI server
gunicorn==20.1.0
# Docker
container_inspector==31.0.0
container_inspector==31.1.0
# ScanCode-toolkit
scancode-toolkit[packages]==31.0.0rc1
extractcode[full]==31.0.0
Expand Down

0 comments on commit b04621b

Please sign in to comment.