geido commented on code in PR #45068:
URL: https://github.com/apache/superset/pull/45068#discussion_r4412992862


##########
superset/utils/json.py:
##########
@@ -362,6 +367,32 @@ def get_masked_fields(
     return masked
 
 
+def unrevealable_masked_fields(
+    old_payload: dict[str, Any] | None,
+    new_payload: dict[str, Any],
+    sensitive_fields: set[str],
+) -> list[str]:
+    """
+    Returns masked fields in ``new_payload`` that ``old_payload`` cannot 
reveal.
+
+    :func:`reveal_sensitive` swaps a mask back for the stored value at the same
+    path. Where the stored payload has no value there, the mask would be kept 
and
+    stored as if it were the secret, so callers that must not do that (imports
+    overwriting a connection) use this to ask for the real value instead.
+
+    :param old_payload: The stored payload, if any
+    :param new_payload: The incoming payload, possibly containing masks
+    :param sensitive_fields: The set of fields to check, as JSONPath 
expressions
+    :returns: JSONPath expressions for masked fields with nothing to reveal
+    """
+    return [
+        field
+        for field in get_masked_fields(new_payload, sensitive_fields)
+        if old_payload is None
+        or not any(match.value for match in parse(field).find(old_payload))

Review Comment:
   I think a stored mask slips through here. master saves `XXXXXXXXXX` when an 
overwrite import can't reveal a secret; this counts it as revealable, so the 
schema asks for nothing and the backstop in `import_database` 500s with no 
field to enter it. Could a stored `PASSWORD_MASK` count as missing, so the 
normal prompt shows? I hit it re-importing a bundle right after upgrading from 
master.
   
   Same local instance before and after upgrading (flags off):
   
   
https://github.com/user-attachments/assets/e0cf0760-a461-46f6-8366-d5afc513734e



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