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


##########
superset-frontend/plugins/plugin-chart-echarts/src/Candlestick/transformProps.ts:
##########
@@ -0,0 +1,194 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  getMetricLabel,
+  getNumberFormatter,
+  getTimeFormatter,
+  getXAxisLabel,
+  isPhysicalColumn,
+  isDefined,
+  getXAxisColumn,
+} from '@superset-ui/core';
+import type { EChartsCoreOption, CandlestickSeriesOption } from 'echarts';
+import type { CallbackDataParams } from 'echarts/types/src/util/types';
+import {
+  CandlestickChartTransformedProps,
+  EchartsCandlestickChartProps,
+} from './types';
+import { defaultGrid, defaultYAxis } from '../defaults';
+import { getColtypesMapping, sanitizeHtml } from '../utils/series';
+import { getDefaultTooltip } from '../utils/tooltip';
+import { Refs } from '../types';
+
+export default function transformProps(
+  chartProps: EchartsCandlestickChartProps,
+): CandlestickChartTransformedProps {
+  const { width, height, formData, queriesData, hooks, filterState } = 
chartProps;
+  const { data = [], verboseMap = {} } = queriesData[0];
+  const { setDataMask = () => {}, emitCrossFilters, onContextMenu } = hooks;
+  const coltypeMapping = getColtypesMapping(queriesData[0]);
+  const refs: Refs = {} as Refs;
+
+  const {
+    open: openMetric,
+    close: closeMetric,
+    low: lowMetric,
+    high: highMetric,
+    zoomable,
+  } = formData;
+
+  const openLabel = getMetricLabel(openMetric);
+  const closeLabel = getMetricLabel(closeMetric);
+  const lowLabel = getMetricLabel(lowMetric);
+  const highLabel = getMetricLabel(highMetric);
+  
+  let xAxisLabel = getXAxisLabel(chartProps.rawFormData) || '__timestamp';
+  if (
+    isPhysicalColumn(chartProps.rawFormData?.x_axis) &&
+    isDefined(verboseMap[xAxisLabel])
+  ) {
+    xAxisLabel = verboseMap[xAxisLabel];
+  }

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>CWE-1321: Object injection vulnerability via dynamic 
property access</b></div>
   <div id="fix">
   
   Lines 64 and 66 use dynamic property access on `verboseMap` object without 
validation, creating an object injection vulnerability 
([CWE-1321](https://cwe.mitre.org/data/definitions/1321.html)). Validate or 
sanitize `xAxisLabel` before using it as an object key to prevent potential 
security issues.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
   let xAxisLabel = getXAxisLabel(chartProps.rawFormData) || '__timestamp';
   if (
     isPhysicalColumn(chartProps.rawFormData?.x_axis) &&
     isDefined(verboseMap[xAxisLabel]) &&
     Object.prototype.hasOwnProperty.call(verboseMap, xAxisLabel)
   ) {
     const safeLabel = verboseMap[xAxisLabel];
     if (typeof safeLabel === 'string') {
       xAxisLabel = safeLabel;
     }
   }
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #e426aa</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