codeant-ai-for-open-source[bot] commented on code in PR #42803:
URL: https://github.com/apache/superset/pull/42803#discussion_r3740354648


##########
superset/daos/dataset.py:
##########
@@ -630,7 +630,7 @@ def find_dataset_metric(cls, dataset_id: int, metric_id: 
int) -> SqlMetric | Non
         dataset = DatasetDAO.find_by_id(dataset_id)
         if not dataset:
             return None
-        return db.session.query(SqlMetric).get(metric_id)
+        return db.session.get(SqlMetric, metric_id)

Review Comment:
   **Suggestion:** Dataset scoping is lost here: after confirming that 
`dataset_id` exists, `db.session.get(SqlMetric, metric_id)` can return a metric 
whose `table_id` belongs to a different dataset. Callers such as metric 
deletion then operate on that unrelated metric, bypassing the dataset ownership 
implied by the method arguments. Filter the metric by both `table_id == 
dataset_id` and `id == metric_id`. [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Dataset metric deletion can affect another dataset.
   - ⚠️ Invalid or malicious metric IDs bypass dataset ownership matching.
   - ⚠️ Dataset APIs return inconsistent column and metric scoping.
   ```
   </details>
   
   [![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=8ef16173caa5459e916145d2e778df0a&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=8ef16173caa5459e916145d2e778df0a&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/daos/dataset.py
   **Line:** 633:633
   **Comment:**
        *Api Mismatch: Dataset scoping is lost here: after confirming that 
`dataset_id` exists, `db.session.get(SqlMetric, metric_id)` can return a metric 
whose `table_id` belongs to a different dataset. Callers such as metric 
deletion then operate on that unrelated metric, bypassing the dataset ownership 
implied by the method arguments. Filter the metric by both `table_id == 
dataset_id` and `id == metric_id`.
   
   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%2F42803&comment_hash=3778e9b91c5e40c7aa92dd41ae5ce98a4042f05666a201e8d3a9678272184f71&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42803&comment_hash=3778e9b91c5e40c7aa92dd41ae5ce98a4042f05666a201e8d3a9678272184f71&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]

Reply via email to