bito-code-review[bot] commented on code in PR #40654:
URL: https://github.com/apache/superset/pull/40654#discussion_r3339153564
##########
superset/cli/update.py:
##########
@@ -110,17 +110,37 @@ def update_api_docs() -> None:
help="An optional previous secret key, if PREVIOUS_SECRET_KEY "
"is not set on the config",
)
-def re_encrypt_secrets(previous_secret_key: Optional[str] = None) -> None:
[email protected](
+ "--engine",
+ "-e",
+ "target_engine_name",
+ required=False,
+ type=click.Choice(sorted(ENCRYPTION_ENGINES)),
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-20: Case-Sensitive Choice Validation</b></div>
<div id="fix">
`click.Choice` defaults to `case_sensitive=True` in Click 8.x. The engine
keys in `ENCRYPTION_ENGINES` are lowercase (`aes`, `aes-gcm`) and the help text
shows lowercase examples. A user who runs `--engine=AES-GCM` (or any mixed
case) will get a `UsageError` instead of a helpful message. Adding
`case_sensitive=False` makes Click normalize the input before matching against
the known choices. ([CWE-20](https://cwe.mitre.org/data/definitions/20.html))
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- superset/cli/update.py
+++ superset/cli/update.py
@@ -115,7 +115,7 @@
"target_engine_name",
required=False,
- type=click.Choice(sorted(ENCRYPTION_ENGINES)),
+ type=click.Choice(sorted(ENCRYPTION_ENGINES), case_sensitive=False),
help="Re-encrypt all app-encrypted fields with this encryption engine "
"(e.g. 'aes-gcm' for authenticated encryption). The SECRET_KEY is "
"unchanged. Take a metadata-DB backup first, then set "
```
</div>
</details>
</div>
<small><i>Code Review Run #a466b5</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]