Fix rename_file to handle relative paths properly (related to GHSA-v7vq-3x77-87vg?)#6609
Conversation
|
Hi @yacchin1205, thank you for submitting this PR! One point of interest that has come up while speaking with @echarles, would it be possible to update the tests to be more in line with the testing done for this functionality in jupyter-server? After this PR is merged it would be great to have these changes added to the 6.5.x branch as well! |
|
Thank you for your reply, @RRosio . OK, I will update the tests! |
|
@RRosio I referred to jupyter-server and found the same problem in the test of jupyter-server, so I fixed the test and found the (new) problem 😓 . |
|
Hi @RRosio , The fixes to the test on jupyter-server have also been merged, and I have modified this test accordingly. Please review it. |
|
Hi @yacchin1205 thank you for implementing these updates. I have brought up this PR in the notebook community meeting and there was interest in a little more testing on our end to ensure that these updates have no other side-effects. |
|
Hi @yacchin1205, thank you again for your work with this update. One question we have is in regards to the order of the |
|
Hi @RRosio , The reason why If you would like to add the same fix to |
|
Thank you for your response @yacchin1205!
Yes, if you could please add that fix here, that would be great! |
|
Hi @RRosio , I have committed a fix regarding |
|
I have tested the latest commit and confirms the hidden files are not shown on my env and can not be addressed directly. |
|
Thank you for the updates @yacchin1205! This looks great! Feel free to let us know whether you would like to submit these same updates to |
…dden files properly) (#6660) * Fix the path form for rename_file * Fix tests for rename_file to give values in relative paths * Fix tests to be in line with jupyter-server * Fix for determining whether a file is hidden and tests for delete_file Co-authored-by: yacchin1205 <968739+yacchin1205@users.noreply.github.com>

Fix #6473 and I assume that this completely resolves GHSA-v7vq-3x77-87vg.
As @jinzhen-lin mentions in #6473, if a path of the same length as notebook_dir is given in
rename_file, it is interpreted as an attempt to rename a file named.ipynb, which is misjudged as a hidden file because the first character is..This problem could be caused by old_path and new_path of
rename_fileare relative paths, butis_hiddenis assumed to be an absolute path. Therefore, I modified the code ofrename_fileso that absolute paths are provided tois_hidden.Additionally, the test was also fixed. The test passed until now, but it did not test if
rename_fileraises the expected error. Because theFileContentsManager.newbefore it raisedHTTPErrorand marks it as success. (is_hiddenis also called innew.)[Related to the security advisory?]
The original commit seems to be jupyter-server/jupyter_server@877da10 on jupyter_server. (This commit seems to handle absolute paths properly.) This appears to be related to Security Advisory GHSA-v7vq-3x77-87vg So I consider this PR may be an important fix.