rusackas commented on code in PR #42803:
URL: https://github.com/apache/superset/pull/42803#discussion_r3737914746


##########
superset/models/core.py:
##########
@@ -708,7 +714,14 @@ def _get_sqla_engine(  # pylint: disable=too-many-locals  
# noqa: C901
         if cacheable and self.id is not None:
             cache_key = (
                 self.id,
-                str(sqlalchemy_url),
+                # SQLAlchemy 2.0 changed str(URL) to always substitute
+                # "***" for the password rather than rendering the real
+                # value (str(url) under 1.4). Using it here would make
+                # the cache key blind to password rotation - the module
+                # comment above depends on the key changing when the
+                # password does, so render_as_string(hide_password=False)
+                # is required to preserve that behavior.
+                sqlalchemy_url.render_as_string(hide_password=False),

Review Comment:
   This isn't new here, it's restoring pre-existing behavior: under SQLAlchemy 
1.4, `str(sqlalchemy_url)` already rendered the real password, so the cache key 
has always included it. 2.0 changed `str(URL)` to mask to `***` 
unconditionally, which would've silently broken password-rotation cache 
invalidation (the whole point of keying on the URL string), so this PR had to 
switch to `render_as_string(hide_password=False)` to keep that working.
   
   Also, hashing the key wouldn't actually reduce plaintext credential 
retention in this cache: the cached *value* is the `Engine` object itself, and 
`engine.url` holds the real unmasked password regardless of what we use as the 
key. So there's no net reduction in exposure, just a less debuggable cache key. 
Leaving this as-is.



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

Reply via email to