Fix structural annotation document visibility#2089
Open
JSv4 wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ty-in-structural-annotations
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.
Motivation
AnnotationType.resolve_documentpath (enabled by@bypass_get_queryset) could return a Document from a sharedStructuralAnnotationSetwithout enforcingDocumentvisibility, allowing private documents or signed URLs to leak when an unrelated shared document is visible.Description
config/graphql/annotation_types.py::AnnotationType.resolve_documentto gate returned documents throughBaseService.filter_visible_qs(...)for the directdocument_idcase, the prefetched structural-set candidate list, and the fallbackdocumentsqueryset so only visible documents are returned.opencontractserver/tests/test_corpus_cards_structural_document_resolution.pythat createsother_userand aprivate_docthat shares the same structural set and would sort first in an unscoped prefetch, along with_UNSCOPED_QUERYandtest_unscoped_structural_resolution_skips_private_shared_documentsto assert no private document is returned.Testing
python -m compileall config/graphql/annotation_types.py opencontractserver/tests/test_corpus_cards_structural_document_resolution.pywhich succeeded.python -m pytest opencontractserver/tests/test_corpus_cards_structural_document_resolution.py -qbut test execution was blocked by the environment due toModuleNotFoundError: No module named 'django'so the new test was not executed here.Fix structural annotation document visibilityand include the code and test updates in the described files.Codex Task