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: skip perms on query context update #16250

Merged
merged 1 commit into from
Aug 13, 2021
Merged

Conversation

betodealmeida
Copy link
Member

SUMMARY

When building a CSV report for an old chart, the worker needs to fetch a screenshot of the chart in order to populate the query_context column of the chart. This is needed to request CSV data for the chart if it hasn't been saved with its query_context.

One problem in doing this is that the worker generating the report might not own the chart, so they are unable to populate query_context. I added a check to bypass the permission check only when the request is just for query_object.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screenshot 2021-08-13 at 08-25-47 Superset

Screenshot 2021-08-13 at 08-25-27  Report  Test 2 Most Populated Countries - ralmeida gmail com - Gmail

TESTING INSTRUCTIONS

  1. Create a CSV report of a chart from the examples that hasn't been opened yet (so that query_context is null).
  2. Configure screenshots with a low-level user that doesn't own the chart (ie, not "admin").
  3. Reports should work fine.

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

@codecov
Copy link

codecov bot commented Aug 13, 2021

Codecov Report

Merging #16250 (eb1fe87) into master (6cd15d5) will decrease coverage by 0.22%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16250      +/-   ##
==========================================
- Coverage   76.75%   76.53%   -0.23%     
==========================================
  Files         997      997              
  Lines       53195    53198       +3     
  Branches     6764     6764              
==========================================
- Hits        40830    40715     -115     
- Misses      12135    12253     +118     
  Partials      230      230              
Flag Coverage Δ
hive ?
mysql 81.54% <100.00%> (-0.04%) ⬇️
postgres 81.60% <100.00%> (+<0.01%) ⬆️
presto ?
python 81.69% <100.00%> (-0.43%) ⬇️
sqlite 81.25% <100.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/charts/commands/update.py 88.88% <100.00%> (+0.48%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
superset/db_engine_specs/presto.py 83.47% <0.00%> (-6.91%) ⬇️
superset/views/database/mixins.py 81.03% <0.00%> (-1.73%) ⬇️
superset/connectors/sqla/models.py 88.04% <0.00%> (-1.66%) ⬇️
superset/db_engine_specs/base.py 88.00% <0.00%> (-0.39%) ⬇️
superset/models/core.py 89.61% <0.00%> (-0.26%) ⬇️
superset/utils/core.py 88.98% <0.00%> (-0.13%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6cd15d5...eb1fe87. Read the comment docs.

@betodealmeida betodealmeida added the need:merge The PR is ready to be merged label Aug 13, 2021
@eschutho
Copy link
Member

Looks good, but question for my understanding, why couldn't we give the machine user permission for the charts that it doesn't own?

@betodealmeida betodealmeida merged commit 2611681 into apache:master Aug 13, 2021
@betodealmeida
Copy link
Member Author

Looks good, but question for my understanding, why couldn't we give the machine user permission for the charts that it doesn't own?

I think we'd need to add the machine user as an owner to all the charts in order to do that, which would require hooks for new charts, and could potentially be confusing to the user (why is "machine" also an owner of my chart?). It would also allow the machine user to delete or modify charts, while with the approach in this PR we only let it update query_context.

stevenuray pushed a commit to preset-io/superset that referenced this pull request Aug 13, 2021
amitmiran137 pushed a commit that referenced this pull request Aug 16, 2021
…gies

* upstream/master: (64 commits)
  check roles before fetching reports (#16260)
  chore: upgrade mypy and add type guards (#16227)
  fix: pivot columns with ints for name (#16259)
  chore(pylint): Bump Pylint to 2.9.6 (#16146)
  fix examples tab for dashboard (#16253)
  chore: bump superset-ui packages to 0.17.84 (#16251)
  chore: Shows the dataset description in the gallery dropdown (#16200)
  fix(Dashboard): Omnibar dropdown visibility and keyboard commands (#16168)
  chore: bump py version for integration test (#16213)
  fix: skip perms on query context update (#16250)
  refactor: external metadata fetch API (#16193)
  feat(dao): admin can remove self from object owners (#15149)
  fix(dashboard): cross filter chart highlight when filters badge icon clicked (#16233)
  fix: validate_parameters and query (#16241)
  fix: Remove Advanced Analytics tag for 2 charts (#16240)
  Revert "feat: Changing Dataset names (#16199)" (#16235)
  feat: Allow users to connect via legacy SQLA form (#16201)
  fix: remove encryption from db params (#16214)
  fix(Explore): Show the tooltip only when label does not fit the container in METRICS/FILTERS/GROUP BY/SORT BY of the DATA panel (#16060)
  Show/hide tooltips (#16192)
  ...

# Conflicts:
#	superset/tasks/caching/cache_strategy.py
@eschutho eschutho added the v1.3 label Sep 14, 2021
@villebro villebro removed the v1.3 label Sep 22, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels need:merge The PR is ready to be merged preset:2021.31 size/S 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants