Fix: zip2tar does not preserve Unix file permissions from ZIP archives#9953
Closed
Andrew-most-likely wants to merge 3 commits intogetmoto:masterfrom
Closed
Fix: zip2tar does not preserve Unix file permissions from ZIP archives#9953Andrew-most-likely wants to merge 3 commits intogetmoto:masterfrom
Andrew-most-likely wants to merge 3 commits intogetmoto:masterfrom
Conversation
Queue.add_message() was iterating over all lambda_event_source_mappings and invoking Lambda without checking whether the mapping was enabled. Add a check to skip disabled mappings. Add a test to verify that a disabled ESM does not trigger Lambda when a message is sent to the queue. Fixes #9948
The zip2tar function in moto/awslambda/models.py ignored the external_attr field of ZipInfo entries, which stores Unix file permissions in its upper 16 bits. As a result, Lambda handler executables (e.g. Go/Rust bootstrap binaries) lost their execute bit after conversion, causing 'permission denied' at runtime. Read the mode from external_attr when present and apply it to the TarInfo entry. Fixes #9947
Contributor
Author
|
I hope I didnt step on any toes with this pr it seemed there was some discussion on it and sorted it today so Im just gonna leave this here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9947
The
zip2tarfunction inmoto/awslambda/models.pynever readzipinfo.external_attr, which stores Unix file permissions in its upper 16 bits. Lambda handler executables (e.g. Go/Rustbootstrapbinaries) therefore lost their execute bit after ZIP-to-TAR conversion, causing apermission deniederror at runtime.Fix: extract the mode from
external_attr >> 16when present and assign it totarinfo.mode.Test:
test_zip2tar_preserves_unix_file_permissionsbuilds a ZIP with a file set to mode0o755, converts it withzip2tar, and asserts the TAR member has the same mode.