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: load examples as anon user #23600

Merged
merged 1 commit into from
Apr 6, 2023
Merged

fix: load examples as anon user #23600

merged 1 commit into from
Apr 6, 2023

Conversation

betodealmeida
Copy link
Member

SUMMARY

In #23200 I added permission checks when importing related assets. Before, users importing dashboards could create databases and datasets as a side effect of the import, even if they didn't have the appropriate permissions. The PR added some extra checks to prevent this from happening:

can_write = security_manager.can_access("can_write", "Database")

The change above required modifying load-examples to run as a user with username "admin":

with override_user(security_manager.find_user(username="admin")):

But the user "admin" might not exist, or might be called differently. So this PR changes load-examples so that the imports happen without a current_user, as before, while keeping the permission checks for other imports initiated via the UI.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

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 Apr 5, 2023

Codecov Report

Merging #23600 (daabdbe) into master (56dcf25) will increase coverage by 0.00%.
The diff coverage is 40.00%.

❗ Current head daabdbe differs from pull request most recent head 1609593. Consider uploading reports for the commit 1609593 to get more accurate results

@@           Coverage Diff           @@
##           master   #23600   +/-   ##
=======================================
  Coverage   67.72%   67.72%           
=======================================
  Files        1916     1916           
  Lines       74051    74050    -1     
  Branches     8040     8040           
=======================================
  Hits        50153    50153           
+ Misses      21850    21849    -1     
  Partials     2048     2048           
Flag Coverage Δ
hive 52.75% <0.00%> (+<0.01%) ⬆️
mysql 78.49% <40.00%> (+<0.01%) ⬆️
postgres 78.57% <40.00%> (+<0.01%) ⬆️
presto 52.68% <0.00%> (+<0.01%) ⬆️
python 82.42% <40.00%> (+<0.01%) ⬆️
sqlite 77.07% <40.00%> (+<0.01%) ⬆️
unit 52.65% <40.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
superset/commands/importers/v1/examples.py 0.00% <0.00%> (ø)
superset/charts/commands/importers/v1/utils.py 100.00% <100.00%> (ø)
superset/dashboards/commands/importers/v1/utils.py 85.00% <100.00%> (ø)
superset/databases/commands/importers/v1/utils.py 100.00% <100.00%> (ø)
superset/datasets/commands/importers/v1/utils.py 78.64% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

LGTM!

@betodealmeida betodealmeida merged commit f787981 into master Apr 6, 2023
jinghua-qa pushed a commit to preset-io/superset that referenced this pull request Apr 10, 2023
eschutho pushed a commit that referenced this pull request Jun 8, 2023
eschutho pushed a commit that referenced this pull request Jun 13, 2023
@mistercrunch mistercrunch added 🍒 2.1.1 🍒 2.1.2 🍒 2.1.3 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 2024
@mistercrunch mistercrunch deleted the sc-69055 branch March 26, 2024 18:04
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 size/M 🍒 2.1.1 🍒 2.1.2 🍒 2.1.3 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants