codeant-ai-for-open-source[bot] commented on code in PR #45890:
URL: https://github.com/apache/superset/pull/45890#discussion_r4444568271
##########
superset/databases/schemas.py:
##########
@@ -1146,25 +1236,37 @@ def validate_masked_encrypted_extra(
"File contains both `encrypted_extra` and
`masked_encrypted_extra`"
)
- if db.session.query(Database).filter_by(uuid=data["uuid"]).first():
- # Existing DB: sensitive values will be revealed from existing
- # encrypted_extra in import_database()
- return
-
masked_encrypted_extra = json.loads(data["masked_encrypted_extra"])
- # Determine engine spec from sqlalchemy_uri to get sensitive fields
- sqlalchemy_uri = data["sqlalchemy_uri"]
- url = make_url_safe(sqlalchemy_uri)
- backend = url.get_backend_name()
- driver = url.get_driver_name()
- db_engine_spec = get_engine_spec(backend, driver=driver)
-
- # Check if any sensitive field is still masked
- masked_fields = get_masked_fields(
- masked_encrypted_extra,
- db_engine_spec.encrypted_extra_sensitive_field_paths(),
- )
+ if existing :=
db.session.query(Database).filter_by(uuid=data["uuid"]).first():
+ if not self.overwrites_existing:
+ return
+ # Existing DB: masked values are revealed from its stored
+ # encrypted_extra in import_database(). Any the stored payload has
no
+ # value for -- e.g. a connection promoted without its OAuth2
client or
+ # embedded credential -- would otherwise be stored as the mask
itself,
+ # so ask for those like a new DB.
+ db_engine_spec = existing.db_engine_spec
+ masked_fields = json.unrevealable_masked_fields(
+ json.loads(existing.encrypted_extra)
+ if existing.encrypted_extra
+ else None,
+ masked_encrypted_extra,
+ db_engine_spec.encrypted_extra_sensitive_field_paths(),
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `c71591e`.
The validator now passes `None` as the old payload when
`import_connection_identity_changed(existing, data)` is true, so masks must be
supplied for the changed connection.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]