bito-code-review[bot] commented on code in PR #30827:
URL: https://github.com/apache/superset/pull/30827#discussion_r3205131500


##########
superset-frontend/plugins/plugin-chart-table/src/transformProps.ts:
##########
@@ -244,6 +245,9 @@ const processColumns = memoizeOne(function processColumns(
       const config = columnConfig[key] || {};
       // for the purpose of presentation, only numeric values are treated as 
metrics
       // because users can also add things like `MAX(str_col)` as a metric.
+      const isFilterable = columnConfigs.find(
+        c => c.column_name === key,
+      )?.filterable;
       const isMetric = metricsSet.has(key) && isNumeric(key, records);
       const isPercentMetric = percentMetricsSet.has(key);
       const label =

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Unsafe object property access via dynamic key</b></div>
   <div id="fix">
   
   The code uses dynamic property access on `columnConfigs` array with 
`c.column_name === key` where `key` is user-controlled data. This creates a 
potential object injection vulnerability. Use a safer lookup method or validate 
the key against a whitelist of allowed column names.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
         const config = columnConfig[key] || {};
         // for the purpose of presentation, only numeric values are treated as 
metrics
         // because users can also add things like `MAX(str_col)` as a metric.
         // Validate key to prevent object injection
         const isFilterable = (typeof key === 'string' && key.length > 0)
           ? columnConfigs.find(
               c => c.column_name === key,
             )?.filterable
           : undefined;
         const isMetric = metricsSet.has(key) && isNumeric(key, records);
         const isPercentMetric = percentMetricsSet.has(key);
         const label =
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #92bbca</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]

Reply via email to