Repository navigation
Conversation
Both history views gate on check_folder_permission(repo_id, '/'), so a share-only account -- no library permission, qualified on the shared directory -- is refused the history of exactly the files it can read and download. Ask about the parent directory instead, the convention the file detail view already uses (file.py:126). Library members are unaffected: the native check answers from the library grant and ignores the path. A rename's old parent path can only affect a share-only account, which was refused before anyway. Compile-checked only; the Hub test suite needs Django, which is not installed on this machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
FileHistoryView(/api/v2.1/repos/{id}/file/history/) andNewFileHistoryView(
/api/v2.1/repos/{id}/file/new_history/) both authorized the caller with:A share-only account has no library permission and is qualified on the shared
directory instead (the native grant seam added in #40). Asking about the library
root therefore answers
Noneand returns 403 — for exactly the files the accountcan already list, read and download. The file detail view (
file.py:126) hasalways asked about the parent directory; the history views were the outliers.
Fix
Ask about the file's parent directory, matching the file detail view:
Both views changed;
posixpathwas already imported.Scope and risk
grant and ignores the path, so
'/'and'/a/b'produce the same verdict.qualifies them — the same files they can already read. Nothing outside a
qualified directory is authorized.
rev_renamed_old_pathis still checked againstits own parent, so a path that is no longer under a share stays refused.
is unchanged from the previous revision.
Testing
python3 -m py_compileonly — the Seahub test suite needs Django, which is notinstalled on this machine. Suggested follow-up coverage in
tests/api/test_files.py:Related
Follow-up to #40 (merged), which gave the native permission seam the shared-root
r/rwlevels these views now rely on.