-
Notifications
You must be signed in to change notification settings - Fork 4.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
Add some path checks around user provided paths #1575
Conversation
# for listing of files in the destination) in a sync command. | ||
# More specifically this if statement will only be hit if it | ||
# is the file generator listing files for a downloading sync. | ||
if self.operation_name == '': |
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 feel that this was sort of hacky when I wrote it as I am relying on the fact in the code when I instantiate the FileGenerator for the reference files in the destination, the operation_name
is set to ''
. I want some feedback on this part.
The other option I was thinking of was to introduce a new argument to the constructor that specifies the transfer direction. The reason I did not do it was because it would bloat the constructor and may require a bunch of updates to the tests. Note I am not too concerned about coupling to the command being run here because the FileGenerator already requires an operation name.
Doesn't it seem simpler to just, much higher up the stack before doing an upload, validate that the local source exists? We should be able to do it before even getting into any of the command architecture code paths. |
I think it was because I was concerned with follow_symlinks check right above it. But now that I think about it, I do not think that should be a concern because the if statment is only hit if the The other issue that I was concerned is with regards to #1082. If I add the logic higher up in the stack. The only way to fix this issue is to completely short circuit the reverse filegenerator, which I am not sure how easy it is for syncing. Maybe make a no op filegenerator but that seems messy to me. I am fine with the first part, but with the second part, I do not have a great idea on how to get around it. Do you have any ideas on how to do that? I could hoist the logic to the |
@kyleknap I'm not following how these is a problem. Is your first concern we'd have to duplicate the symlink checking logic somewhere in Also I'm not quite sure I understand the second point, maybe because I don't know the root cause. Why do we need to possibly short circuit the reverse filegenerator? |
No the first paragraph is no longer an issue. I was just explaining (a little bit too my self as well) a possible issue, but it ended up not being an issue. The second one is an issue because in order to avoid modifying the |
I'm definitely missing something. Can we not just create the directory before doing any transfers? Let me give something more specific. Why doesn't something like this work for your second case?
|
Yeah that would be simpler. The only thing is that it is kind of weird that we are making modifications to the file system there as opposed to in s3handler and fileinfo. |
0549048
to
e81ac19
Compare
Alright I updated the PR. Integration tests still pass. |
CommandParameters already has has pre-existing validation of parameters. Was there a reason not to add this logic to that class? |
5e28883
to
a889585
Compare
No, I just had forgotten about that class. Had not looked at it for a long time, and it shown. There were methods in the class that we not even used and some tests were using internal methods... I update the PR. Integration tests still pass. |
This mainly applies to the existance of user provided local paths. If the transfer is an upload and that local path does not exist, this will cause the command to fail instead of skipping. If the transfer is a syncing download and the local path does not existant, there should not be warnings.
Hoisted the user provided local paths to the CommandArchitecture class
a889585
to
1401714
Compare
Add some path checks around user provided paths
* test: Verify samconfig is accessible to all CLI commands * fix cases where comma vs space needs to be delimiter * adding few more unit tests * adding unit tests for all commands * fix linter * Adding tests for overriding args thru config, CLI args, and envvars * Fixing a minor UX issue when sam template is invalid * fixing mock imports
This mainly applies to the existence of user provided local paths. If the transfer is an upload and that local path does not exist, this will cause the command to fail instead of skipping. I realize this will cause a change in status code, but I think a hard fail is the correct behavior. Skipping on a specific path that the user specified should not be happening.
Also, If the transfer is a syncing download and the local path does not existent, there should not be warnings.
All integration test pass as well.
Fixes #1082, #1564
cc @jamesls @mtdowling @rayluo @JordonPhillips