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


##########
tests/unit_tests/cli/test_db_test.py:
##########
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest.mock import patch
+
+from rich.console import Console
+
+from superset.cli.test_db import collect_connection_info
+from superset.commands.database.exceptions import DatabaseInvalidError
+
+
+def test_collect_connection_info_masking():
+    """Test that passwords are masked in CLI output."""
+    console = Console()
+    uri = "postgresql://user:pass@host/db"
+
+    with patch("builtins.input", return_value="n"):
+        # We need to mock sys.stdin.read because collect_connection_info might 
read it
+        with patch("sys.stdin.read", return_value="{}"):
+            with console.capture() as capture:
+                collect_connection_info(console, uri)
+
+            output = capture.get()
+            assert "user:pass@" not in output
+            assert "***" in output
+            assert "host" in output
+
+
+def test_collect_connection_info_malformed_uri():

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this new test 
function to satisfy the typing rule for newly added code. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This newly added function has no return type hint, which violates the rule 
that new Python code should be fully typed.
   </details>
   
   [![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=81f6fc1b62f64a28a88fca0f7c256319&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=81f6fc1b62f64a28a88fca0f7c256319&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/cli/test_db_test.py
   **Line:** 43:43
   **Comment:**
        *Custom Rule: Add an explicit return type annotation to this new test 
function to satisfy the typing rule for newly added code.
   
   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%2F38229&comment_hash=42a435f9888880c5d2bae47f907c7e63369f4d93372721a47558be67fa728a6c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38229&comment_hash=42a435f9888880c5d2bae47f907c7e63369f4d93372721a47558be67fa728a6c&reaction=dislike'>👎</a>



##########
tests/unit_tests/cli/test_db_test.py:
##########
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest.mock import patch
+
+from rich.console import Console
+
+from superset.cli.test_db import collect_connection_info
+from superset.commands.database.exceptions import DatabaseInvalidError
+
+
+def test_collect_connection_info_masking():

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this new test 
function so it is fully typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test function, and it omits a return type 
annotation. The rule requires new Python functions to be fully typed, including 
return values, so this is a real violation.
   </details>
   
   [![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=9adda975d3564fb9a7bd4061b4fb2763&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=9adda975d3564fb9a7bd4061b4fb2763&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/cli/test_db_test.py
   **Line:** 26:26
   **Comment:**
        *Custom Rule: Add an explicit return type annotation to this new test 
function so it is fully typed.
   
   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%2F38229&comment_hash=9727f22bdb6760e2ee818d1a27ce1a7c3a1cf1b284828bb9c34fe3a69ee4fd4c&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38229&comment_hash=9727f22bdb6760e2ee818d1a27ce1a7c3a1cf1b284828bb9c34fe3a69ee4fd4c&reaction=dislike'>👎</a>



##########
tests/unit_tests/cli/test_db_test.py:
##########
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from unittest.mock import patch
+
+from rich.console import Console
+
+from superset.cli.test_db import collect_connection_info
+from superset.commands.database.exceptions import DatabaseInvalidError
+
+
+def test_collect_connection_info_masking():
+    """Test that passwords are masked in CLI output."""
+    console = Console()
+    uri = "postgresql://user:pass@host/db"
+
+    with patch("builtins.input", return_value="n"):
+        # We need to mock sys.stdin.read because collect_connection_info might 
read it
+        with patch("sys.stdin.read", return_value="{}"):
+            with console.capture() as capture:
+                collect_connection_info(console, uri)
+
+            output = capture.get()
+            assert "user:pass@" not in output
+            assert "***" in output
+            assert "host" in output
+
+
+def test_collect_connection_info_malformed_uri():
+    """Test that malformed URIs are handled gracefully in CLI output."""
+    console = Console()
+    uri = "not-a-valid-uri"
+
+    with patch("builtins.input", return_value="n"):
+        with console.capture() as capture:
+            info = collect_connection_info(console, uri)
+
+        output = capture.get()
+        assert "<invalid database URI>" in output
+        assert info == {}
+
+
+def test_collect_connection_info_database_invalid_error():

Review Comment:
   **Suggestion:** Add an explicit return type annotation to this new test 
function so the function signature is fully typed. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is another newly introduced Python test function without a return type 
annotation. That matches the custom typing rule violation for new code.
   </details>
   
   [![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=9937070d4e9d4f7ebf144c4bc8da783f&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=9937070d4e9d4f7ebf144c4bc8da783f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/cli/test_db_test.py
   **Line:** 57:57
   **Comment:**
        *Custom Rule: Add an explicit return type annotation to this new test 
function so the function signature is fully typed.
   
   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%2F38229&comment_hash=ea320a838cc987655de2e2c7ddaa639a3033ea140bd68ce906acf1bb7656b680&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38229&comment_hash=ea320a838cc987655de2e2c7ddaa639a3033ea140bd68ce906acf1bb7656b680&reaction=dislike'>👎</a>



##########
tests/unit_tests/initialization_test.py:
##########
@@ -189,6 +189,29 @@ def test_database_uri_doesnt_cache_fallback_values(self):
             == "postgresql://realuser:realpass@realhost:5432/realdb"
         )
 
+    def test_check_and_warn_database_connection_masks_password(self):

Review Comment:
   **Suggestion:** Add full type annotations to this new test method signature, 
including an explicit return type. [custom_rule]
   
   **Severity Level:** Minor ⚠️
   <details>
   <summary><b>Why it matters? 🤔 </b></summary>
   
   This is a newly added Python test method and it has no type annotations on 
the `self` parameter or on the return type. The custom rule requires newly 
added Python code to be fully typed, so this is a real violation.
   </details>
   
   [![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=acde3c7123fc4c509b04c7908d15866b&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=acde3c7123fc4c509b04c7908d15866b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/unit_tests/initialization_test.py
   **Line:** 192:192
   **Comment:**
        *Custom Rule: Add full type annotations to this new test method 
signature, including an explicit return type.
   
   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%2F38229&comment_hash=7a750da999d177b4cde5253318f5d346f0820419d8c4dad41eea6bb9cda0764d&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38229&comment_hash=7a750da999d177b4cde5253318f5d346f0820419d8c4dad41eea6bb9cda0764d&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