You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "no-hup (via GitHub)" <gi...@apache.org> on 2026/09/08 17:50:20 UTC

[PR] perf(security): memoise the user subject lookup within a request [superset]

no-hup opened a new pull request, #44017:
URL: https://github.com/apache/superset/pull/44017

   ### SUMMARY
   
   `is_editor` and `is_viewer` both start by resolving the current user's subject IDs, and both take a single resource. Anything that checks a list of objects calls them in a loop, so the subject lookup runs once per object.
   
   The lookup isn't cheap — `get_user_subject_ids_subquery` is a three-way `UNION ALL` over the user's own subject, their direct and group-derived roles, and their groups. Loading a dashboard runs `can_access_chart` per chart, which is where I noticed it.
   
   Counting the union queries while checking 40 charts as a non-admin:
   
   | | subject-union queries |
   |---|---|
   | master | 80 |
   | this branch | 1 |
   
   Two per chart, because the editor check and the viewer check each do their own lookup.
   
   The fix memoises the result on `g`, keyed by user id. Nothing in a request reads a user's own subjects after changing them, so the entry can't go stale underneath a caller.
   
   Two things I was deliberate about:
   
   - **Outside a request context the behaviour is unchanged.** It's guarded by `has_request_context()`, so Celery tasks and CLI commands keep reading through every time. That matters because `g` is bound to the app context, not the request, and a worker can hold one open for a long time.
   - **It returns a copy.** One caller hands the list into the bootstrap payload that `COMMON_BOOTSTRAP_OVERRIDES_FUNC` is allowed to edit, so handing out the cached list itself would let a customisation hook corrupt it.
   
   Happy to change the cache key or drop it behind a config flag if you'd rather — this seemed like the smallest version that works.
   
   ### TESTING INSTRUCTIONS
   
   `pytest tests/unit_tests/subjects tests/unit_tests/commands tests/unit_tests/dao` — 1237 passed.
   
   Three new tests in `tests/unit_tests/subjects/test_utils.py` cover the cases I cared about: it runs once per user per request, a second user is a separate entry, it still reads through with no request context, and mutating the returned list doesn't poison the cache.
   
   `ruff check`, `ruff format --check` and `mypy` are clean on both files.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5589461163

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev merged PR #44017:
URL: https://github.com/apache/superset/pull/44017


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5839723579

   good call, thats the direction i left implicit. widened the docstring in 2d17bf4 to argue both ways: a miss on a just-created subject cant list it anywhere yet, and a stale retained membership only reaches ensure_no_lockout in commands/utils.py where the worst case is the caller locking themselves out. neither flips a decision for a third party. thanks for the careful read on both PRs.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5793555838

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4079619319


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,33 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. Nothing reads a user's subjects after changing
+    them within a single request, so the cached set cannot go stale in place.

Review Comment:
   `commands/utils.py:127` creates the user's USER subject (`get_user_subject` there is `get_or_create_user_subject`, aliased at line 40) and line 133 reads back through this function, so "nothing reads a user's subjects after changing them" isn't quite the rule. The `get_user_group_subjects` backfill does the same on the create paths.
   
   It still holds up, just for a different reason: a subject created mid-request isn't referenced by any resource's editors or viewers yet, so a cache that's missing it can't flip `is_editor`. Could we write that reason down instead? As worded it reads like something a future create-then-check path can lean on.



##########
tests/unit_tests/subjects/test_utils.py:
##########
@@ -611,3 +612,63 @@ def test_compute_subjects_all_variants(mock_compute):
         ensure_no_lockout=True,
         field_name="editors",
     )
+
+
+def test_get_user_subject_ids_memoises_within_a_request(app) -> None:

Review Comment:
   Following on from the other note, none of these pin the create-then-read case, which is the one carrying the security argument.
   
   Something like: patch the query to return `[7]`, read it, switch the patch to `[7, 99]`, and assert the same request still sees `[7]`. That makes the staleness window a deliberate contract instead of a docstring claim.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5771417449

   Done in f1aa7f2. The cache now lives on `flask.request` (via `_get_current_object()`) instead of `g`, so it's gone when the request ends rather than surviving to the next request that shares the app context. Same `has_request_context()` guard as before — outside a request we still read through.
   
   Added `test_get_user_subject_ids_cache_does_not_leak_across_requests`: one app context, two `test_request_context` blocks, the mocked query returns `[7, 8]` then `[9]`, and it asserts the second request re-queries and sees `[9]`. It fails against the old `g` version (returns the stale `[7, 8]`) and passes with this change. Ran `pytest tests/unit_tests/subjects/test_utils.py` (31 passed), ruff, and mypy locally; didn't run the full suite.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5677410250

   Thanks for the careful pass — checking the request boundary, the `g` key scoping, and the defensive copies is exactly where this could have gone wrong, so I appreciate you going through those paths.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5769580627

   Nice catch, @EnxDev, and looks like bito's landed on the same fix. `g` outlives the request inside a shared app context, so the cache doesn't actually have the lifetime the docstring promises, that matters for anything holding an app context across multiple requests (tests with an autouse fixture, some worker setups). Keying it off `flask.request` instead of `g` seems like the right move since it's already gated by the same `has_request_context()` check. Want to see that addressed, plus a test that reuses one app context across two requests, before this merges.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5841416608

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5767136284

   <!-- Bito Reply -->
   The current implementation uses `g` to store the cache, which persists for the duration of the application context. As you noted, this means the cache survives across multiple requests within the same `app_context()`. To tie the cache to the request lifetime specifically, you can store it on the `flask.request` object instead of `g`. Since `flask.request` is only available when `has_request_context()` is true, this naturally aligns with your existing check.
   
   **superset/subjects/utils.py**
   ```
   if not has_request_context():
           return _query_user_subject_ids(user_id)
       # Store on the request object instead of g
       cache: dict[int, list[int]] = getattr(request, "_user_subject_ids", {})
       if not hasattr(request, "_user_subject_ids"):
           request._user_subject_ids = cache
       if user_id not in cache:
           cache[user_id] = _query_user_subject_ids(user_id)
       return list(cache[user_id])
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5773127284

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5791105926

   Thanks, both of these are fair.
   
   - **The staleness reasoning.** You're right that the "nothing reads a user's subjects after changing them" wording is wrong — `commands/utils.py:127` creates the subject and line 133 reads it straight back, and the group backfill does the same. I rewrote the docstring to the reason that actually holds: a subject created mid-request isn't listed in any resource's editors or viewers yet, so a check against a cache that omits it returns the same access decision. The window is bounded by the request either way.
   - **The test.** Added `test_get_user_subject_ids_serves_a_stale_set_within_the_request`: warm the cache with `[7]`, swap the query to `[7, 99]` in the same request, assert the call still returns `[7]`. That pins the staleness window as a contract instead of a docstring claim.
   - **The description.** Refreshed it so it says the cache lives on `flask.request`, not `g`, with the corrected staleness note, so the squashed message matches the code.
   
   The red checks are the repo-wide `check_pot_drift` / `babel-extract` failure you already confirmed isn't from this diff.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5589501169

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/44017?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `62.50000%` with `3 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 57.52%. Comparing base ([`c4e145b`](https://app.codecov.io/gh/apache/superset/commit/c4e145b071f8ec708ca16485852de3dd8bec9117?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`e688808`](https://app.codecov.io/gh/apache/superset/commit/e6888081bf337d8291947c31e88ffd7b427ba4be?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 6 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/44017?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/subjects/utils.py](https://app.codecov.io/gh/apache/superset/pull/44017?src=pr&el=tree&filepath=superset%2Fsubjects%2Futils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvc3ViamVjdHMvdXRpbHMucHk=) | 62.50% | [1 Missing and 2 partials :warning: ](https://app.codecov.io/gh/apache/superset/pull/44017?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (c4e145b) and HEAD (e688808). Click for more details.
   > 
   > <details><summary>HEAD has 86 uploads less than BASE</summary>
   >
   >| Flag | BASE (c4e145b) | HEAD (e688808) |
   >|------|------|------|
   >|python|75|1|
   >|presto|13|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #44017       +/-   ##
   ===========================================
   - Coverage   79.82%   57.52%   -22.30%     
   ===========================================
     Files        2914     2914               
     Lines      170473   170496       +23     
     Branches    39518    39526        +8     
   ===========================================
   - Hits       136076    98077    -37999     
   - Misses      31875    71495    +39620     
   + Partials     2522      924     -1598     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.51% <62.50%> (-0.01%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.51% <62.50%> (-44.69%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/44017/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/44017?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "no-hup (via GitHub)" <gi...@apache.org>.
no-hup commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5775311672

   Heads-up on the red checks (`babel-extract` and the `check_pot_drift` unit test) — they aren't from this diff. This PR only touches `superset/subjects/utils.py` and its test.
   
   The `check_pot_drift` failure lists five strings missing from `messages.pot`: the alert/report retry messages, plus `Screenshot cache is unavailable` and `Screenshot request is temporarily unavailable`. Those live in `superset/reports/notifications/*` and `superset/dashboards/api.py` on master, not in anything here. `messages.pot` on current master doesn't carry them yet, so any branch cut from master fails this check the same way — rebasing won't clear it, it needs a `messages.pot` regeneration on master. Leaving this one as-is.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5905858521

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4066188646


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,23 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. Nothing reads a user's subjects after changing
+    them within a single request, so the cached set cannot go stale in place.
     """
+    if not has_request_context():
+        return _query_user_subject_ids(user_id)
+    cache: dict[int, list[int]] = g.setdefault("_user_subject_ids", {})

Review Comment:
   Could we tie this cache to the request itself, and add a test with two requests inside the same app context? `has_request_context()` controls when the cache is used, but `g` still survives until the enclosing app context ends.
   
   I reproduced this with the changed function: inside one `app.app_context()`, a first `app.test_request_context('/')` caches `[7, 8]` for user 1. After changing the mocked query result to `[9]`, a second request still returns `[7, 8]` without querying. The autouse `app_context` fixture makes this relevant to tests that issue multiple requests and change memberships between them.
   
   The new test explicitly pushes a fresh app context for its second lookup, so it doesn't catch this case. Storing the cache on the request object would give it the documented lifetime.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5611365526

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4129003964


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,42 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. The cache can miss a subject created earlier in
+    the same request (the create paths in ``commands/utils.py`` read back through
+    here), but that never grants access to anyone else, in either direction. A
+    cache that misses a just-created subject: the subject is not yet listed in
+    any resource's editors or viewers, so an ``is_editor``/``is_viewer`` check
+    still returns the same answer. A cache that retains a subject removed
+    earlier in the same request: the only path that reads it back is
+    ``ensure_no_lockout`` in ``commands/utils.py``, where a stale membership can
+    at most let the caller lock themselves out -- annoying, not a security
+    hole. Neither direction flips a decision for a third party, and the
+    staleness window is bounded by the request.

Review Comment:
   @no-hup have you taken a look at this? Holler if you need a hand assessing it, or apply it if you like it. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4080948428


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,37 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for

Review Comment:
   `is_viewer` only reaches here when there's a user id. The embedded guest branch falls through to `subjects_from_roles` instead, which runs a query per role per resource, so a guest loading a 40-chart dashboard still pays the per-chart cost this removes for everyone else.
   
   Not asking you to fix it here, the shape is different enough to want its own change. Worth a line in this docstring or a follow-up so the next person doesn't read this as covering the guest path too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4140628324


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,23 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. Nothing reads a user's subjects after changing
+    them within a single request, so the cached set cannot go stale in place.
     """
+    if not has_request_context():
+        return _query_user_subject_ids(user_id)
+    cache: dict[int, list[int]] = g.setdefault("_user_subject_ids", {})

Review Comment:
   Good catch, this is already keyed off the request object now instead of `g`, and there's a test pushing a fresh request inside the same app context to pin it. Should hold up to the leak you reproduced.



##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,33 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. Nothing reads a user's subjects after changing
+    them within a single request, so the cached set cannot go stale in place.

Review Comment:
   Fair, and this is fixed too. The docstring now says the actual reason (a subject created mid-request isn't in anyone's editors/viewers yet) instead of the "nothing reads it back" claim.



##########
tests/unit_tests/subjects/test_utils.py:
##########
@@ -611,3 +612,63 @@ def test_compute_subjects_all_variants(mock_compute):
         ensure_no_lockout=True,
         field_name="editors",
     )
+
+
+def test_get_user_subject_ids_memoises_within_a_request(app) -> None:

Review Comment:
   `test_get_user_subject_ids_serves_a_stale_set_within_the_request` does exactly this now, patch returns `[7]`, read it, switch to `[7, 99]`, same request still sees `[7]`. Thanks for spelling it out.



##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,37 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for

Review Comment:
   Agreed the guest path deserves its own change rather than folding it in here. Added a line to the docstring noting `is_viewer`'s guest branch falls through to `subjects_from_roles` and isn't covered, so it doesn't get mistaken for already handled.



##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,42 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. The cache can miss a subject created earlier in
+    the same request (the create paths in ``commands/utils.py`` read back through
+    here), but that never grants access to anyone else, in either direction. A
+    cache that misses a just-created subject: the subject is not yet listed in
+    any resource's editors or viewers, so an ``is_editor``/``is_viewer`` check
+    still returns the same answer. A cache that retains a subject removed
+    earlier in the same request: the only path that reads it back is
+    ``ensure_no_lockout`` in ``commands/utils.py``, where a stale membership can
+    at most let the caller lock themselves out -- annoying, not a security
+    hole. Neither direction flips a decision for a third party, and the
+    staleness window is bounded by the request.

Review Comment:
   Went ahead and applied it in 215ec8a, matches your wording almost verbatim. Nice catch on the reader list too, that was stale.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #44017:
URL: https://github.com/apache/superset/pull/44017#issuecomment-5589478097

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | e6888081bf337d8291947c31e88ffd7b427ba4be |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6aa04adc47caf000082780bb |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-44017--superset-docs-preview.netlify.app](https://deploy-preview-44017--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQ0MDE3LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.1wXQjFpc6hhYAHQ7ukkXDvGZXHcyBqH_zfOhdRR8bHE)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpNCoAgEEDhu8w6SUJSukHHGMeRjEzxZxHR3fOt3uJ7IZcUc4MNYAJb8KZjfObi58gxhcqiVy6idnsyNRFcHdBxvtKzu0FXRKnQkdKEXo7Moo20Fr4f) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-44017--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] perf(security): memoise the user subject lookup within a request [superset]

Posted by "EnxDev (via GitHub)" <gi...@apache.org>.
EnxDev commented on code in PR #44017:
URL: https://github.com/apache/superset/pull/44017#discussion_r4121859970


##########
superset/subjects/utils.py:
##########
@@ -206,7 +206,42 @@ def get_user_subject_ids(user_id: int) -> list[int]:
     1. The user's own USER-type subject
     2. ROLE-type subjects for all direct and group-derived roles the user has
     3. GROUP-type subjects for all groups the user belongs to
+
+    Memoised for the duration of the request, keyed by user id. Authorization
+    calls this once per object checked -- ``is_editor``/``is_viewer`` run it for
+    every chart on a dashboard. The cache can miss a subject created earlier in
+    the same request (the create paths in ``commands/utils.py`` read back through
+    here), but that never grants access to anyone else, in either direction. A
+    cache that misses a just-created subject: the subject is not yet listed in
+    any resource's editors or viewers, so an ``is_editor``/``is_viewer`` check
+    still returns the same answer. A cache that retains a subject removed
+    earlier in the same request: the only path that reads it back is
+    ``ensure_no_lockout`` in ``commands/utils.py``, where a stale membership can
+    at most let the caller lock themselves out -- annoying, not a security
+    hole. Neither direction flips a decision for a third party, and the
+    staleness window is bounded by the request.

Review Comment:
   This makes `ensure_no_lockout` sound like the only reader, but `is_editor`, `is_viewer`, `tasks/utils.py:98` and the bootstrap in `views/base.py` all read through here too.
   
   What actually closes the removal direction is that membership only changes in the Admin user, role and group endpoints or in login-time role sync, and none of those requests read this back afterwards. Could the sentence say that instead?
   
   ```suggestion
       still returns the same answer. A cache that retains a subject removed
       earlier in the same request: membership only changes in the Admin user,
       role and group endpoints or in login-time role sync, and none of those
       requests read this back afterwards. Neither direction flips a decision
       for a third party, and the staleness window is bounded by the request.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org