-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Preserve file permissions when decompressing a zip file #464
Conversation
Fixes #389 Zip archive format includes a `external_attr` property on each file that stores file permissions. Most zip programs store permissions as in a format that unix's `chmod` command will accept. I cross-verified this approach with a couple of other libraries: * [Setuptools](https://github.com/pypa/setuptools/blob/89ef5bb7e4812193d6f593d531bad36191517981/setuptools/archive_util.py#L122-L124) * [Golang source](https://github.com/golang/go/blob/161874da2ab6d5372043a1f3938a81a19d1165ad/src/archive/zip/struct.go#L273) Unit tests create a zip archive with different permissions to verify that it does in fact unzip with permissons. This includes integration tests that invoke a function with zip of code for Java & Golang. We can run these automated tests on various platforms (Mac, Linux, Windows) to ensure unzipping works consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small comments with the main one being we should move away from os.path onto the Pathlib (Path), which is a more OO way of handling Paths and is standard in 3.6.
from subprocess import Popen, PIPE | ||
from nose_parameterized import parameterized, param | ||
|
||
from ..invoke_integ_base import InvokeIntegBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should only be using .
not ..
. Can you change this to full path?
cls.test_data_path = os.path.join(integration_dir, "testdata") | ||
cls.template_path = os.path.join(cls.test_data_path, "invoke", "template.yml") | ||
cls.event_path = os.path.join(cls.test_data_path, "invoke", "event.json") | ||
cls.env_var_path = os.path.join(cls.test_data_path, "invoke", "vars.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Path instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to skip this one for now. Path definitely simplifies this expression but let's get to it in a separate pass of converting os.path to Path
Fixes #389
Zip archive format includes a
external_attr
property on each filethat stores file permissions. Most zip programs store permissions as
in a format that unix's
chmod
command will accept. I cross-verifiedthis approach with a couple of other libraries:
Unit tests create a zip archive with different permissions to verify that it
does in fact unzip with permissons. This includes integration tests that
invoke a function with zip of code for Java & Golang. We can run these
automated tests on various platforms (Mac, Linux, Windows) to ensure unzipping
works consistently.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.