You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/30 01:29:14 UTC

[GitHub] [superset] betodealmeida opened a new pull request, #21248: feat: filter parameters from DB API

betodealmeida opened a new pull request, #21248:
URL: https://github.com/apache/superset/pull/21248

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   Filter out some of the parameters from the database connection in the API.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] 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


[GitHub] [superset] dpgaspar commented on a diff in pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
dpgaspar commented on code in PR #21248:
URL: https://github.com/apache/superset/pull/21248#discussion_r958177243


##########
superset/db_engine_specs/bigquery.py:
##########
@@ -380,18 +381,47 @@ def build_sqlalchemy_uri(
 
     @classmethod
     def get_parameters_from_uri(
-        cls, uri: str, encrypted_extra: Optional[Dict[str, str]] = None
+        cls,
+        uri: str,
+        encrypted_extra: Optional[Dict[str, Any]] = None,
     ) -> Any:
         value = make_url_safe(uri)
 
         # Building parameters from encrypted_extra and uri
         if encrypted_extra:
+            try:
+                encrypted_extra["credentials_info"]["private_key"] = PASSWORD_MASK
+            except KeyError:
+                pass
+
             # ``value.query`` needs to be explicitly converted into a dict (from an
             # ``immutabledict``) so that it can be JSON serialized
             return {**encrypted_extra, "query": dict(value.query)}
 
         raise ValidationError("Invalid service credentials")
 
+    @classmethod
+    def update_encrypted_extra(

Review Comment:
   What do you think about adding a unit test to bigquery and gsheets. An actual test for this has an integration test for the API would be nice also



-- 
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


[GitHub] [superset] github-actions[bot] commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235808697

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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


[GitHub] [superset] jinghua-qa commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
jinghua-qa commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235672071

   for the skip test, do we have a plan to get it fix and re-enable?


-- 
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


[GitHub] [superset] betodealmeida commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
betodealmeida commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235713600

   > for the skip test, do we have a plan to get it fix and re-enable?
   
   I'm not sure why these were timing out, they are unrelated to this PR. I need to take a better look.


-- 
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


[GitHub] [superset] github-actions[bot] commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1231196356

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


-- 
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


[GitHub] [superset] betodealmeida commented on a diff in pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
betodealmeida commented on code in PR #21248:
URL: https://github.com/apache/superset/pull/21248#discussion_r958569084


##########
superset/db_engine_specs/bigquery.py:
##########
@@ -380,18 +381,47 @@ def build_sqlalchemy_uri(
 
     @classmethod
     def get_parameters_from_uri(
-        cls, uri: str, encrypted_extra: Optional[Dict[str, str]] = None
+        cls,
+        uri: str,
+        encrypted_extra: Optional[Dict[str, Any]] = None,
     ) -> Any:
         value = make_url_safe(uri)
 
         # Building parameters from encrypted_extra and uri
         if encrypted_extra:
+            try:
+                encrypted_extra["credentials_info"]["private_key"] = PASSWORD_MASK
+            except KeyError:
+                pass
+
             # ``value.query`` needs to be explicitly converted into a dict (from an
             # ``immutabledict``) so that it can be JSON serialized
             return {**encrypted_extra, "query": dict(value.query)}
 
         raise ValidationError("Invalid service credentials")
 
+    @classmethod
+    def update_encrypted_extra(

Review Comment:
   Working on 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


[GitHub] [superset] yousoph commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
yousoph commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1231189906

   /testenv up


-- 
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


[GitHub] [superset] sadpandajoe commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
sadpandajoe commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235839517

   🏷️ preset:2022.33


-- 
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


[GitHub] [superset] jinghua-qa commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
jinghua-qa commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235712565

   /testenv up


-- 
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


[GitHub] [superset] betodealmeida commented on a diff in pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
betodealmeida commented on code in PR #21248:
URL: https://github.com/apache/superset/pull/21248#discussion_r957980670


##########
superset/models/core.py:
##########
@@ -339,14 +339,6 @@ def get_effective_user(self, object_url: URL) -> Optional[str]:
             else None
         )
 
-    @memoized(

Review Comment:
   This is not working for BigQuery, had to disable.



##########
superset/models/core.py:
##########
@@ -639,7 +631,6 @@ def db_engine_spec(self) -> Type[db_engine_specs.BaseEngineSpec]:
         return self.get_db_engine_spec(url)
 
     @classmethod
-    @memoized

Review Comment:
   Same here, not working for BigQuery.



-- 
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


[GitHub] [superset] github-actions[bot] commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1235750990

   @jinghua-qa Ephemeral environment spinning up at http://34.221.65.136:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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


[GitHub] [superset] betodealmeida merged pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
betodealmeida merged PR #21248:
URL: https://github.com/apache/superset/pull/21248


-- 
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


[GitHub] [superset] codecov[bot] commented on pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #21248:
URL: https://github.com/apache/superset/pull/21248#issuecomment-1231042472

   # [Codecov](https://codecov.io/gh/apache/superset/pull/21248?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21248](https://codecov.io/gh/apache/superset/pull/21248?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (943dabe) into [master](https://codecov.io/gh/apache/superset/commit/8772e2cdb3b5a500812e7df12c133f9c9f2e6bad?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (8772e2c) will **decrease** coverage by `11.42%`.
   > The diff coverage is `58.82%`.
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #21248       +/-   ##
   ===========================================
   - Coverage   66.43%   55.01%   -11.43%     
   ===========================================
     Files        1784     1784               
     Lines       68163    68195       +32     
     Branches     7264     7264               
   ===========================================
   - Hits        45285    37516     -7769     
   - Misses      21010    28811     +7801     
     Partials     1868     1868               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `53.02% <47.05%> (-0.01%)` | :arrow_down: |
   | postgres | `?` | |
   | presto | `52.92% <47.05%> (-0.01%)` | :arrow_down: |
   | python | `57.70% <58.82%> (-23.65%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `50.65% <58.82%> (+<0.01%)` | :arrow_up: |
   
   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=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/superset/pull/21248?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [superset/databases/api.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YWJhc2VzL2FwaS5weQ==) | `52.09% <ø> (-43.41%)` | :arrow_down: |
   | [superset/db\_engine\_specs/gsheets.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2dzaGVldHMucHk=) | `65.45% <30.00%> (-9.55%)` | :arrow_down: |
   | [superset/databases/dao.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YWJhc2VzL2Rhby5weQ==) | `69.76% <40.00%> (-30.24%)` | :arrow_down: |
   | [superset/db\_engine\_specs/bigquery.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2JpZ3F1ZXJ5LnB5) | `54.85% <70.00%> (-31.81%)` | :arrow_down: |
   | [superset/db\_engine\_specs/base.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL2Jhc2UucHk=) | `74.84% <75.00%> (-13.38%)` | :arrow_down: |
   | [superset/constants.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvY29uc3RhbnRzLnB5) | `100.00% <100.00%> (ø)` | |
   | [superset/databases/schemas.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YWJhc2VzL3NjaGVtYXMucHk=) | `81.33% <100.00%> (-16.90%)` | :arrow_down: |
   | [superset/db\_engine\_specs/snowflake.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lX3NwZWNzL3Nub3dmbGFrZS5weQ==) | `75.86% <100.00%> (+0.20%)` | :arrow_up: |
   | [superset/models/core.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvbW9kZWxzL2NvcmUucHk=) | `78.48% <100.00%> (-9.70%)` | :arrow_down: |
   | [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
   | ... and [289 more](https://codecov.io/gh/apache/superset/pull/21248/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
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


[GitHub] [superset] hughhhh commented on a diff in pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
hughhhh commented on code in PR #21248:
URL: https://github.com/apache/superset/pull/21248#discussion_r958921795


##########
superset/databases/dao.py:
##########
@@ -33,6 +34,25 @@ class DatabaseDAO(BaseDAO):
     model_cls = Database
     base_filter = DatabaseFilter
 
+    @classmethod
+    def update(
+        cls,
+        model: Database,
+        properties: Dict[str, Any],
+        commit: bool = True,
+    ) -> Database:
+        if "encrypted_extra" in properties:
+            new = json.loads(properties["encrypted_extra"])

Review Comment:
   shouldn't we have try/except here just incase we have malformed coming in from the modal?



-- 
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


[GitHub] [superset] betodealmeida commented on a diff in pull request #21248: feat: filter parameters from DB API

Posted by GitBox <gi...@apache.org>.
betodealmeida commented on code in PR #21248:
URL: https://github.com/apache/superset/pull/21248#discussion_r958923381


##########
superset/databases/dao.py:
##########
@@ -33,6 +34,25 @@ class DatabaseDAO(BaseDAO):
     model_cls = Database
     base_filter = DatabaseFilter
 
+    @classmethod
+    def update(
+        cls,
+        model: Database,
+        properties: Dict[str, Any],
+        commit: bool = True,
+    ) -> Database:
+        if "encrypted_extra" in properties:
+            new = json.loads(properties["encrypted_extra"])

Review Comment:
   Yeah, good point, that's safer. Let me add.



-- 
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