Delay creating symlinks until after all regular files #23
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.
When decompressing a tarball there isn't any guarantee of the order
which tar headers are presented to us by (*tar.Reader).Next(), this
means that it's possible for us to evaluate and try to create a symlink
before the file which it points to has been created.
This is usually fine, a symlink isn't required to point to anything.
However, for security reasons (mitigating against "Zip-slip") we wan't
to evaluate that a symlink resolves to a file that is within the
expected directory (i.e. it should not escape outside of the directory
which we are decompressing into).
For this reason, we need to collect all symlinks and process them after
we've gone through all regular files.
There might still be a chance of problems being caused by symlinks that
point to other symlinks -- I'll cross that bridge if I get to it.