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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Heatmap/transformProps.ts:
##########
@@ -392,10 +385,14 @@ export default function transformProps(
         let suffix = 'heatmap';
         if (typeof value === 'number') {
           if (normalizeAcross === 'x') {
-            percentage = value / totals.x[String(xValue)];
+            // Convert xValue to a key type (string or number) for totals 
lookup
+            const xKey = xValue as string | number;
+            percentage = value / totals.x[xKey];
             suffix = formattedX;
           } else if (normalizeAcross === 'y') {
-            percentage = value / totals.y[String(yValue)];
+            // Convert yValue to a key type (string or number) for totals 
lookup
+            const yKey = yValue as string | number;
+            percentage = value / totals.y[yKey];
             suffix = formattedY;
           } else {
             percentage = value / totals.total;

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>CWE-1321: Generic Object Injection Sink 
vulnerability</b></div>
   <div id="fix">
   
   Two instances of unsafe object property access using unsanitized keys 
(`xKey` and `yKey`) at lines 390 and 395. This creates a Generic Object 
Injection Sink vulnerability 
([CWE-1321](https://cwe.mitre.org/data/definitions/1321.html)). Validate or 
sanitize keys before using them for object property access.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
             let suffix = 'heatmap';
             if (typeof value === 'number') {
               if (normalizeAcross === 'x') {
                 // Convert xValue to a key type (string or number) for totals 
lookup
                 const xKey = xValue as string | number;
                 if (Object.prototype.hasOwnProperty.call(totals.x, xKey)) {
                   percentage = value / totals.x[xKey];
                 }
                 suffix = formattedX;
               } else if (normalizeAcross === 'y') {
                 // Convert yValue to a key type (string or number) for totals 
lookup
                 const yKey = yValue as string | number;
                 if (Object.prototype.hasOwnProperty.call(totals.y, yKey)) {
                   percentage = value / totals.y[yKey];
                 }
                 suffix = formattedY;
               } else {
                 percentage = value / totals.total;
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #4ef44b</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