codeant-ai-for-open-source[bot] commented on code in PR #43474: URL: https://github.com/apache/superset/pull/43474#discussion_r3845836631
########## superset/semantic_layers/api.py: ########## @@ -81,10 +81,44 @@ logger = logging.getLogger(__name__) +def _mask_configuration(layer: SemanticLayer, config: dict[str, Any]) -> dict[str, Any]: + """ + Redact configuration values the connector's schema marks as write-only. + + A connector publishes its configuration shape via ``get_configuration_schema``; + a property with ``"writeOnly": true`` (the standard JSON Schema way of + marking a field that's set but never echoed back, e.g. a password or API + key) is replaced with ``PASSWORD_MASK`` here rather than returned in the + clear. + """ + cls = registry.get(layer.type) + if not cls: + return config + + try: + schema = cls.get_configuration_schema() + except Exception: # pylint: disable=broad-except + return config Review Comment: **Suggestion:** When `get_configuration_schema()` raises, this returns the unmasked configuration. A connector metadata or connection failure can therefore expose stored passwords or API keys through both `get` and `get_list`; masking must fail closed or the endpoint must avoid returning the configuration when the schema cannot be loaded. [security] <details> <summary><b>Severity Level:</b> Critical 🚨</summary> ```mdx - ❌ GET semantic-layer endpoints can disclose stored credentials. - ❌ Connector metadata or connection failures bypass credential masking. - ⚠️ Disclosure affects both single-layer and list responses. ``` </details> [](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=5ac12e6f599f469b82ec1da997ee36da&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=5ac12e6f599f469b82ec1da997ee36da&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/semantic_layers/api.py **Line:** 100:101 **Comment:** *Security: When `get_configuration_schema()` raises, this returns the unmasked configuration. A connector metadata or connection failure can therefore expose stored passwords or API keys through both `get` and `get_list`; masking must fail closed or the endpoint must avoid returning the configuration when the schema cannot be loaded. 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%2F43474&comment_hash=42ab21c7f824390206673fad1729a624003e01af888e73c4826d504f1efb2627&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43474&comment_hash=42ab21c7f824390206673fad1729a624003e01af888e73c4826d504f1efb2627&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]
