codeant-ai-for-open-source[bot] commented on code in PR #42245: URL: https://github.com/apache/superset/pull/42245#discussion_r3615713774
########## superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/controlPanel.ts: ########## @@ -0,0 +1,170 @@ +/** + * 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 { t } from '@apache-superset/core/translation'; +import { ControlPanelConfig, sections } from '@superset-ui/chart-controls'; + +// Control names match the legacy nvd3 chart so saved charts keep working +// without a form-data migration. nvd3-specific pixel-margin and min/max +// toggles are intentionally dropped; ECharts lays those out automatically. +const config: ControlPanelConfig = { + controlPanelSections: [ + sections.legacyTimeseriesTime, + { + label: t('Query'), + expanded: true, + controlSetRows: [ + ['metric'], + ['adhoc_filters'], + [ + { + name: 'freq', + config: { + type: 'SelectControl', + label: t('Frequency'), + default: 'W-MON', + freeForm: true, + clearable: false, + choices: [ + ['AS', t('Year (freq=AS)')], + ['52W-MON', t('52 weeks starting Monday (freq=52W-MON)')], + ['W-SUN', t('1 week starting Sunday (freq=W-SUN)')], + ['W-MON', t('1 week starting Monday (freq=W-MON)')], + ['D', t('Day (freq=D)')], + ['4W-MON', t('4 weeks (freq=4W-MON)')], + ], + description: t( + `The periodicity over which to pivot time. Users can provide + "Pandas" offset alias. + Click on the info bubble for more details on accepted "freq" expressions.`, + ), + tooltipOnClick: () => { + window.open( + 'https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases', + ); + }, Review Comment: **Suggestion:** The external docs link is opened with `window.open` without `noopener`/`noreferrer`, which leaves `window.opener` exposed and enables reverse-tabnabbing if that destination is ever compromised. Open the URL with an explicit `noopener,noreferrer` policy (or equivalent safe helper) so the new page cannot control the originating tab. [security] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ⚠️ External docs page can redirect original Superset tab. - ⚠️ Compromised docs domain could perform phishing via opener. ``` </details> <details> <summary><b>Steps of Reproduction ✅ </b></summary> ```mdx 1. Start the Superset frontend with this PR and open the Explore view for a Time-series Period Pivot chart, which uses the control panel config exported from `superset-frontend/plugins/plugin-chart-echarts/src/TimePivot/controlPanel.ts:170`. 2. In the Explore view, locate the "Frequency" control whose configuration (including `tooltipOnClick`) is defined at `controlPanel.ts:35-61`, and click its info-bubble/tooltip icon. 3. The handler `tooltipOnClick: () => { window.open(...) }` at `controlPanel.ts:56-60` executes, opening `https://pandas.pydata.org/...#offset-aliases` in a new tab/window without specifying `noopener` or `noreferrer`. 4. In the newly opened page, JavaScript can access `window.opener` (because no `noopener` policy was set) and, if compromised, can call `window.opener.location = <malicious URL>` to redirect the original Superset tab, demonstrating reverse-tabnabbing. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=407dd2a7a8cd4eff862ff72e0fc03516&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=407dd2a7a8cd4eff862ff72e0fc03516&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-frontend/plugins/plugin-chart-echarts/src/TimePivot/controlPanel.ts **Line:** 56:60 **Comment:** *Security: The external docs link is opened with `window.open` without `noopener`/`noreferrer`, which leaves `window.opener` exposed and enables reverse-tabnabbing if that destination is ever compromised. Open the URL with an explicit `noopener,noreferrer` policy (or equivalent safe helper) so the new page cannot control the originating tab. 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%2F42245&comment_hash=2710b77fb3576d13497c237c2d9d6528b1b68e71b60adb1f25386816c0a147ad&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42245&comment_hash=2710b77fb3576d13497c237c2d9d6528b1b68e71b60adb1f25386816c0a147ad&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]
