You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "rusackas (via GitHub)" <gi...@apache.org> on 2026/08/24 17:18:05 UTC

[PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

rusackas opened a new pull request, #43474:
URL: https://github.com/apache/superset/pull/43474

   ### SUMMARY
   Two follow-ups on the semantic-layer/theme access-check work from #43389, for consistency:
   
   - `_serialize_layer`'s `configuration` blob is now passed through a masking step before it's returned. A connector publishes its configuration shape via `get_configuration_schema`; any property marked `"writeOnly": true` (the standard JSON Schema way of flagging a field that's set but never echoed back, e.g. a password or API key) gets replaced with the same `PASSWORD_MASK` used elsewhere in the codebase, rather than returned as-is.
   - `get_list`, `get`, and `runtime_schema` now carry the same `SEMANTIC_LAYERS` feature-flag guard that `structure`, `views`, and `delete` already have, so the flag gating is consistent across the whole API surface.
   
   Behavior is unchanged for connectors that don't mark any config field `writeOnly`.
   
   ### TESTING INSTRUCTIONS
   `pytest tests/unit_tests/semantic_layers/` — new unit tests for `_mask_configuration` (redacts marked fields, leaves unset/falsy values alone, no-ops when there's no registered connector or the schema can't be loaded) and for the three new feature-flag guards (both through the client and via direct unwrapped calls, matching the existing pattern for the other guarded endpoints).
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5398830962

   <!-- Bito Reply -->
   The security concern is valid. In the current implementation of `_mask_configuration`, if `get_configuration_schema()` raises an exception, the function catches it and returns the original, unmasked configuration. This means that if the schema cannot be loaded, the system fails open, potentially exposing sensitive credentials.
   
   To resolve this, the function should fail closed by raising an exception or returning an empty/masked configuration when the schema cannot be retrieved. Here is a corrected implementation:
   
   ```python
       try:
           schema = cls.get_configuration_schema()
       except Exception:
           # Fail closed: return an empty configuration or raise an error
           return {}
   ```
   
   I have checked the available PR comments, and there are no other pending review comments to address. Would you like me to proceed with any other changes?
   
   **superset/semantic_layers/api.py**
   ```
   try:
           schema = cls.get_configuration_schema()
       except Exception:
           # Fail closed: return an empty configuration or raise an error
           return {}
   ```


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3868592009


##########
superset/commands/semantic_layer/update.py:
##########
@@ -43,6 +44,57 @@
 logger = logging.getLogger(__name__)
 
 
+def _unmask_configuration(
+    sl_type: str,
+    existing_raw_configuration: str | None,
+    new_configuration: dict[str, Any],
+) -> dict[str, Any]:
+    """
+    Replace ``PASSWORD_MASK`` sentinels in write-only fields of an incoming
+    update payload with the value already stored.
+
+    The GET/list endpoints mask write-only configuration values (see
+    ``superset.semantic_layers.api._mask_configuration``); a client that
+    round-trips that response back on an update (e.g. a name-only edit)
+    would otherwise overwrite the real stored credential with the literal
+    mask string.
+    """
+    cls = registry.get(sl_type)
+    if not cls:
+        return new_configuration
+
+    try:
+        schema = cls.get_configuration_schema()
+    except Exception:  # pylint: disable=broad-except
+        return new_configuration
+
+    secret_keys = {
+        key
+        for key, prop in schema.get("properties", {}).items()
+        if isinstance(prop, dict) and prop.get("writeOnly")
+    }
+    if not secret_keys:
+        return new_configuration
+
+    try:
+        existing_configuration = (
+            json.loads(existing_raw_configuration) if existing_raw_configuration else {}
+        )
+    except (TypeError, ValueError):
+        existing_configuration = {}
+
+    return {
+        key: (
+            existing_configuration[key]
+            if key in secret_keys

Review Comment:
   If the schema was unavailable when the client read this layer, `_mask_configuration` replaces every truthy value, including non-secret settings. Once the schema is available here, this restores only write-only keys, so a name-only save can persist `XXXXXXXXXX` as values such as `account` or `database` and break the connection. Can the update path preserve all values that were masked by the fallback, or avoid returning a round-trippable masked configuration in that state?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5403055494

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5437629446

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3845849172


##########
superset/semantic_layers/api.py:
##########
@@ -677,6 +711,9 @@ def runtime_schema(self, uuid: str) -> FlaskResponse:
             404:
               $ref: '#/components/responses/404'
         """
+        if not is_feature_enabled("SEMANTIC_LAYERS"):

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Duplicate authorization check pattern</b></div>
   <div id="fix">
   
   Detected syntactic duplication (76 tokens across 14 lines) in superset/semantic_layers/api.py affecting lines 714-727 and 775-788. The authorization check pattern appears twice. Consider extracting the common logic into a helper method to reduce duplication and improve maintainability.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #124a5d</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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5399152920

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43474?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `20 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 66.08%. Comparing base ([`f3142e7`](https://app.codecov.io/gh/apache/superset/commit/f3142e7b15b77aace6b72dcdf1f96e9067d41474?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f67f6d8`](https://app.codecov.io/gh/apache/superset/commit/f67f6d80e614bc909e0fd87d62b0e2a881199b10?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 10 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43474?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/semantic\_layers/api.py](https://app.codecov.io/gh/apache/superset/pull/43474?src=pr&el=tree&filepath=superset%2Fsemantic_layers%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvc2VtYW50aWNfbGF5ZXJzL2FwaS5weQ==) | 0.00% | [20 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43474?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (f3142e7) and HEAD (f67f6d8). Click for more details.
   > 
   > <details><summary>HEAD has 4 uploads less than BASE</summary>
   >
   >| Flag | BASE (f3142e7) | HEAD (f67f6d8) |
   >|------|------|------|
   >|python|7|3|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #43474       +/-   ##
   ===========================================
   - Coverage   78.90%   66.08%   -12.82%     
   ===========================================
     Files        2878     2878               
     Lines      165031   165050       +19     
     Branches    38135    38140        +5     
   ===========================================
   - Hits       130218   109077    -21141     
   - Misses      32363    53757    +21394     
   + Partials     2450     2216      -234     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `38.04% <0.00%> (-0.01%)` | :arrow_down: |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.96% <0.00%> (-0.01%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.65% <0.00%> (-25.92%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.51% <0.00%> (-0.02%)` | :arrow_down: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/43474/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43474?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3856142155


##########
superset/semantic_layers/api.py:
##########
@@ -81,10 +81,51 @@
 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:

Review Comment:
   If a persisted layer's extension is removed or fails to register, this returns its decrypted configuration unchanged, so the detail and list endpoints can expose its credentials. Should the missing-connector path fail closed like the schema-load error path?



##########
superset/semantic_layers/api.py:
##########
@@ -81,10 +81,51 @@
 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
+        # We can't tell which fields are secret, so fail closed: mask every
+        # truthy value rather than risk echoing a credential back in the clear.
+        logger.warning(
+            "Failed to load configuration schema for semantic layer type %s; "
+            "masking all configuration values.",
+            layer.type,
+        )
+        return {key: PASSWORD_MASK if value else value for key, value in config.items()}
+
+    secret_keys = {
+        key
+        for key, prop in schema.get("properties", {}).items()
+        if isinstance(prop, dict) and prop.get("writeOnly")
+    }
+    if not secret_keys:
+        return config
+
+    return {
+        key: PASSWORD_MASK if key in secret_keys and value else value

Review Comment:
   Masking this value in GET means the edit modal sends the mask back in its full configuration on a name-only save, overwriting the stored credential and breaking later connections. Can the update path preserve masked fields and cover that edit round trip?



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3847325587


##########
superset/semantic_layers/api.py:
##########
@@ -677,6 +711,9 @@ def runtime_schema(self, uuid: str) -> FlaskResponse:
             404:
               $ref: '#/components/responses/404'
         """
+        if not is_feature_enabled("SEMANTIC_LAYERS"):

Review Comment:
   <!-- Bito Reply -->
   The suggestion to extract the authorization check into a helper method is a valid approach to improve maintainability by reducing code duplication. While the pattern may predate this pull request, addressing it now would improve the consistency of the codebase. You are not required to apply this suggestion if it is out of scope for your current task, but it remains a sound recommendation for future refactoring.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3869494212


##########
superset/commands/semantic_layer/update.py:
##########
@@ -43,6 +44,57 @@
 logger = logging.getLogger(__name__)
 
 
+def _unmask_configuration(
+    sl_type: str,
+    existing_raw_configuration: str | None,
+    new_configuration: dict[str, Any],
+) -> dict[str, Any]:
+    """
+    Replace ``PASSWORD_MASK`` sentinels in write-only fields of an incoming
+    update payload with the value already stored.
+
+    The GET/list endpoints mask write-only configuration values (see
+    ``superset.semantic_layers.api._mask_configuration``); a client that
+    round-trips that response back on an update (e.g. a name-only edit)
+    would otherwise overwrite the real stored credential with the literal
+    mask string.
+    """
+    cls = registry.get(sl_type)
+    if not cls:
+        return new_configuration
+
+    try:
+        schema = cls.get_configuration_schema()
+    except Exception:  # pylint: disable=broad-except
+        return new_configuration
+
+    secret_keys = {
+        key
+        for key, prop in schema.get("properties", {}).items()
+        if isinstance(prop, dict) and prop.get("writeOnly")
+    }
+    if not secret_keys:
+        return new_configuration
+
+    try:
+        existing_configuration = (
+            json.loads(existing_raw_configuration) if existing_raw_configuration else {}
+        )
+    except (TypeError, ValueError):
+        existing_configuration = {}
+
+    return {
+        key: (
+            existing_configuration[key]
+            if key in secret_keys

Review Comment:
   Good catch, the fallback masks everything, so restoring only write-only keys left non-secret fields stuck with the literal mask once the schema came back. `_unmask_configuration` now restores any field matching the sentinel, not just write-only ones.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5401278008

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | a16696210526136300fecdf7ab2658a4000f4fc5 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a8caf1dd2b8e7000886053f |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43474--superset-docs-preview.netlify.app](https://deploy-preview-43474--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQzNDc0LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.FbN8H9VhQ2rRb3wg2ExOF9tQZjex5dE-BIF4UeIEl4Q)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpLCoAgEADQu8w6yYpMukHHGH8kaA5mlER3z91bvBcop0gFVoAOVMZD783OP_1pIx7Faxaw2swIsy-VuRRCui9q21gKqW6mfYFSoxuMGZW0C-dcSsHnycH3Aw) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-43474--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5398771914

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
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>
   
   [![Use CodeAnt Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [![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=5ac12e6f599f469b82ec1da997ee36da&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=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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43474:
URL: https://github.com/apache/superset/pull/43474#issuecomment-5418194423

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers an incremental AI Review.
   - `/review full` - Manually triggers a full AI Review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3856892010


##########
superset/semantic_layers/api.py:
##########
@@ -81,10 +81,51 @@
 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:

Review Comment:
   Good catch, missing connector fell through to the raw config. `_mask_configuration` now fails closed there too, masking everything when the type isn't registered or its schema can't load.



##########
superset/semantic_layers/api.py:
##########
@@ -81,10 +81,51 @@
 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
+        # We can't tell which fields are secret, so fail closed: mask every
+        # truthy value rather than risk echoing a credential back in the clear.
+        logger.warning(
+            "Failed to load configuration schema for semantic layer type %s; "
+            "masking all configuration values.",
+            layer.type,
+        )
+        return {key: PASSWORD_MASK if value else value for key, value in config.items()}
+
+    secret_keys = {
+        key
+        for key, prop in schema.get("properties", {}).items()
+        if isinstance(prop, dict) and prop.get("writeOnly")
+    }
+    if not secret_keys:
+        return config
+
+    return {
+        key: PASSWORD_MASK if key in secret_keys and value else value

Review Comment:
   You're right, a name-only PUT would round-trip the mask straight into storage. UpdateSemanticLayerCommand now swaps masked write-only fields back to the stored value before validating and saving.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #43474:
URL: https://github.com/apache/superset/pull/43474#discussion_r3847323919


##########
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:
   Fair catch, a schema load failure was falling through to unmasked config. Fixed to fail closed and mask everything when the schema can't load.



##########
superset/semantic_layers/api.py:
##########
@@ -677,6 +711,9 @@ def runtime_schema(self, uuid: str) -> FlaskResponse:
             404:
               $ref: '#/components/responses/404'
         """
+        if not is_feature_enabled("SEMANTIC_LAYERS"):

Review Comment:
   That pattern predates this PR, this diff only adds the feature-flag check above it. Broader dedup would touch a lot more than what's in scope here.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix(semantic_layers): mask write-only config fields, gate flag-off endpoints [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe merged PR #43474:
URL: https://github.com/apache/superset/pull/43474


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org