codeant-ai-for-open-source[bot] commented on code in PR #43491:
URL: https://github.com/apache/superset/pull/43491#discussion_r3865339009


##########
superset/utils/json.py:
##########
@@ -304,8 +304,11 @@ def reveal_sensitive(
         jsonpath_expr = parse(json_path)
         for match in jsonpath_expr.find(revealed_payload):
             if match.value == PASSWORD_MASK:
-                old_value = match.full_path.find(old_payload)
-                match.context.value[match.path.fields[0]] = old_value[0].value
+                # the old payload may not have a value to reveal, e.g. when a
+                # masked payload is submitted for a database that never stored
+                # the corresponding secret; keep the mask instead of crashing
+                if old_value := match.full_path.find(old_payload):
+                    match.context.value[match.path.fields[0]] = 
old_value[0].value

Review Comment:
   **Suggestion:** When the submitted payload contains `PASSWORD_MASK` but 
`old_payload` has no corresponding value, this branch leaves the sentinel in 
the returned configuration. The database update/import path persists that 
result directly, and `Database.get_oauth2_config()` then treats `XXXXXXXXXX` as 
the OAuth2 client secret, causing authentication failures instead of requiring 
a real secret or omitting the incomplete OAuth2 configuration. Reject this case 
or remove the masked field before persistence. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ OAuth2 database connections can persist unusable client secrets.
   - ❌ OAuth2 authentication fails after masked updates or imports.
   - ⚠️ Existing-database imports bypass new-database mask validation.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6b925444b041405fa23a1e06a3f8e373&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6b925444b041405fa23a1e06a3f8e373&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/json.py
   **Line:** 307:311
   **Comment:**
        *Logic Error: When the submitted payload contains `PASSWORD_MASK` but 
`old_payload` has no corresponding value, this branch leaves the sentinel in 
the returned configuration. The database update/import path persists that 
result directly, and `Database.get_oauth2_config()` then treats `XXXXXXXXXX` as 
the OAuth2 client secret, causing authentication failures instead of requiring 
a real secret or omitting the incomplete OAuth2 configuration. Reject this case 
or remove the masked field before persistence.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43491&comment_hash=3d41524b3f5bf25a5b5670ece3e8d0223fd2d286c43d36bff356750d79cb799f&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43491&comment_hash=3d41524b3f5bf25a5b5670ece3e8d0223fd2d286c43d36bff356750d79cb799f&reaction=dislike'>👎</a>



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