Repository navigation
OpenConceptLab/ocl_online#718 | A collection named in the query string counts only through versions the requester can view - #1027
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
…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
…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
…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
…>/<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
…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
…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
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
…g counts only through versions the requester can view The global /concepts/ and /mappings/ lists, and the source and owner lists, can be filtered by collection from the query string: `collection`, `collection_url` and `collection_owner_url` on a search, and `collection` (with the owner and `version`) on the database read behind `?csv=true`. Neither checked the collection, so the public members of a private collection, or of a private version of a public one, showed to anyone who named it. - A search counts a concept's or mapping's membership only through the collection versions the requester can view, for plain, `!` and `*` values. Staff, and anyone who can view every version the value matches, get the same search as before. A prefix that matches more than 1,000 viewable versions, when some are hidden, answers 400. - The database read keeps to the members of the versions the requester can view, in the same filter as the collection's own. - A collection named with its owner answers as a source named that way does: 404 unless the version named exists, then 401 or 403 unless the requester can view the collection and that version. A collection's HEAD is checked too, as it holds other repositories' content. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
…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
…versions the requester can view, as literal prefixes, and aren't cached Codex pass 1 on oclapi2#1027: - An exact collection facet value always matches through the viewable versions' URLs, so a version deleted since it was indexed (whose members keep its URL until they're indexed again) matches nothing (F1.3). - A prefix is literal, as the database reads it: `@` is no wildcard, and `*` alone is checked too (F1.1). - An owner URL matches that owner's versions only, and the 1,000-version limit applies to prefixes (F1.8). - A source version's first page isn't cached when a collection facet is named, as its rows depend on who asks (F1.2). - A test pins that a CSV export's version and access match in one expansion (F1.9). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
…o ocl_online-718-query-collection-version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
…lection check in, and `*` alone is checked per requester Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
…he viewable versions' URLs up to the limit, so deleted versions match nothing there too Codex pass 1 on oclapi2#1027, F1.3 for prefixes: a prefix stays a prefix only past the limit with nothing hidden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
Codex review, pass 1 (codex-cli 0.169.0, commit c5f9b4e)Verdict: findings (7 P1, 2 P2). Fixed in b46db42 and 6221056; #1023's head 36f75b3 merged in 0adfb63.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "full",
"commit": "c5f9b4e2",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "F1.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 477,
"claim": "Collection prefixes can match private memberships that the database visibility lookup never checks.",
"scenario": "A bare `*` becomes an empty prefix and skips the visibility lookup. Elasticsearch still matches every indexed collection membership, including rows whose only membership is private. The two matchers also disagree on `@`. The database treats it literally, while the fallback regexp treats it as a wildcard under Lucene's default flags. [Elasticsearch regexp syntax](https://www.elastic.co/docs/reference/query-languages/query-dsl/regexp-syntax#regexp-optional-operators)",
"action": "Check visibility for empty prefixes and use the same literal prefix semantics in PostgreSQL and Elasticsearch. Add coverage for an empty prefix and a prefix containing `@`.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 1211,
"claim": "The shared source-version list cache bypasses the new collection facet visibility check.",
"scenario": "An org member filters an accessible source release by the URL of a private collection version. With default paging and no search text, the list caches the matching rows under a key shared by all callers. An outsider requesting the same list receives those rows before the facet visibility check runs.",
"action": "Bypass shared list caching whenever a collection membership facet is present. Test the same request first as a member and then as an outsider.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.3",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 489,
"claim": "Deleting a private collection version lets its stale indexed memberships through the visibility check.",
"scenario": "A private collection version contains public resources and is then deleted. The delete task removes the expansion and collection rows without reindexing the member documents. A search for the old version URL finds no hidden database row, keeps the original Elasticsearch filter, and returns the former members.",
"action": "Require a current viewable version for indexed membership matches. Add a regression case where an indexed membership remains after its collection version is deleted.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.4",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 1443,
"claim": "A source route skips the collection version check even when the version is supplied explicitly in the query string.",
"scenario": "An outsider lists an accessible source release with `collection=C&version=v1`. The collection's HEAD is public and its `v1` is private. The guard checks only HEAD and the request can return 200. An explicitly named nonexistent collection version likewise skips the required 404.",
"action": "Read an explicit query-string `version` for the named collection and keep the URL's version scoped to its repository. Test both a private and a missing query-string version from a source route.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.5",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 1456,
"claim": "An explicit `latest` request succeeds for an existing collection with no released version.",
"scenario": "A public collection contains members in HEAD and has never been released. An owner-qualified request for that collection with `version=latest` passes the guard and can return HEAD members in search, despite the required 404.",
"action": "Return 404 when an existing collection has no release that resolves an explicit `latest` selector. Cover a populated HEAD with no released version.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.6",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 1440,
"claim": "A query-string user owner cannot override an organization owner from the URL.",
"scenario": "On an organization-owned source route, an outsider supplies `user=U&collection=C` for a private collection owned by U. The merged parameters retain the URL's `org`, and `get_parent_owner_filters` gives it priority. If the organization has no C, the guard skips the collection and returns 200 instead of 403.",
"action": "Resolve the explicit query-string owner before falling back to the URL owner. Use the resolved owner consistently in collection authorization and database filtering.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.7",
"severity": "P1",
"tag": null,
"file": "core/concepts/views.py",
"line": 246,
"claim": "CSV exports under a source route ignore the query-string collection membership filter.",
"scenario": "A public source contains two concepts and a viewable collection contains only one. Exporting the source's concepts with `csv=true&collection=C` takes the parent queryset branch and exports both. The mapping list has the same parent queryset branch.",
"action": "Apply the collection criterion and version visibility to the source-scoped CSV queryset before slicing it. Test exported rows for both resource types.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.8",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 491,
"claim": "The facet limit counts candidate URIs before checking whether their owner URLs actually match.",
"scenario": "An exact `collection_owner_url` of `/orgs/` matches no indexed owner URL. If the database contains more than 1,000 viewable organization-owned versions and at least one hidden version, the broad URI lookup raises 400 before checking owner URL equality. A valid exact owner URL also receives the prefix limit when the owner has enough versions.",
"action": "Match the actual owner URL before testing for hidden versions or counting viewable versions. Apply the 1,000-version limit to prefix filters.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F1.9",
"severity": "P2",
"tag": null,
"file": "core/integration_tests/tests_access_control.py",
"line": 2202,
"claim": "The CSV regression test does not exercise the same-expansion join required by criterion 5.",
"scenario": "The fixture keeps the private Q v1 member out of the public Q HEAD. The test would still pass if a second join let a row satisfy `version=v1` through the private expansion and satisfy visibility through the public HEAD expansion.",
"action": "Put the same concept and mapping rows in both expansions, then assert that the ownerless v1 CSV export excludes them for an outsider and includes them for a member.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…thing, quoted names are checked, and the database read always keeps to viewable versions Codex pass 2 on oclapi2#1027: - A version counts as viewable only while active, as its own lists answer 404 otherwise (F2.1). - The owner check strips quotes from names, as a search does (F2.4). - An owner URL prefix longer than any owner URL matches no version (F2.5). - The database read keeps to the viewable versions on every non-staff read that names a collection, with no separate check first (F2.6). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
Codex review, pass 2 (codex-cli 0.169.0, commit 6221056)Verdict: findings (2 P1, 4 P2). Pass 1: F1.1, F1.2 and F1.8 resolved. F1.4–F1.7 stand as answered in pass 1. F1.3 is narrowed to F2.2 and F2.3 below. F1.9's test fails with the read split into two joins and passes as written (checked by swapping the file in). Fixes are in a495486.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "62210563",
"verdict": "findings",
"prior": [
{"id": "F1.1", "status": "resolved"},
{"id": "F1.2", "status": "resolved"},
{"id": "F1.3", "status": "unresolved"},
{"id": "F1.4", "status": "unresolved"},
{"id": "F1.5", "status": "unresolved"},
{"id": "F1.6", "status": "unresolved"},
{"id": "F1.7", "status": "unresolved"},
{"id": "F1.8", "status": "resolved"},
{"id": "F1.9", "status": "unresolved"}
],
"findings": [
{
"id": "F2.1",
"severity": "P1",
"tag": null,
"file": "core/common/models.py",
"line": 1187,
"claim": "Deactivating a collection owner can expose memberships that the collection's private HEAD previously hid.",
"scenario": "A user-owned collection has a release that retains its public access value after HEAD becomes private. Deactivating the owner marks both rows inactive. The collection's own list now returns 404, but the new lookup ignores the inactive private HEAD and still admits the inactive release. An outsider can see its public members through an ownerless search or CSV export.",
"action": "Require an active collection version in the membership visibility query and add a regression test for a deactivated owner with a private HEAD and a formerly public release.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.2",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 468,
"claim": "Reusing a collection URL grants access to stale memberships from the deleted collection.",
"scenario": "An owner deletes a private collection and creates an empty public collection with the same name. Deletion leaves the old collection URL on indexed member documents. The new public row puts that URL back in the allowlist, and an outsider's exact facet search returns the deleted collection's former members.",
"action": "Match search membership against a stable collection version ID and cover deletion followed by recreation at the same URL.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.3",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 496,
"claim": "The large-prefix fallback still returns stale memberships from deleted private versions.",
"scenario": "A prefix matches 1,001 current public versions and one deleted private version whose membership is still indexed. The database finds no hidden current version, so the search falls back to a raw prefix and returns rows that matched only through the deleted version.",
"action": "Keep the visibility restriction on broad prefixes even when every current match is public. Add a regression case that reaches the fallback with a deleted private match.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.4",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1464,
"claim": "The owner-qualified guard skips exact collection names that search accepts in quotes.",
"scenario": "With private collection C under O, a request for `/concepts/?org=O&collection=%22C%22` looks up a mnemonic that includes the quotes and skips the guard. Search strips the quotes and treats the filter as an exact match for C. The request returns 200 instead of 401 or 403.",
"action": "Use the same exact collection value parsing for the guard and the search facet, and test the owner-qualified quoted form.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.5",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 491,
"claim": "An owner URL prefix can trigger the 1,000-version limit even when it matches zero owner URLs.",
"scenario": "An organization has more than 1,000 public collection versions and at least one private version. `collection_owner_url=/orgs/O/collections/*` matches their collection URIs in PostgreSQL, but no indexed owner URL extends beyond `/orgs/O/`. An outsider receives 400 for a filter whose result should be empty.",
"action": "Match the prefix against owner URLs before counting viewable versions or checking for hidden matches.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F2.6",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1495,
"claim": "The CSV visibility check can race with a collection permission change.",
"scenario": "An outsider starts an ownerless CSV export while all versions of the named collection are public. The preliminary existence check returns false. If an editor makes the selected version private before the export queryset runs, the export uses an unrestricted expansion join and includes its members.",
"action": "Apply the viewability predicate in the same expansion join on every non-staff CSV read, including when the preliminary lookup would find no hidden versions.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…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
…rch reads as `collection` Codex pass 3 on oclapi2#1027, F3.3: `Collection=` named a private collection with its owner and got 200 (with no rows), not 401 or 403. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR
Codex review, pass 3 (codex-cli 0.169.0, commit a495486)Verdict: findings (2 P1, 1 P2). Pass 2: F2.1, F2.4, F2.5 and F2.6 resolved, and F1.9 is resolved too. F1.4–F1.7, F2.2 and F2.3 stand as answered. The F3.3 fix is eb83b09, on top of a merge of master 24a8e90 (529f23f, after #1023 and #1024 merged). The full suite on the merged code passes: 3,560 tests, plus 690 search tests.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "verify",
"commit": "a4954860",
"verdict": "findings",
"prior": [
{"id": "F1.1", "status": "resolved"},
{"id": "F1.2", "status": "resolved"},
{"id": "F1.3", "status": "unresolved"},
{"id": "F1.4", "status": "unresolved"},
{"id": "F1.5", "status": "unresolved"},
{"id": "F1.6", "status": "unresolved"},
{"id": "F1.7", "status": "unresolved"},
{"id": "F1.8", "status": "resolved"},
{"id": "F1.9", "status": "resolved"},
{"id": "F2.1", "status": "resolved"},
{"id": "F2.2", "status": "unresolved"},
{"id": "F2.3", "status": "unresolved"},
{"id": "F2.4", "status": "resolved"},
{"id": "F2.5", "status": "resolved"},
{"id": "F2.6", "status": "resolved"}
],
"findings": [
{
"id": "F3.1",
"severity": "P1",
"tag": null,
"file": "core/common/views.py",
"line": 468,
"claim": "The search allowlist can mistake a live private release's indexed membership for public HEAD membership.",
"scenario": "A collection has a public HEAD and a private release named `concepts`. The expansion URI parser cuts the path at `/concepts/`, so the release's members are indexed under the HEAD URL. The allowlist admits that URL, and an outsider's collection search returns public rows that belong only to the private release. The same parser also leaves the indexed version URL empty for a collection named `concepts`, so the rewritten owner facet drops that public collection's members.",
"action": "Index and match membership using the expansion's collection version ID, backfill existing documents, and test both path-segment cases.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.2",
"severity": "P1",
"tag": null,
"file": "core/integration_tests/tests_access_control.py",
"line": 2139,
"claim": "The CSV test adds HEAD rows to releases and masks empty exports from ordinary versioned expansions.",
"scenario": "A locked collection release replaces HEAD concepts and mappings with their resource versions, as `Collection.replace_head_resources` specifies. A member exports that release from a global list. The expansion join finds the versioned rows, but the list applies `id=versioned_object_id` because the version was supplied in the query string. The export is empty. The test passes because it inserts both the HEAD and versioned row into the release.",
"action": "Use only versioned resource rows in the release fixture and make global CSV lists preserve the rows selected by a query-string collection.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "F3.3",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1460,
"claim": "The owner-qualified check misses collection parameter spellings that search accepts.",
"scenario": "An outsider names a private collection with its owner using `Collection` as the query parameter. Search normalizes the key to `collection`, but the guard reads only the lowercase key. The request returns 200 with no hits instead of 403.",
"action": "Read the collection value using the same key normalization and precedence as search. Add an owner-qualified test for an alternate spelling.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…lper Simplification review S1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
…y viewable versions; a collection version's URL wins over a query-string version Adversarial pass, A5 and A1: - POST /concepts/$match/ with a filter naming a collection facet reads the view's document_model since this PR's facet change; the view now declares it (ConceptDocument), so the filter counts only the collection versions the requester can view, as a list search does. - CollectionBaseView.get_filter_params takes the version the URL names, and the query string's only on routes that name none, so a version route's access check and its search read the same version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
Simplification review (claude subagent, commit eb83b09)Verdict: findings (3 cuts proposed, 1 applied). Applied in e1d7390; the access tests (161) and Pylint (
simplify-findings.json{"reviewer":"claude subagent","perspective":"simplify","mode":"full","commit":"eb83b09a","verdict":"findings","prior":[],"findings":[
{"id":"S1","tag":"dup-test","file":"core/integration_tests/tests_access_control.py","line":2297,"claim":"test_csv_exports_count_only_versions_the_requester_can_view and test_csv_exports_match_the_version_and_its_access_in_one_expansion each define the same `export` closure and exports list.","action":"Pull one helper (e.g. a `csv_rows(url, user, resource)` method that patches write_csv_to_s3 and returns the exported mnemonics) onto the test class and use it in both; the tests themselves (they pin F1.9) stay.","lines_delta":-12,"confidence":"medium","severity":null,"scenario":null},
{"id":"S2","tag":"shrink","file":"core/common/views.py","line":139,"claim":"The `if not prefix: urls = list(urls) else: ...` split in get_viewable_collection_urls nests the limit logic one level deeper than needed.","action":"Handle the exact-value case first with an early `cache[key] = list(urls)` / continue-style return, so the prefix branch (limit, 400, owner-url filter) is un-nested: `if not prefix: cache[key] = list(urls); return cache[key]`.","lines_delta":-3,"confidence":"low","severity":null,"scenario":null},
{"id":"S3","tag":"dup-test","file":"core/integration_tests/tests_access_control.py","line":2155,"claim":"In test_collection_facets_count_only_versions_the_requester_can_view, the three assert_lists calls combining `collection_url=<owner>collections/<prefix>*`, `collection=*` and `collection_owner_url=<owner>` with `collection=<prefix>*` assert the identical expected sets as the plain `collection=<prefix>*` line.","action":"Keep one of the combined-facet lines (one per distinct facet code path: collection_url prefix and collection_owner_url); drop the `collection=*&collection_url=...` variant, which the `collection=*` loop and the collection_url prefix line already cover.","lines_delta":-2,"confidence":"low","severity":null,"scenario":null}
]} |
Adversarial pass (claude subagent, commit eb83b09)A fresh reviewer had only the diff and one goal: find any way a requester learns which concepts or mappings are in a collection version they can't view. Channels: global and repository lists, CSV, facets,
The reviewer found everything else closed at this head:
|
…on refuses a different version in the query string Codex final check FC.1 and FC.3: with the URL's version winning, a DELETE or PUT sent to HEAD/ with a query-string version would act on HEAD, and an unresolved `latest` could lose its version. A route that names a version now answers 400 when the query string names a different one, before any read or write; routes that name none still read the query string's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
…ng version naming the release it resolves to Codex check FC2.1: the conflict check now compares the query string's version with `latest` as resolved, so `latest/concepts/?version=v1` answers as before when v1 is the newest release; a different version, or one with no release to resolve to, still answers 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
Codex check of commits a495486..7126b2d (codex-cli 0.169.0, commit 7126b2d)Verdict: findings (1 P1, 2 P2), all on the version precedence that 7126b2d changed. This pass judged only this PR's own lines in the range (eb83b09, e1d7390, 7126b2d), not the master merge 529f23f.
Pylint is clean and the full suite passes on a88cc2b: 3,560 tests, plus 692 search tests (on a fresh index). findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "7126b2d4",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC.1",
"severity": "P1",
"tag": null,
"file": "core/collections/views.py",
"line": 116,
"claim": "The shared version lookup can turn a release deletion into deletion of the entire collection.",
"scenario": "An authorized client sends DELETE to the explicit HEAD version route with `?version=v1`, using the existing query-string override to select the release. The previous lookup passed v1 to `delete_collection`. The new lookup passes HEAD, whose deletion also removes every sibling version.",
"action": "Reject conflicting version selectors before a mutation. Add a regression test that verifies the request schedules no deletion.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.2",
"severity": "P2",
"tag": null,
"file": "core/common/views.py",
"line": 1512,
"claim": "The owner check can reject a search based on a collection value that the search discards.",
"scenario": "An owner-scoped list request sends `Collection` for a private collection followed by `collection` for a public one. Search normalization keeps the later public value. The new check evaluates both and returns 401 or 403 to someone who could previously run the public search.",
"action": "Use the effective collection value from the active search or database parser for the owner check, and test both orders of the two spellings.",
"lines_delta": null,
"confidence": "high"
},
{
"id": "FC.3",
"severity": "P2",
"tag": null,
"file": "core/collections/views.py",
"line": 116,
"claim": "Giving an unresolved `latest` URL precedence can produce a 500 by dropping the version constraint.",
"scenario": "A collection has HEAD and an unreleased v1. A member requests its `latest/concepts/?version=v1` list. The previous lookup selected v1. The new lookup selects `latest`, finds no released version, and drops the resulting null version from the queryset. The single-object lookup then finds both rows and raises `MultipleObjectsReturned`.",
"action": "Return 404 when an explicit `latest` version cannot be resolved, before building the queryset.",
"lines_delta": null,
"confidence": "high"
}
]
} |
Codex check of commits 7126b2d..a88cc2b (codex-cli 0.169.0, commit a88cc2b)Verdict: findings (1 P2). FC.1 and FC.3 resolved; FC.2 stands as accepted.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "a88cc2b6",
"verdict": "findings",
"prior": [
{"id": "FC.1", "status": "resolved"},
{"id": "FC.2", "status": "unresolved"},
{"id": "FC.3", "status": "resolved"}
],
"findings": [
{
"id": "FC2.1",
"severity": "P2",
"tag": null,
"file": "core/collections/views.py",
"line": 118,
"claim": "The conflict check rejects requests where `latest` and the explicit version select the same release.",
"scenario": "When `v1` is the newest released version, a member requesting `GET /orgs/O/collections/C/latest/concepts/?version=v1` previously received the `v1` list and now receives 400. A configured Term Browser v2 organization tab can send this combination through its `defaultURI` and `query_params` settings. The added test expects 400 with `v1` as the fixture's only release.",
"action": "Resolve `latest` before comparing the selectors. Test that a matching release succeeds and that a conflicting or unresolved selector fails before any write.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…ery-string version naming the release it resolves to" This reverts commit 9df45c9. Codex check FC3.1: comparing the query string's version with `latest` as resolved answered differently when it named that release, before the access check. A route that names a version again refuses any different query-string version with 400. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
Codex check of commits a88cc2b..9df45c9 (codex-cli 0.169.0, commit 9df45c9)Verdict: findings (1 P1). FC2.1 resolved by 9df45c9, but that fix brought in FC3.1.
findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "9df45c9c",
"verdict": "findings",
"prior": [
{
"id": "FC2.1",
"status": "resolved"
}
],
"findings": [
{
"id": "FC3.1",
"severity": "P1",
"tag": null,
"file": "core/collections/views.py",
"line": 128,
"claim": "The conflict check reveals whether a supplied version is a private collection's latest release.",
"scenario": "A signed-in nonmember requests a private collection's latest concept list. When the query version matches the private latest release, the request reaches the object permission check and returns 403. A different version returns 400. Before this commit, both explicit version names returned 400. The status difference now confirms the private release's version name.",
"action": "Check access to the resolved release before comparing the selectors. Test that a nonmember receives the same permission denial for matching and conflicting versions while a member can still use a matching version.",
"lines_delta": null,
"confidence": "high"
}
]
} |
…ivate HEADs once for all versions For a signed-in requester, the private-HEAD check sat inside an OR with their own and their orgs' versions, so the database ran it once per version: 0.3 s for a collection with 675 versions. It is now a top-level NOT EXISTS that leaves out the requester's own and their orgs' HEADs; a version shares its HEAD's owner, so the versions matched are the same. A test compares the query with has_view_access on every version, for each kind of requester. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaZ4qU5uSpgMo1niq3ECJx
Codex check of commits e13b215..de591bb (codex-cli 0.169.0, commit de591bb)Verdict: findings (1 P2). The commit changes the shape of the viewable-versions query (a top-level anti-join; 301 ms → 2 ms for a signed-in lookup on a collection with 675 versions, measured on production).
Pylint is clean and the full suite passes on de591bb (3,561 tests, plus 692 search tests). findings.json{
"reviewer": "codex-cli 0.169.0",
"perspective": "defects",
"mode": "final",
"commit": "de591bb1",
"verdict": "findings",
"prior": [],
"findings": [
{
"id": "FC4.1",
"severity": "P2",
"tag": null,
"file": "core/common/models.py",
"line": 1198,
"claim": "The rewritten predicate can hide a legacy collection from members of its owning organization.",
"scenario": "Before [OpenConceptLab/oclapi2#979](https://github.com/OpenConceptLab/oclapi2/pull/979), collection creation could populate both owner fields. If an org collection version also has Alice's user ID and Alice has a private personal collection with the same mnemonic, her personal HEAD matches the subquery by user ID. For another member of the org, that HEAD survives the exclusion and blocks the org version. The previous predicate allowed the version through org membership. Collection facets and database reads now omit content that matches only through that version.",
"action": "Apply the ownership bypass to the candidate version and add a regression test with a legacy dual-owner row and a same-named private personal HEAD.",
"lines_delta": null,
"confidence": "high"
}
]
} |
snyaggarwal
left a comment
There was a problem hiding this comment.
Approving at de591bb. Merge once its CI is green; it was still running when I looked. The fix holds on the paths I traced:
get_viewable_versions_criteriagiveshas_view_access's answer. Public versions need a public HEAD, own and org versions skip the private-HEAD check (their HEAD is theirs too), and inactive versions are left out. de591bb's single anti-join keeps that answer and takes the signed-in BEMRS lookup from 301 ms to 2 ms on prod. Keep it rather than the partial index, as it needs no migration.- The three facets match only through version URLs the requester can view. An empty list matches nothing, and
!excludes only versions they can view, so a hidden collection answers like one that doesn't exist. - The database read keeps the viewable versions in the same filter as the collection's own criterion, so one expansion must match both. Your EXPLAIN shows no extra cost.
- The owner check gives a query-string collection the source check from #1023, plus its HEAD.
- A version route refuses a different query-string
versionwith a 400, which also closes FC.1'sDELETE …/HEAD/?version=v1.
Choices for review: I agree with all four. That covers the empty list for an owner-less name, checking a collection's HEAD, the 400 past 1,000 viewable versions when some are hidden, and the 400 for a conflicting version. Fine to leave FC.2, FC2.1 and FC4.1 as accepted (prod has no collection rows with both owners).
The collection facet's buckets still list hidden collections' names and counts. That's #739, so it's not part of this PR.
The description spells out the leak, and master would have the fix before prod does. So once this merges, the release should follow soon.
I haven't run the tests. You report 3,561 tests plus 692 search tests passing on de591bb.
Follows #1023 (merged; master merged in at 529f23f). Tracks OpenConceptLab/ocl_online#718; follow-up in OpenConceptLab/ocl_online#739.
What this fixes
A collection named in the query string wasn't access-checked on the concept and mapping lists:
collection,collection_urlandcollection_owner_urlfilter on the names and URLs of every version a concept or mapping is in. That includes versions the requester can't view, and it ignoresorgandversion.!and*values work too.?csv=true,collection(with the owner andversion) filters the same way.What changes
!or*) is matched only through the URLs of the current collection versions the requester can view (terms collection_url). That also drops a deleted version's members, which keep its URL in the index until they're indexed again. Staff's searches are unchanged. A prefix is literal (an Elasticsearchprefixquery, so@is no wildcard).get_base_querysettakes the viewable versions, in the same filter as the collection's own criterion, so one expansion has to match both.check_query_collection_version_access, next to OpenConceptLab/ocl_online#717 OpenConceptLab/ocl_online#718 | Reads under a source version get that version's access check #1023's source check): 404 unless the named version exists, then 401 or 403 unless the requester can view the collection and that version. A collection that doesn't exist under that owner is skipped, as the search reads the name as a facet.ConceptContainerModel.get_viewable_versions_criteria(user)ishas_view_accessas a query.NOT EXISTSthat leaves out their own and their orgs' HEADs, rather than a check inside the OR, which the database ran once per version. The results are the same; a test compares it withhas_view_access. Drop this commit if a partial index oncollections (mnemonic) WHERE version = 'HEAD'is preferred.$match: afilternaming one of the three facets counts only the versions the requester can view, as a list search does (the view now declares itsdocument_model; after the facet change it answered 500).CollectionBaseView.get_filter_params). So the route's access check, its search and its writes all act on the version the URL names. Routes with no version in the URL still read the query string's.Choices for review (each can be overturned)
collection=abc*) that matches more than 1,000 viewable versions answers 400 when the requester can't view some of what it matches; with nothing hidden, it stays a plain prefix. Staff never see this. On a server with many public collections, such as OCL's, a barecollection=*from anyone but staff answers 400; no OCL web client sends a collection wildcard.versionin the query string answers 400. Before, it mostly overrode the URL's version. No OCL web client sends one.Not in this PR
collectionfacet's buckets on a global search still list hidden collections' names and counts (OpenConceptLab/ocl_online#739).CollectionVersionConceptsView) get the search rewrite but not the owner check, as they read their own URL's collection.Tests
QueryCollectionAccessTestintests_access_control.py: signed out, an outsider, a member and staff, on/concepts/and/mappings/, by search,qandcsv; plain, comma,!and*values;collection_urlandcollection_owner_url; the owner check, includinglatest, a missing version, and the source routes; the 400 past the limit;$matchfilters; and a version route with a query-stringversion.ViewableVersionsCriteriaTestchecks the query againsthas_view_access.pylint -j0 core/is clean, and the full suite passes (3,561 tests, plus 692 search tests).Production
EXPLAIN(Nov 23) is on the private tracking ticket. The database read's extra join adds no cost, and signed-out lookups take milliseconds. A signed-in lookup on a collection with hundreds of versions took about 0.3 s; with de591bb it takes 2 ms.🤖 Generated with Claude Code
https://claude.ai/code/session_01AaZ4qW8QKbfuEJubgQgsHR