bito-code-review[bot] commented on code in PR #40003:
URL: https://github.com/apache/superset/pull/40003#discussion_r3215702656
##########
superset-frontend/src/dashboard/components/nativeFilters/selectors.ts:
##########
@@ -141,9 +141,17 @@ const selectIndicatorsForChartFromFilter = (
}));
};
+const getQueryFilterMetadata = (
+ chart: any,
+ metadataKey: 'applied_filters' | 'rejected_filters',
+) =>
+ ensureIsArray(chart?.queriesResponse).flatMap(
+ queryResponse => queryResponse?.[metadataKey] || [],
+ );
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>CWE-1321: Dynamic object property access without
validation</b></div>
<div id="fix">
Line 149 uses dynamic property access `queryResponse?.[metadataKey]` where
`metadataKey` is a parameter. This is flagged as a potential object injection
vulnerability ([CWE-1321](https://cwe.mitre.org/data/definitions/1321.html)).
Since `metadataKey` is constrained to a union type ('applied_filters' |
'rejected_filters'), consider using explicit property access or adding runtime
validation to prevent unintended property access.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
const getQueryFilterMetadata = (
chart: any,
metadataKey: 'applied_filters' | 'rejected_filters',
) =>
ensureIsArray(chart?.queriesResponse).flatMap(
queryResponse => (
metadataKey === 'applied_filters' ? queryResponse?.applied_filters :
queryResponse?.rejected_filters
) || [],
);
````
</div>
</details>
</div>
<small><i>Code Review Run #694f2e</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]