-
Notifications
You must be signed in to change notification settings - Fork 323
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
Deny git access to nested server root #1278
Deny git access to nested server root #1278
Conversation
Thanks for submitting your first pull request! You are awesome! 🤗 |
@Zxun2 the main branch has been updated to JupyterLab 4 - to ease the work here, I changed the target to the branch |
I have made the code ever slightly more compact by shifting all the relevant logic to server side. Let me know if there are any more changes to be made! |
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.
Hey @fcollonval! Thanks for the review. I tried looking into the test case that you linked to, but i am a little confused how the function works. Both For example,
Changing "test_path" to any other string causes the testcase to fail, but i am unsure why. Are these strings predetermined (from the codebase, i only see "test_path" and "ignored_path")? |
Thanks @Zxun2 The difference between the two tests is the mocked result from the git command:
So in your case you will need to return a valid answer as the error must be raised from the relative path computation. |
…om/Zxun2/jupyterlab-git into zxun2/deny-git-subdirectory-access
Hey @fcollonval, thanks for the quick response! I merged the main repository, hence the huge LoC changes |
Kicking the CI following targeted branch change |
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.
Almost through, here are some suggestions to fix the CI
Co-authored-by: Frédéric Collonval <[email protected]>
Co-authored-by: Frédéric Collonval <[email protected]>
@fcollonval I am done with this PR! |
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.
Thanks @Zxun2
@all-contributors please add @Zxun2 for code |
I've put up a pull request to add @Zxun2! 🎉 |
Fixes #1205
Changes
IShowPrefixResult
now returns an additional attributerelative_path
which determines the current path relative to the server root directory.relative_path
, i compared the server root to the git root. The main logic is that ifrelative_path == "."
then you simply check ifpath === ""
. This would be an indication that server root is equal to the git root since path is relative to git root. Otherwise, determine ifnormalize(relative_path) === normalize(path)
. If git root is indeed equal to server root, then relative path must be equal to the path itself.