codeant-ai-for-open-source[bot] commented on code in PR #40670: URL: https://github.com/apache/superset/pull/40670#discussion_r3401896496
########## tests/unit_tests/security/test_password_complexity.py: ########## @@ -0,0 +1,97 @@ +# 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. + +import pytest +from flask import current_app +from flask_appbuilder.exceptions import PasswordComplexityValidationError + +from superset.security.password_complexity import validate_password_complexity + + +def test_validate_password_complexity_accepts_strong_password() -> None: + # No exception for a sufficiently long, uncommon password. + validate_password_complexity("a-Good-Long-Passphrase-42") + + +def test_validate_password_complexity_rejects_short_password() -> None: Review Comment: **Suggestion:** Add a short docstring under this function definition to describe the short-password rejection scenario. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This newly introduced function is missing a docstring in the final file state. That matches the rule requiring newly added Python functions to be documented inline. </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1ff33295fd6540bdb67fd6ed3985e545&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1ff33295fd6540bdb67fd6ed3985e545&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/security/test_password_complexity.py **Line:** 30:30 **Comment:** *Custom Rule: Add a short docstring under this function definition to describe the short-password rejection scenario. 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%2F40670&comment_hash=70ccad604bd37b403f55480cf48f08b52b9af8f4f45fe92efc5fd653f2074de0&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40670&comment_hash=70ccad604bd37b403f55480cf48f08b52b9af8f4f45fe92efc5fd653f2074de0&reaction=dislike'>👎</a> ########## tests/unit_tests/security/test_password_complexity.py: ########## @@ -0,0 +1,97 @@ +# 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. + +import pytest +from flask import current_app +from flask_appbuilder.exceptions import PasswordComplexityValidationError + +from superset.security.password_complexity import validate_password_complexity + + +def test_validate_password_complexity_accepts_strong_password() -> None: Review Comment: **Suggestion:** Add a concise docstring to this new test function describing the expected behavior it validates. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This is a newly added Python test function in a new file, and it has no docstring. The custom rule requires newly added Python functions and classes to include inline docstrings, so the suggestion identifies a real violation. </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=52693464bff247108bff94ba2bb56393&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=52693464bff247108bff94ba2bb56393&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/security/test_password_complexity.py **Line:** 25:25 **Comment:** *Custom Rule: Add a concise docstring to this new test function describing the expected behavior it validates. 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%2F40670&comment_hash=0f74fa265014181198886a18617da20a7f97d63e5b4b54c5957de15683110150&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40670&comment_hash=0f74fa265014181198886a18617da20a7f97d63e5b4b54c5957de15683110150&reaction=dislike'>👎</a> ########## tests/unit_tests/security/test_password_complexity.py: ########## @@ -0,0 +1,97 @@ +# 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. + +import pytest +from flask import current_app +from flask_appbuilder.exceptions import PasswordComplexityValidationError + +from superset.security.password_complexity import validate_password_complexity + + +def test_validate_password_complexity_accepts_strong_password() -> None: + # No exception for a sufficiently long, uncommon password. + validate_password_complexity("a-Good-Long-Passphrase-42") + + +def test_validate_password_complexity_rejects_short_password() -> None: + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("short1") # < 8 chars + + +def test_validate_password_complexity_rejects_common_password() -> None: Review Comment: **Suggestion:** Add a docstring to this test function to explain that it verifies common-password blocking and case-insensitive handling. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> The function is newly added and does not have a docstring. This is a direct match for the custom rule about documenting new Python functions and classes. </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=49e3ac420b5446979ff0ca75c5f9e655&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=49e3ac420b5446979ff0ca75c5f9e655&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/security/test_password_complexity.py **Line:** 35:35 **Comment:** *Custom Rule: Add a docstring to this test function to explain that it verifies common-password blocking and case-insensitive handling. 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%2F40670&comment_hash=855e331d3b09b35451e369e9656984cedc3d8fc4b1dc4bfae00ef8a415271c22&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40670&comment_hash=855e331d3b09b35451e369e9656984cedc3d8fc4b1dc4bfae00ef8a415271c22&reaction=dislike'>👎</a> ########## tests/unit_tests/security/test_password_complexity.py: ########## @@ -0,0 +1,97 @@ +# 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. + +import pytest +from flask import current_app +from flask_appbuilder.exceptions import PasswordComplexityValidationError + +from superset.security.password_complexity import validate_password_complexity + + +def test_validate_password_complexity_accepts_strong_password() -> None: + # No exception for a sufficiently long, uncommon password. + validate_password_complexity("a-Good-Long-Passphrase-42") + + +def test_validate_password_complexity_rejects_short_password() -> None: + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("short1") # < 8 chars + + +def test_validate_password_complexity_rejects_common_password() -> None: + # Common even though length >= 8. + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("password123") + # Case-insensitive. + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("PASSWORD123") + + +def test_validate_password_complexity_honors_configured_min_length() -> None: + original = current_app.config.get("AUTH_PASSWORD_MIN_LENGTH") + current_app.config["AUTH_PASSWORD_MIN_LENGTH"] = 16 + try: + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("only12chars!") # 12 < 16 + finally: + current_app.config["AUTH_PASSWORD_MIN_LENGTH"] = original + + +def test_validate_password_complexity_honors_extra_blocklist() -> None: Review Comment: **Suggestion:** Add a short docstring to this test function indicating it checks custom blocklist enforcement. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This function is newly added and has no docstring. That is a valid instance of the custom rule violation requiring new Python functions to be documented inline. </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=83315805588f440b8e63076370689742&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=83315805588f440b8e63076370689742&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/security/test_password_complexity.py **Line:** 54:54 **Comment:** *Custom Rule: Add a short docstring to this test function indicating it checks custom blocklist enforcement. 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%2F40670&comment_hash=95beb52ad90f786d3bfdfd9d2786a6ddcccbffcc4cb31aef04e639dadcb7608d&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40670&comment_hash=95beb52ad90f786d3bfdfd9d2786a6ddcccbffcc4cb31aef04e639dadcb7608d&reaction=dislike'>👎</a> ########## tests/unit_tests/security/test_password_complexity.py: ########## @@ -0,0 +1,97 @@ +# 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. + +import pytest +from flask import current_app +from flask_appbuilder.exceptions import PasswordComplexityValidationError + +from superset.security.password_complexity import validate_password_complexity + + +def test_validate_password_complexity_accepts_strong_password() -> None: + # No exception for a sufficiently long, uncommon password. + validate_password_complexity("a-Good-Long-Passphrase-42") + + +def test_validate_password_complexity_rejects_short_password() -> None: + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("short1") # < 8 chars + + +def test_validate_password_complexity_rejects_common_password() -> None: + # Common even though length >= 8. + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("password123") + # Case-insensitive. + with pytest.raises(PasswordComplexityValidationError): + validate_password_complexity("PASSWORD123") + + +def test_validate_password_complexity_honors_configured_min_length() -> None: Review Comment: **Suggestion:** Add an inline docstring to this function describing that it validates behavior with a configured minimum length. [custom_rule] **Severity Level:** Minor ⚠️ <details> <summary><b>Why it matters? 🤔 </b></summary> This new test function lacks an inline docstring in the final file state. The suggestion correctly points out a real violation of the docstring rule. </details> [Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=fc9ed3404c3346b49c4be2e3260b5a4a&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=fc9ed3404c3346b49c4be2e3260b5a4a&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/security/test_password_complexity.py **Line:** 44:44 **Comment:** *Custom Rule: Add an inline docstring to this function describing that it validates behavior with a configured minimum length. 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%2F40670&comment_hash=2744325b10f08d77af7f93c42f41b17407b072e43e4b948ffbae6fb540729576&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F40670&comment_hash=2744325b10f08d77af7f93c42f41b17407b072e43e4b948ffbae6fb540729576&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]
