Skip to content
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

Merged
merged 3 commits into from
Jun 14, 2018
Merged

fix: Preserve file permissions when decompressing a zip file #464

merged 3 commits into from
Jun 14, 2018

Conversation

sanathkr
Copy link
Contributor

@sanathkr sanathkr commented Jun 6, 2018

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:

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.

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.
Copy link
Contributor

@jfuss jfuss left a 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
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Path instead

Copy link
Contributor Author

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

@jfuss jfuss merged commit 1d887c1 into aws:develop Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants