-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 zip-slip noise in tests #3586
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3586 +/- ##
==========================================
- Coverage 72.96% 72.94% -0.02%
==========================================
Files 280 280
Lines 20949 20952 +3
==========================================
- Hits 15285 15283 -2
- Misses 4693 4697 +4
- Partials 971 972 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
LGTM in general.
I don't think we have ever been fulnerable to this as this more or less only goes in memory, but I guess some shenanigans were still possible with ../https/hostname.com/path
.. but I still have no idea why that will be useful 🤷
I personally do not want to touch code that plays with filepath
as unfortunately it is quite ... funky with us having paths from windows but running on linux and vice-versa.
This seems to not break any tests, and given that filepath.Join
already does Clean
(which is by far the thing that IIRC breaks most stuff) - hopefully nothing new will break 🤞
return errors.New("tar file contains non-local file names") | ||
} | ||
|
||
target := filepath.Join(destination, filepath.Clean(fileName)) |
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.
nit: Pretty sure there is no need to call Clean before Join
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.
Having no filepath.Clean
here will trigger golang-ci lint (see the omitting lines).
First, I share with you the opinion that the code is not vulnerable for the reasons you mention (like in memory).
Still, the primary purpose of doing this for me is to fix the Now, we have two options to reach this state: omit it inline or try fixing it. In choosing between these two options, I feel that it's worth trying to go with the fixing first instead of just omitting inline. |
What?
This attempts to fix the "noise" from the security tab (CodeQL reported).
Why?
Fixing such cases helps us focus on the right things.
Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)