codeant-ai-for-open-source[bot] commented on code in PR #39469:
URL: https://github.com/apache/superset/pull/39469#discussion_r3502729900
##########
superset/security/password_change.py:
##########
@@ -62,7 +62,18 @@
)
# Exact endpoint names (function views / Flask built-ins) that are always
exempt.
-_EXEMPT_ENDPOINTS = frozenset({"static", "appbuilder.static", "health",
"healthcheck"})
+_EXEMPT_ENDPOINTS = frozenset(
+ {
+ "static",
+ "appbuilder.static",
+ "health",
+ "healthcheck",
+ # Self-service password change API (AUTH_DB); must stay reachable while
+ # ``password_must_change`` is set, same as ``ResetMyPasswordView``.
+ "CurrentUserRestApi.update_my_password",
+ "CurrentUserRestApi.get_my_password_policy",
+ }
+)
Review Comment:
**Suggestion:** Add an explicit type annotation to `_EXEMPT_ENDPOINTS` so
this newly introduced module-level variable complies with the required Python
type-hinting rule. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly added module-level variable in Python code, and it is not
annotated with a type hint. That matches the stated rule requiring type hints
for relevant new or modified variables that can be annotated.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1a15b44a4acd4204a38844251c7ad204&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1a15b44a4acd4204a38844251c7ad204&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:** superset/security/password_change.py
**Line:** 65:76
**Comment:**
*Custom Rule: Add an explicit type annotation to `_EXEMPT_ENDPOINTS` so
this newly introduced module-level variable complies with the required Python
type-hinting rule.
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%2F39469&comment_hash=7414a4afdf0d3ecc92bb2469e93e650e1592c24fdb320fd44027f97faf42d6e5&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=7414a4afdf0d3ecc92bb2469e93e650e1592c24fdb320fd44027f97faf42d6e5&reaction=dislike'>👎</a>
##########
superset/utils/auth_db_password_hash.py:
##########
@@ -0,0 +1,94 @@
+# 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.
+"""Hash and verify AUTH_DB passwords using bcrypt or argon2."""
+
+from __future__ import annotations
+
+import re
+
+import bcrypt
+from argon2 import PasswordHasher
+from argon2.exceptions import InvalidHash, VerifyMismatchError
+from werkzeug.security import check_password_hash
+
+from superset.utils.auth_db_password import (
+ BCRYPT_MAX_PASSWORD_BYTES,
+ get_auth_db_password_hash_algorithm,
+)
+
+_BCRYPT_HASH_RE = re.compile(r"^\$2[aby]\$\d{2}\$")
Review Comment:
**Suggestion:** Add an explicit type annotation to this module-level regex
constant to satisfy the type-hint requirement for relevant variables.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This new module-level variable is assigned a regex object but has no
explicit type hint. The custom rule requires type hints for relevant variables
that can be annotated, so this is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=7b209b7fd1a14109a26f0de195cc226f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=7b209b7fd1a14109a26f0de195cc226f&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:** superset/utils/auth_db_password_hash.py
**Line:** 33:33
**Comment:**
*Custom Rule: Add an explicit type annotation to this module-level
regex constant to satisfy the type-hint requirement for relevant variables.
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%2F39469&comment_hash=9bde5b725829c2333fe79ad1460c769ba2db9bf071a8a81fc67b45295248ef2f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=9bde5b725829c2333fe79ad1460c769ba2db9bf071a8a81fc67b45295248ef2f&reaction=dislike'>👎</a>
##########
superset/utils/auth_db_password_hash.py:
##########
@@ -0,0 +1,94 @@
+# 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.
+"""Hash and verify AUTH_DB passwords using bcrypt or argon2."""
+
+from __future__ import annotations
+
+import re
+
+import bcrypt
+from argon2 import PasswordHasher
+from argon2.exceptions import InvalidHash, VerifyMismatchError
+from werkzeug.security import check_password_hash
+
+from superset.utils.auth_db_password import (
+ BCRYPT_MAX_PASSWORD_BYTES,
+ get_auth_db_password_hash_algorithm,
+)
+
+_BCRYPT_HASH_RE = re.compile(r"^\$2[aby]\$\d{2}\$")
+_ARGON2_HASH_PREFIX = "$argon2"
Review Comment:
**Suggestion:** Add an explicit type annotation to this module-level
constant so new relevant variables consistently include type hints.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This module-level string constant is newly added and lacks a type
annotation. Because it can be annotated and the rule explicitly requires type
hints for relevant variables, the suggestion identifies a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=b221a34343744f9c8029744903999391&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=b221a34343744f9c8029744903999391&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:** superset/utils/auth_db_password_hash.py
**Line:** 34:34
**Comment:**
*Custom Rule: Add an explicit type annotation to this module-level
constant so new relevant variables consistently include type hints.
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%2F39469&comment_hash=22ceb664f5f33e449b687562e60b23b3f87c86610da25f972e439aef105efd33&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39469&comment_hash=22ceb664f5f33e449b687562e60b23b3f87c86610da25f972e439aef105efd33&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]