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

chore(key-value): use json serialization for main resources #23888

Merged
merged 9 commits into from
May 4, 2023

Conversation

villebro
Copy link
Member

@villebro villebro commented May 1, 2023

SUMMARY

Since the permalink and app resources were already using simple primitive types that serialize well with json.dumps, we don't really need to use pickle to serialize them. Therefore, to simplify the main key-value resources, we replace pickle with json where applicable. However, the metastore cache will still use pickle, as it needs to be able to handle arbitrary binary types. This should be ok, as it's opt-in, so it won't be enabled by default.

To test this permalinks were created on master branch, the branch checked out, the database migrated, and the permalinks validated to work as before.

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

@villebro villebro requested a review from a team as a code owner May 1, 2023 10:23
@codecov
Copy link

codecov bot commented May 1, 2023

Codecov Report

Merging #23888 (a4c8202) into master (3528f41) will decrease coverage by 1.76%.
The diff coverage is 97.10%.

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

@@            Coverage Diff             @@
##           master   #23888      +/-   ##
==========================================
- Coverage   68.10%   66.35%   -1.76%     
==========================================
  Files        1940     1940              
  Lines       75016    75057      +41     
  Branches     8154     8155       +1     
==========================================
- Hits        51092    49803    -1289     
- Misses      21841    23171    +1330     
  Partials     2083     2083              
Flag Coverage Δ
hive ?
mysql 78.82% <97.05%> (+0.01%) ⬆️
postgres 78.90% <97.05%> (+0.01%) ⬆️
presto ?
python 79.03% <97.05%> (-3.65%) ⬇️
sqlite 77.42% <97.05%> (+0.01%) ⬆️
unit ?

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

Impacted Files Coverage Δ
...nd/src/explore/components/RunQueryButton/index.tsx 100.00% <ø> (ø)
superset/dashboards/permalink/commands/create.py 92.85% <ø> (ø)
superset/explore/permalink/commands/create.py 90.90% <ø> (ø)
superset/explore/permalink/commands/get.py 91.42% <ø> (ø)
superset/key_value/types.py 95.12% <90.90%> (-4.88%) ⬇️
...c/SqlLab/components/RunQueryActionButton/index.tsx 79.41% <100.00%> (+0.62%) ⬆️
superset/dashboards/permalink/commands/base.py 100.00% <100.00%> (ø)
superset/dashboards/permalink/commands/get.py 81.25% <100.00%> (ø)
superset/explore/permalink/commands/base.py 100.00% <100.00%> (ø)
superset/extensions/metastore_cache.py 92.45% <100.00%> (-5.63%) ⬇️
... and 8 more

... and 90 files with indirect coverage changes

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

@dpgaspar dpgaspar added the 2.1.1 label May 2, 2023
@dpgaspar dpgaspar requested a review from eschutho May 2, 2023 10:26
@villebro villebro force-pushed the villebro/key-value-codec branch 5 times, most recently from 819307c to fe91c72 Compare May 3, 2023 11:59
Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM

assert entry.created_by_fk == admin.id
db.session.delete(entry)
db.session.commit()


def test_create_fail_json_entry(app_context: AppContext, admin: User) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

Nice tests

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

really cool solution!

@villebro villebro merged commit f1fa1a7 into apache:master May 4, 2023
@villebro villebro deleted the villebro/key-value-codec branch May 4, 2023 05:04
@eschutho eschutho added the v2.1 label May 12, 2023
eschutho pushed a commit to preset-io/superset that referenced this pull request May 23, 2023
eschutho pushed a commit that referenced this pull request May 23, 2023
eschutho pushed a commit that referenced this pull request May 25, 2023
@villebro villebro added the 2.1.1 label Jun 21, 2023
@eschutho eschutho added the v2.1 label Jul 11, 2023
@vin01
Copy link
Contributor

vin01 commented Sep 8, 2023

It makes me sad that people are getting CVEs for stuff like this and even trying to fly it as a "RCE". 😞

An attacker with write access to the metadata database can insert an arbitrary pickle payload into the store, and then trigger deserialization of it, leading to remote code execution.

With write access to the metadata database, I don't think any further steps are needed to compromise anything here. Such CVEs should be outright rejected.

@mistercrunch mistercrunch added 🏷️ 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
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/L 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants