Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Jinja): Extra cache keys to consider vars with set #30549

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

geido
Copy link
Member

@geido geido commented Oct 8, 2024

SUMMARY

The regex for ExtraCache that checks whether the statement has extra cache key calls via has_extra_cache_key_calls wasn't considering cases where the callable vars might not be in double curly brackets, such as:

{% set customer_id = current_user_email() %}
select '{{customer_id}}' as test;

Because of this issue, cached queries for charts would show previously cached data potentially exposing information from other users.

TESTING INSTRUCTIONS

  1. Create a dataset using
{% set customer_id = current_user_email() %}
select '{{customer_id}}' as test;
  1. Create a table chart based on the dataset
  2. Add the chart to a Dashboard
  3. Login with another user
  4. You should see the current user email

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@dosubot dosubot bot added the global:jinja Related to Jinja templating label Oct 8, 2024
superset/jinja_context.py Outdated Show resolved Hide resolved
Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! I don't agree with removing the check for the opening bracket - let's rather make it check for both.

superset/jinja_context.py Outdated Show resolved Hide resolved
tests/integration_tests/sqla_models_tests.py Outdated Show resolved Hide resolved
@michael-s-molina michael-s-molina added the v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch label Oct 8, 2024
@pull-request-size pull-request-size bot added size/L and removed size/S labels Oct 9, 2024
superset/jinja_context.py Fixed Show fixed Hide fixed
superset/jinja_context.py Fixed Show fixed Hide fixed
superset/jinja_context.py Fixed Show fixed Hide fixed
superset/jinja_context.py Fixed Show fixed Hide fixed
superset/jinja_context.py Fixed Show fixed Hide fixed
@geido
Copy link
Member Author

geido commented Oct 9, 2024

/testenv up

Copy link
Contributor

github-actions bot commented Oct 9, 2024

@geido Ephemeral environment spinning up at http://34.222.13.11:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@villebro
Copy link
Member

villebro commented Oct 9, 2024

This comment looks mildly concerning.. Although to be fair, this probably isn't a problem in practice.
image

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful test refactoring! ❤️ LGTM

@geido geido merged commit 318eff7 into master Oct 9, 2024
33 checks passed
Copy link
Contributor

github-actions bot commented Oct 9, 2024

Ephemeral environment shutdown and build artifacts deleted.

sadpandajoe pushed a commit that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
global:jinja Related to Jinja templating size/L v4.1 Label added by the release manager to track PRs to be included in the 4.1 branch
Projects
Status: Cherried
Development

Successfully merging this pull request may close these issues.

4 participants