Repository navigation
OpenConceptLab/ocl_online#717 OpenConceptLab/ocl_online#718 | Reads under a source version get that version's access check - #1023
Conversation
…same access check as that version's list Every GET or HEAD under a source now checks the source and the version the URL names before the view runs, as that version's own concept and mapping lists do: 401 signed out, 403 signed in without access. That covers the lists, a concept or mapping and its revisions, version history, mappings, children, parents, summary, names, extras, collection versions and $cascade, searched or not. For `latest`, the version is the newest released one, plus any version named `latest`. Item-level checks stay, and POST, PUT, PATCH and DELETE are unchanged. The list checks added for OpenConceptLab/ocl_online#715 (check_parent_permissions and SourceVersionListHeadMixin) are folded into this check; their tests pass unchanged. $cascade under a source the requester can't view now answers 401/403 like the source's other reads, rather than 404. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
…'t exist answers 404 A read under a source that doesn't exist, or under a named version of it that doesn't exist, answers 404 for every caller before anything is listed, as collections already do. `latest` on a source with no released version keeps its empty list. Fuzzy search's `source_version` targets get the same access check as the versions' own lists: each version it names must be one the requester can view, otherwise 401 or 403. Expressions that don't resolve are skipped, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
…releases the requester can view With IncludeSearchLatest, the global concept and mapping searches answer from each source's latest release. Their hits and facets now leave out the sources whose latest release the requester can't view, as that release's own lists do. Those are released versions that aren't public while their HEAD is; a private HEAD's content is already private itself. Staff, the owner and the owning organization's members see them as before. Source.get_latest_releases_hidden_from finds them in one query, picking each source's latest release as get_latest_released_version does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
…on, and a search of latest releases, keep to versions the reader can view A concept's Atom feed under a source version (named or `latest`) answers only when the version it reads exists and is public, as feeds are served without signing in. Source.get_url_versions resolves the versions a URL under a source reads, for the feed and for the reads' access check. A search of latest releases now keeps each source that has a release the requester can't view to the members of its exact latest release, or leaves it out when that release isn't viewable either. The index marks a new latest release's members only some time after it's published, so the latest-release flag alone could still point at the previous release in the meantime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
…the source versions it names, as GET does HEAD on a source's concept list with `fuzzy` resolves and checks its `source_version` targets before counting, the same way GET does, instead of failing before the search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
|
Codex review, pass 1 (codex-cli 0.169.0, commit bb9f34f): 6 findings.
Details are on the private ticket. |
…xpressions that don't name a source version A `source_version` expression that resolves to a collection's version, or that can't be parsed, is skipped like one that doesn't resolve, instead of scoping the search by a collection's name or failing the request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
…he signed-in user's own source The concept Atom feed on /user/sources/... routes looked the concept up under any owner. It now reads the signed-in user's own source and answers 404 signed out, as the API's other /user/ routes do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
|
Codex review, pass 2 (codex-cli 0.169.0, commit fb3ece8): pass 1's fixes are confirmed, plus 6 new findings.
Details are on the private ticket. |
…rom the response headers CI's pylint reads `response['num_found']` on the test client's response as unsubscriptable (E1136). `response.headers` is how the other count tests read it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
|
Codex review, pass 3 (codex-cli 0.169.0, commit 16d9d8f): the earlier fixes are confirmed, plus 3 new findings. None is fixed here; they're noted for follow-up:
9e7ff2d is a test-only change for CI's pylint. Details are on the private ticket. |
…se cover HEAD on every route in one test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcAwHwLtCieQ2LSK5
|
Simplification review (fresh reviewer, commit 9e7ff2d), one line each:
Tests on 693a32c: |
…>/<version>/ answers 404, as that route names no owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcAwHwLtCieQ2LSK5
|
Adversarial pass (fresh reviewer, read-only, commit 9e7ff2d): the check holds on every route it covers. One finding was in this PR's own code and is fixed in 3c2098c: a concept feed under |
…tring gets the same read check as one in the URL The reads under a source take `source`, `org`, `user` and `version` from the query string over the URL's, but the check ran on the URL's alone. `check_query_source_version_access` now runs from `initial()` after the URL's check, for GET and HEAD, whenever the query string names a version other than HEAD for a source: 401 or 403 unless the requester can view that version, and its HEAD, of each source named (commas separate several). Precedence is unchanged. - Owner: the one the query string names (org, else user). When it names none (no owner in the URL, or `?org=` empty), the reads match every owner's source of that name, so each one that has the version is checked. A same-named source of another owner can then refuse a request; a version no source has is left to the reads (empty, as before). - HEAD, or no version, isn't checked here: HEAD's content carries its own access and is checked where it's read, and plain requests make no extra queries. - `get_parent_owner_filters` takes the params to find their owner. Tests: `SourceVersionReadAccessTest` (detail, sub-resources, revision, lists, HEAD requests, `?version=latest`, another source's URL, `?user=`, no owner) and `SourceVersionSearchAccessTest` (global lists, searched lists): 401 signed out, 403 to a non-member, 200 to members; HEAD, a public version or an empty `?version=` stay visible. They fail on the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVxv4g3w33csUQuubF
…ust exist under the owner named, and `latest` there is the release the reads use From the Codex check of e86a9bf: - FC.1: a source renamed after a release keeps that release under its old mnemonic. The source and version the query string names are now looked up under the owner it names, and either missing answers 404, as in the URL, instead of being skipped. - With no owner (none in the URL, or an empty `org`), no owner names the version: 404, instead of checking every owner's source of that name. - FC.4: `latest` is the newest released version (`find_latest_released_version_by`), as `get_base_queryset` resolves it, and no longer also a version literally named `latest`. - FC.3: on a collection's route, the URL's version is the collection's. A `source` in the query string there doesn't check a source version of that name (`$cascade` is the collection route served by a source's view). Tests: a renamed source, no owner and a missing version answer 404; a newer public release answers `?version=latest` with an older private version literally named `latest`; a collection version's `$cascade` with `?source=` stays visible. They fail on the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVxv4g3w33csUQuubF
Codex check of commits 16d9d8f..3c2098c (codex-cli 0.169.0, commit 3c2098c)Verdict: clean, no findings. It covered 9e7ff2d (the fuzzy HEAD test reads |
…the owner doesn't have is skipped, as a search reads it as a facet From the Codex check of dd0eb7d, FC.2: a `source` in the query string that isn't one of the owner's sources (a search's facet, such as a prefix) answered 404. Nothing is read under a source that doesn't exist, so it's skipped. A source that exists without the named version still answers 404. Test: `SourceVersionSearchAccessTest.test_a_source_facet_under_a_public_release_stays_a_search` (fails on the previous commit). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qVxv4g3w33csUQuubF
Codex check of commit e86a9bf (codex-cli 0.169.0, commit e86a9bf)Verdict: 4 findings (2 P1, 2 P2).
Full output is on the private ticket. |
Codex check of commits e86a9bf..dd0eb7d (codex-cli 0.169.0, commit dd0eb7d)Verdict: 3 findings (P2).
Full output is on the private ticket. |
Codex check of commits dd0eb7d..ae48cfa (codex-cli 0.169.0, commit ae48cfa)Verdict: 3 findings. None comes from the commit. ae48cfa only gives a
The review loop ends here: no P0 or P1 is open from this PR's commits. Full output is on the private ticket. |
snyaggarwal
left a comment
There was a problem hiding this comment.
Reviewed at ae48cfa, after your Codex passes and the adversarial pass (latest check). The version check holds on the routes I traced: every GET and HEAD under a source checks the version the URL names, and the query-string, fuzzy source_version and latest-release checks work as described. I haven't run the tests.
Before merge (inline):
- A prod
EXPLAIN ANALYZEand row count forget_latest_release_scopes_for, which now runs on every latest-release search. A suggestion keeps it to one query per request. - New: comma-separated sources in the URL now answer 404. The Behaviour to review list doesn't mention it.
- A query-string version with no owner answering 404: this is already in your Behaviour to review list. I agree it needs a call, and suggest an alternative inline.
Nits (inline): extra queries on each read under a source, inactive rows in the new scope query, and the owner-less feed without a version (pre-existing).
| return results | ||
| from core.sources.models import Source | ||
| criterion = None | ||
| for mnemonic, org, username, latest_version in Source.get_latest_release_scopes_for(self.request.user): |
There was a problem hiding this comment.
Before merge: prod EXPLAIN and row count. get_latest_release_scopes_for runs on every non-staff search with IncludeSearchLatest. It runs twice when facets are included, because hits and facets each go through __apply_common_search_filters. It scans every released, non-public source version, and the OR in same_repo may keep Postgres off the indexes. Each row also adds a group of about four clauses to the ES must_not, so the query grows with the number of such sources across OCL. Could you run EXPLAIN ANALYZE and a row count on prod before this merges?
The suggestion keeps it to one query per request. It needs _latest_release_scopes = None beside BaseAPIView's other class attributes, so pylint doesn't flag W0201. If the prod count is large, caching the signed-out answer for a short TTL would also help, since it's the same for every anonymous request.
| for mnemonic, org, username, latest_version in Source.get_latest_release_scopes_for(self.request.user): | |
| if self._latest_release_scopes is None: # hits and facets each build a search | |
| self._latest_release_scopes = Source.get_latest_release_scopes_for(self.request.user) | |
| for mnemonic, org, username, latest_version in self._latest_release_scopes: |
There was a problem hiding this comment.
Done in 2eb9738: your suggestion, with _latest_release_scopes = None on BaseAPIView, and test_latest_release_search_reads_its_scopes_once (a search with facets reads the scopes once).
Prod EXPLAIN (ANALYZE, BUFFERS), read-only (plan and SQL on the private ticket): 8.5 ms execution, 3.8 ms planning; 5 rows returned, signed out and signed in alike (3,915 rows in sources, 240 of them non-public releases). The outer scan is a seq scan of sources, which is small. The public-HEAD EXISTS and both latest-release subqueries use the mnemonic index (sources_mnemoni_56cf9b_idx), and the OR in same_repo becomes a BitmapOr of the organization_id and user_id indexes. So the must_not gets 5 groups today; I've left out the signed-out cache for now.
| repo_versions = Source.get_url_versions( | ||
| self.kwargs['source'], self.kwargs.get('version'), self.get_parent_owner_filters()) | ||
| if repo_versions is None: | ||
| raise Http404() | ||
| for repo_version in repo_versions: | ||
| self.check_view_access(request, repo_version) |
There was a problem hiding this comment.
New: comma-separated sources in the URL now answer 404. On master, /orgs/O/sources/A,B/concepts/ (and mappings/, with or without a version) lists both sources. The reads match the source through get_exact_or_criteria, which splits on commas. Here get_url_versions gets A,B as one mnemonic, finds no HEAD and answers 404. The query-string check below splits on commas and checks each source, and #1022 keeps comma lists working on the versions lists, so the paths disagree.
test_a_missing_source_or_version_is_not_found asserts the 404 for S,, so this may be intended, but the Behaviour to review list doesn't mention it. If comma lists should keep working, checking each name keeps the check whole:
| repo_versions = Source.get_url_versions( | |
| self.kwargs['source'], self.kwargs.get('version'), self.get_parent_owner_filters()) | |
| if repo_versions is None: | |
| raise Http404() | |
| for repo_version in repo_versions: | |
| self.check_view_access(request, repo_version) | |
| for mnemonic in compact(self.kwargs['source'].split(',')): | |
| repo_versions = Source.get_url_versions( | |
| mnemonic, self.kwargs.get('version'), self.get_parent_owner_filters()) | |
| if repo_versions is None: | |
| raise Http404() | |
| for repo_version in repo_versions: | |
| self.check_view_access(request, repo_version) |
The with_comma cases in that test would then answer 401/403/200 like the plain URL. If comma lists shouldn't keep working, a line in Behaviour to review would cover it.
There was a problem hiding this comment.
Kept them working, in 2eb9738. check_source_version_access now resolves each source the URL names (404 unless each exists), then checks each (401/403), so A,B answers like the plain URL with every source checked. On master these lists had no check, as parent_resource came back None.
test_sources_separated_by_commas_in_the_url_answer_as_each covers concept and mapping lists, an item, latest and a trailing comma; test_a_missing_source_or_version_is_not_found keeps 404 for A,NoSuchSource and ,. One thing is as on master: latest under a comma list reads nothing (find_latest_released_version_by gets A,B as one mnemonic), so an item there answers 404 once the check passes.
| if (version, params.get(url_repo), owner_filters) == ( | ||
| self.kwargs.get('version'), self.kwargs.get(url_repo), self.get_parent_owner_filters()): | ||
| return # the URL's own version, checked already | ||
| if not owner_filters: |
There was a problem hiding this comment.
Agreed this needs a call (it's in your Behaviour to review list). When no owner is named, /concepts/?source=S&version=v1 now answers 404 to everyone, staff included, even when every owner's S v1 is public. Master's DB read returned those members across owners.
An option that keeps it working: when no owner is named, look up each source named S that has that version and check each one (401/403, or leave out the ones the requester can't view). Answer 404 only when none exists.
There was a problem hiding this comment.
Built your alternative in 2eb9738. With no owner named, set_hidden_query_versions finds every owner's S with that version and keeps the ones the requester can view. The reads leave out the others' members (leave_out_hidden_query_versions, on the get_base_queryset(self.params) reads) rather than answering 401/403, so a private one's existence doesn't show. A named source answers 404 when none is left, the same answer as when none exists. Public versions read across owners as on master, staff included.
latest with no owner still reads nothing, as on master (the reads' find_latest_released_version_by filters on a NULL owner). Lists with source in the query string go to the search, which reads no version from the query string, so there the check only decides 404 or not. Tests: test_a_version_named_without_an_owner_leaves_out_those_the_requester_cannot_view, and owner-less lines in test_searches_naming_a_version_in_the_query_string_answer_as_in_the_url.
There was a problem hiding this comment.
Follow-up, from the adversarial pass: in 36f75b3 the reads keep to the versions the requester can view (set_viewable_query_versions, keep_to_viewable_query_versions) instead of leaving out the ones found hidden. A renamed source's releases keep their old name, which the lookup by name missed; they're now left out. The answers above are otherwise unchanged.
| return 'source' | ||
|
|
||
| @classmethod | ||
| def get_url_versions(cls, mnemonic, version, owner_filters): |
There was a problem hiding this comment.
Nit (queries). Every GET and HEAD under a source now adds 2 to 4 queries: the HEAD and named-version lookups here, then is_publicly_viewable fetching HEAD again for each version in check_view_access, then HasPrivateAccess's membership exists(). Most of these views then fetch the same version again in set_parent_resource. Passing the HEAD already in hand to the version's check, and keeping the resolved versions on the view for set_parent_resource, would remove most of them.
There was a problem hiding this comment.
Partly, in 2eb9738: set_parent_resource (concepts and mappings) now takes the version the check already read (get_url_source_version), one query less on each read under a source. I've left passing the HEAD to the version's check: is_publicly_viewable reads self.head each time, and caching it there would change a property that serializers and every permission check read, beyond this PR. The membership exists() runs only when the version isn't public.
| public_head = cls.objects.filter(same_repo, version=HEAD, public_access__in=cls.PUBLIC_ACCESS_VALUES) | ||
| releases = cls.objects.filter(released=True).exclude(version=HEAD).exclude( | ||
| public_access__in=cls.PUBLIC_ACCESS_VALUES).filter(Exists(public_head)).annotate( |
There was a problem hiding this comment.
Nit. latest_release keeps to active releases, but releases and public_head don't. A deleted private release still marks its source as scoped. If no active release is left, latest_version is None and the whole source drops out of signed-out latest-release searches.
| public_head = cls.objects.filter(same_repo, version=HEAD, public_access__in=cls.PUBLIC_ACCESS_VALUES) | |
| releases = cls.objects.filter(released=True).exclude(version=HEAD).exclude( | |
| public_access__in=cls.PUBLIC_ACCESS_VALUES).filter(Exists(public_head)).annotate( | |
| public_head = cls.objects.filter( | |
| same_repo, is_active=True, version=HEAD, public_access__in=cls.PUBLIC_ACCESS_VALUES) | |
| releases = cls.objects.filter(is_active=True, released=True).exclude(version=HEAD).exclude( | |
| public_access__in=cls.PUBLIC_ACCESS_VALUES).filter(Exists(public_head)).annotate( |
There was a problem hiding this comment.
Applied in 2eb9738, with test_inactive_versions_leave_latest_release_searches_as_they_are (an inactive private release, and an inactive HEAD).
| """Whether the source version a versioned URL names exists and is public (for `latest`, each it reads).""" | ||
| if 'version' not in kwargs: | ||
| return True | ||
| from core.sources.models import Source | ||
| if 'org' in kwargs: | ||
| owner_filters = {'organization__mnemonic': kwargs['org']} | ||
| elif 'user' in kwargs: | ||
| owner_filters = {'user__username': kwargs['user']} | ||
| else: # /sources/<source>/<version>/: no owner names the version | ||
| return False | ||
| versions = Source.get_url_versions(kwargs['source'], kwargs['version'], owner_filters) | ||
| return bool(versions) and all(version.is_publicly_viewable for version in versions) |
There was a problem hiding this comment.
Nit, pre-existing. The owner-less route without a version, /sources/<source>/concepts/<c>/atom/, still serves whichever owner's concept get_base_queryset(kwargs).first() returns. Only the versioned owner-less route gets the new 404. The concept is public, so nothing leaks, but the feed can belong to another owner's source of the same name. Checking the owner first covers both routes:
| """Whether the source version a versioned URL names exists and is public (for `latest`, each it reads).""" | |
| if 'version' not in kwargs: | |
| return True | |
| from core.sources.models import Source | |
| if 'org' in kwargs: | |
| owner_filters = {'organization__mnemonic': kwargs['org']} | |
| elif 'user' in kwargs: | |
| owner_filters = {'user__username': kwargs['user']} | |
| else: # /sources/<source>/<version>/: no owner names the version | |
| return False | |
| versions = Source.get_url_versions(kwargs['source'], kwargs['version'], owner_filters) | |
| return bool(versions) and all(version.is_publicly_viewable for version in versions) | |
| """ | |
| Whether the URL names the source's owner and, when it names a version, that version exists and is public | |
| (for `latest`, each it reads). | |
| """ | |
| from core.sources.models import Source | |
| if 'org' in kwargs: | |
| owner_filters = {'organization__mnemonic': kwargs['org']} | |
| elif 'user' in kwargs: | |
| owner_filters = {'user__username': kwargs['user']} | |
| else: # /sources/<source>/: no owner names the source | |
| return False | |
| if 'version' not in kwargs: | |
| return True | |
| versions = Source.get_url_versions(kwargs['source'], kwargs['version'], owner_filters) | |
| return bool(versions) and all(version.is_publicly_viewable for version in versions) |
There was a problem hiding this comment.
Applied in 2eb9738. /sources/<source>/concepts/<c>/atom/ now answers 404, with or without a version (test_concept_feeds_answer_only_under_public_versions).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUNfkgDYc59V43e44Y
… are each checked, and a version named with no owner leaves out the sources the requester can't view - A URL naming several sources (`/orgs/O/sources/A,B/...`), as the reads match each, answers 404 unless each exists, then 401 or 403 unless the requester can view each, instead of 404 for every list. - A query-string version with no owner (`?org=&source=S&version=v1`) is read from each owner's `S` that has it: the reads leave out the ones the requester can't view, and answer 404 when none is left. - A latest-release search reads its scopes once per request (hits and facets shared one), from active rows only. - A concept feed answers only under a URL naming the source's owner. - The reads under a source reuse the source versions the access check read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUNfkgDYc59V43e44Y
… already-read source versions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUNfkgDYc59V43e44Y
|
Codex review, pass 1 of the fix round (codex-cli 0.169.0, commit 2eb9738) Verdict: 4 P1, 1 P2, all on behaviour master already has; none from this round's commits. No code change, so the loop stops here.
Responses
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "2eb9738e",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 1366,
"claim": "Ownerless version filtering applies to SQL reads only. Elasticsearch lists ignore the versions the access check resolved.",
"scenario": "Two owners have a source named S with a public HEAD. One owner's v1 is public and the other's is private. The public v1 lets an anonymous request for `/concepts/?source=S&version=v1` pass the access check. Search can then return HEAD concepts from both owners, including concepts outside the public v1.",
"action": "Use the authorized owner, source and version combinations to constrain search hits, counts and facets. Assert the returned owners and release members in the integration test.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 522,
"claim": "Search treats a comma-separated URL source segment as one mnemonic.",
"scenario": "A and B both have a readable v1 with matching concepts. The plain `/orgs/O/sources/A,B/v1/concepts/` list returns members of both. Adding `q` sends Elasticsearch a single source term with the value `A,B`, so the matching concepts disappear from the results and facets.",
"action": "Build the search filter from the checked source versions and test searched results for a URL naming two sources.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.3",
"severity": "P1",
"tag": null,
"file": "core/concepts/views.py",
"line": 192,
"claim": "Versioned concept hierarchy and mapping reads fall back to HEAD behavior on newly accepted comma-separated source URLs.",
"scenario": "A and B have readable v1 releases. A contains concept C, and a mapping from C was added to A's HEAD after v1. On `/orgs/O/sources/A,B/v1/concepts/C/mappings/`, the concept lookup finds C, but the release lookup tries the literal mnemonic `A,B`. The fallback returns the mapping added after v1.",
"action": "Resolve the checked release for the selected concept's source and use it for related reads. Test a release whose mappings or hierarchy differ from HEAD.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.4",
"severity": "P1",
"tag": null,
"file": "core/concepts/views.py",
"line": 423,
"claim": "HEAD on newly reachable public item URLs requires edit permission.",
"scenario": "A public v1 contains the requested concept. A comma-separated source URL that includes its source now returns 200 to a signed-in nonmember on GET. HEAD on the same URL returns 403 because the concept detail view selects `CanEditParentDictionary`. Mapping detail has the same permission branch.",
"action": "Use view permission for both GET and HEAD on concept and mapping detail. Extend the public comma-separated item tests to cover both methods.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.5",
"severity": "P2",
"tag": null,
"file": "core/sources/models.py",
"line": 267,
"claim": "Deactivating a private release can expose its stale latest-release entries in search.",
"scenario": "A public HEAD has one private release whose members are indexed with the latest-release flag. An admin marks that release inactive, as in the new test. The source disappears from the SQL exclusion scopes immediately, so an anonymous latest-release search can return those members while the index still carries the flag.",
"action": "Keep stale memberships excluded until indexing clears their flags, or constrain results to the current active release. Test hits and facets with an index that still marks the inactive release as latest.",
"lines_delta": null,
"confidence": "high"
}
]
} |
|
Codex check of commits 2eb9738..0b217d7 (codex-cli 0.169.0) Verdict: clean. The commit after pass 1 (from the simplification review: one loop splits viewable and hidden versions; Simplification review (Claude subagent) of 2eb9738: S1 and S3 applied in 0b217d7. S2 kept: the test pins the one scope query per request asked for in review. S4 kept: GET and HEAD take different paths, so the comma test checks both. findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "0b217d78",
"verdict": "clean",
"prior": [],
"findings": []
} |
…ing source to the version-access tests; clearer owner-filter comment A missing source or version is the version-access check's case (#1023 answers 404 and tests it), so this test no longer asserts an answer for one and passes whichever PR merges first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D
…o the versions the requester can view, and each source named is checked once A renamed source's versions keep their old name, so finding the versions to leave out by name missed them. The reads now keep to the members of the versions found viewable instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUNfkgDYc59V43e44Y
|
Adversarial pass on this round's commits (cd3d0e6..0b217d7; Claude subagent, fresh context, 14 probes). Details are on the private ticket.
|
|
Codex check of commits 0b217d7..36f75b3 (codex-cli 0.169.0) Verdict: 1 P2, accepted.
Response: FC.1: intended, the safe direction. It matches how this PR answers a renamed source's releases elsewhere: by the new name, with the owner named, they answer 404 as well (in Behaviour to review). findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "36f75b32",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.1",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1361,
"claim": "Ownerless reads now drop renamed source versions even when the requester has access.",
"scenario": "Extend the new rename test by making the same `?user=` request as `self.member`. The org's HEAD has the new mnemonic, its private v1 retains the old mnemonic, and another owner has a public v1 under the new mnemonic. The member could previously read the concept or mapping from the org's v1. The new allowlist contains only the other owner's v1, so both reads now return 404.",
"action": "Resolve eligible versions through the same source memberships and HEAD mnemonics the read uses. Check access to the actual HEAD and linked version, and add a member assertion alongside the existing outsider assertions.",
"lines_delta": null,
"confidence": "high"
}
]
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at 36f75b3. Each item from the ae48cfa review is answered as your replies describe:
- Prod EXPLAIN: 8.5 ms and 5 scope rows, now read once per request. No cache is needed at that size.
- Sources separated by commas in the URL read again, and each is checked. Searches and versioned sub-reads under a comma list still behave as on master (your F1.2 and F1.3), but the check runs first, so they show nothing it didn't pass.
- No owner named: the reads keep to the versions the requester can view. That uses the URL check's rule (
has_view_accessreads HEAD's access throughis_publicly_viewable). Every concept and mapping read goes throughkeep_to_viewable_query_versions, both membership views included. The 404 when none is left doesn't show whether a hidden one exists. set_parent_resourcereuses the version the check read. Leaving HEAD's re-read as it is is fine.- Active rows only in the scope query. F1.5 follows from that suggestion of mine. Deleting a version through the API removes the row, and prod has no inactive private releases, so I agree with accepting it.
- The owner-less feed answers 404.
Behaviour to review is fine as listed, including the new rename item: a renamed source's releases already lose their HEAD on master, as versions and head look them up by name.
CI is green at 36f75b3. It merges cleanly with master, which now has #1007, and with #1024 (396efe3) on top. Neither PR's CI has run with the other's current head or with #1007, so whichever merges second should take master and pass CI first. I haven't run the tests locally.
…'s repository version; a reference's cascade walks only source versions its creator can view (#1024) * OpenConceptLab/ocl_online#736 | Fuzzy concept search keeps to the repository version in the URL, as plain search does A fuzzy search that names no source_version targets now applies the URL's owner, source and version filters. The block that builds them moves unchanged out of __get_search_results into __apply_scope_filters, which both searches call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC * OpenConceptLab/ocl_online#736 | A reference's cascade walks a source version it names only if the reference's creator can view it A version the creator can't view is walked as if it didn't exist, so the reference adds only the concept, as for a label that doesn't resolve; omit_if_exists_in already works this way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC * OpenConceptLab/ocl_online#736 | A reference's cascade checks the system or value set version it walks too; a search scope naming no version matches nothing The cascade check now covers every repo version a cascade walks, not only one named by label. A search scoped to a version that doesn't resolve (latest with no release) now returns no results, rather than an Elasticsearch error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC * OpenConceptLab/ocl_online#736 | Search scope reads the owner from the requester on /user/ routes A collection's owner URL and the release `latest` resolves to now use the requester on the /user/ shortcut, as the owner filter already did, so searches there keep to the requester's own repositories. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qUzz3wjAx46pzoRCsC * OpenConceptLab/ocl_online#736 | Search on the /user/ collection shortcut keeps to the collection's members; search stats with no hits answer an empty list - A search under /user/collections/<c>/ no longer adds the requester as the concepts' owner: a collection's members come from any owner's source, as on the /users/<u>/collections/<c>/ route. - Search stats (searchStatsOnly) with no hits return [] instead of failing on a null max score. - The signed-out reference test now names the cascade version too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH * OpenConceptLab/ocl_online#736 | A reference's cascade checks the source version it walks as the walk finds it, among the versions that hold the concept The label check looked the version up under the source's current name, while the walk looks it up among the source versions that hold the concept. When those differ (after a source is renamed, its releases keep the old name), the check found nothing and let the walk through. It now resolves the label the way the walk does and checks every version it finds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH * OpenConceptLab/ocl_online#736 | A reference's cascade resolves the source version it walks once and hands the checked version to the walk The check and the walk each resolved the cascade's version label. The check now resolves it once, as the walk did (among the source versions that hold the concept, exactly one), checks it, and passes that version to the walk, or None, which adds only the concept as an unknown label does. One lookup per concept instead of the walk's two, and nothing changes between the check and the walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qXcjfVFHsP2kYdP9tH * OpenConceptLab/ocl_online#736 | Fuzzy-search scope test leaves a missing source to the version-access tests; clearer owner-filter comment A missing source or version is the version-access check's case (#1023 answers 404 and tests it), so this test no longer asserts an answer for one and passes whichever PR merges first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qWTbiSiJ56vAgWwb9D --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…1007) into ocl_online-718-query-collection-version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
What changes
Reads under a source now get the access check of the source version the URL names, the one that version's own concept and mapping lists already have.
SourceChildCommonBaseView.check_source_version_accessruns frominitial(), before the handler. The source's HEAD and the version the URL names must exist, or the request answers 404.Source.get_url_versionsresolves them. Forlatest, the version is the newest released one, plus any version namedlatest. The requester must then be able to view them, or the request answers 401 signed out and 403 signed in. Item-level checks still follow. POST, PUT, PATCH and DELETE are unchanged.$cascade. It applies with or withoutq,facetsOnlyor sorting, and to HEAD requests.latestlist checks from OpenConceptLab/ocl_online#715 |latestgets the same access check as a named version #1013 are folded into it.check_parent_permissionsandSourceVersionListHeadMixinare gone, and OpenConceptLab/ocl_online#715 |latestgets the same access check as a named version #1013's tests pass unchanged.source_version. Each version it names gets the same check (401/403), for GET and HEAD. Expressions that don't resolve to a source version are skipped, as before; that now includes a collection's version and an expression that can't be parsed. A fuzzy HEAD request now counts instead of failing.…/<version>/concepts/<c>/atom/,latesttoo). Feeds are served without signing in, so the feed answers only when every version the URL reads exists and is public. Otherwise it answers 404. On/user/routes the feed reads the signed-in user's own source, and a feed URL with no owner (/sources/<source>/…) answers 404, with or without a version. Before, it looked the concept up under any owner. Feeds don't read API tokens, so a token-only request there now answers 404.source,org,userandversionfrom the query string over the URL's. When the query string names a version other than HEAD,check_query_source_version_accessgives it the URL's check, for each source named (commas separate several): 404 when the owner's source of that name doesn't have that version, then 401 or 403 unless the requester can view both. A name that isn't one of the owner's sources (a search's facet, such as a prefix) is skipped, as nothing is read under it.latestis the newest released version, as the reads resolve it. With no owner named (none in the URL, or an emptyorg), the reads take that version from every owner's source of that name:set_viewable_query_versionskeeps the reads to the ones the requester can view, leaving out the others (rather than answering 401/403, which would show they exist), and a source answers 404 when none is left. A renamed source's versions keep their old name, so they're left out too.latestwith no owner resolves to no release, as before. On a collection's route, the URL's version is the collection's and is left to its own checks. Precedence is unchanged. HEAD, or no version, isn't checked again, as HEAD's content carries its own access, so plain requests make no extra queries./orgs/O/sources/A,B/…, which the reads match each of): each must exist (404), then each is checked (401/403). Before, these reads had no check.IncludeSearchLateston/concepts/and/mappings/). Some sources have a public HEAD and a released version the requester can't view. Hits and facets keep each of those to the members of its latest release, picked asget_latest_released_versiondoes, or leave the source out when that release isn't public either. Keeping to the exact release (source_version) covers the time after a new release is published, before the index marks its members as the latest.Source.get_latest_release_scopes_forfinds these sources in one query. Staff, owners and members see everything as before.Routes and methods
/orgs/<org>/sources/<source>/,/users/<user>/sources/<source>/and/user/sources/<source>/:concepts/…andmappings/…, with no version, a named version orlatest./concepts/and/mappings/withIncludeSearchLatest.?source_version=on a source's concept list (GET and HEAD)./concepts/and/mappings/, whose query string names a version other than HEAD (with or withoutsource,orgoruser).Behaviour to review
lateston a private source with no released version answers 401/403 instead of an empty list. On a public source it still answers[].$cascadeover a source the requester can't view answers 401/403, like the source's other reads, instead of 404. The GET assertions inCascadeRepoAccessTestchange to match;$clonestill answers 404./user/route answers 404 without a signed-in session user (see above).version). A version the owner's named source doesn't have answers 404. With no owner named (/concepts/?source=<s>&version=v1, or an emptyorg), versions the requester can't view are left out, and 404 answers only when none is left. Before, these answered from HEAD or an empty list.latestunder such a list still reads nothing, as on master./orgs/<o>/sources/<old>/v1/…) answer 404 to everyone, members included, as there's no HEAD of that name. Before, they answered as the release's access allowed.Tests
New, in
core/integration_tests/tests_access_control.py. The fixture is a public source with a private releasedv1, where HEAD has moved one concept to a newer revision, and a private source with a releasedv1:SourceVersionReadAccessTest: reads underv1andlatest, on every route above, answer 401 signed out, 403 to a non-member and 200 to members and staff. HEAD requests answer the same. Reads under the public HEAD stay visible, and the private source stays hidden. A missing source or version answers 404 to everyone, for GET and HEAD. Also covered:latestwith no release, user-owned sources under/users/and/user/, and concept feeds under private and public versions and under/user/.SourceVersionSearchAccessTest(es): searched version histories (q,facetsOnly,sortAsc, HEAD) answer as their version does. Fuzzysource_versionchecks each version it names, for GET and HEAD, and skips a collection's version or an unparseable expression. A latest-release search leaves out a release the requester can't view, in hits and facets, while members and staff still see it. It keeps to the new latest release before the index catches up. A public latest release stays in.Query-string versions:
SourceVersionReadAccessTestnamesv1orlatestin the query string on the detail, revision, sub-resources and lists (GET and HEAD), and names another source or a user's source; a missing version and a renamed source answer 404; with no owner, versions the requester can't view are left out and 404 answers when none is left (test_a_version_named_without_an_owner_leaves_out_those_the_requester_cannot_view); sources separated by commas in the URL answer as each (test_sources_separated_by_commas_in_the_url_answer_as_each);latestis the newest release; a collection version's$cascadewith?source=stays visible;SourceVersionSearchAccessTestcovers the global and searched lists, and asourcefacet under a public release that names no source of the owner's. They answer 401 signed out, 403 to a non-member and 200 to members.?version=HEAD, an emptyversionor a public release stay visible.Against master's code, the new tests fail except those that check what stays visible. The tests added after review fail on the commit before their fixes.
Run locally as CI runs them at 36f75b3 (with master merged): 3,493 tests without ES, OK (2 skipped); 666 with ES, OK.
pylint -j0 core/exits 0 with no messages. The latest-release scope query on prod (read-onlyEXPLAIN ANALYZE): 8.5 ms, 5 rows.Private details: OpenConceptLab/ocl_online#717, OpenConceptLab/ocl_online#718
🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qX9yqYaS1WjeoK2WiT
https://claude.ai/code/session_01AaZ4qUNfkgDYc59V43e44Y