github-advanced-security[bot] commented on code in PR #35021:
URL: https://github.com/apache/superset/pull/35021#discussion_r2590395203


##########
superset-frontend/src/pages/RedirectWarning/index.tsx:
##########
@@ -0,0 +1,240 @@
+/**
+ * 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 { useState, useEffect, useMemo, useCallback } from 'react';
+import { t } from '@superset-ui/core';
+import { styled, css, useTheme } from '@apache-superset/core/ui';
+import {
+  Button,
+  Card,
+  Checkbox,
+  Flex,
+  Typography,
+  Icons,
+} from '@superset-ui/core/components';
+
+const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+const MAX_TRUSTED_URLS = 100;
+
+const PageContainer = styled(Flex)`
+  ${({ theme }) => css`
+    height: calc(100vh - 64px);
+    background-color: ${theme.colorBgLayout};
+    padding: ${theme.padding}px;
+  `}
+`;
+
+const WarningCard = styled(Card)`
+  ${({ theme }) => css`
+    max-width: 520px;
+    width: 100%;
+    box-shadow: ${theme.boxShadowSecondary};
+  `}
+`;
+
+const WarningHeader = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.paddingLG}px ${theme.paddingXL}px;
+    border-bottom: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningBody = styled.div`
+  ${({ theme }) => css`
+    padding: ${theme.paddingXL}px;
+  `}
+`;
+
+const UrlDisplay = styled(Flex)`
+  ${({ theme }) => css`
+    background-color: ${theme.colorFillQuaternary};
+    border-radius: ${theme.borderRadiusSM}px;
+    padding: ${theme.paddingSM}px ${theme.padding}px;
+    margin-bottom: ${theme.margin}px;
+  `}
+`;
+
+const UrlText = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-family: ${theme.fontFamilyCode};
+    font-size: ${theme.fontSize}px;
+    word-break: break-all;
+  `}
+`;
+
+const TrustSection = styled(Flex)`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginSM}px;
+  `}
+`;
+
+const WarningFooter = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.padding}px ${theme.paddingXL}px;
+    background-color: ${theme.colorFillAlter};
+    border-top: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningTitle = styled(Typography.Title)`
+  && {
+    margin: 0;
+  }
+`;
+
+function normalizeUrl(url: string): string {
+  try {
+    const parsed = new URL(url);
+    const normalized =
+      parsed.origin + parsed.pathname.replace(/\/$/, '') + parsed.search;
+    return normalized;
+  } catch {
+    return url;
+  }
+}
+
+function getTrustedUrls(): string[] {
+  try {
+    const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+    return stored ? JSON.parse(stored) : [];
+  } catch {
+    return [];
+  }
+}
+
+function saveTrustedUrls(urls: string[]): void {
+  try {
+    const limitedUrls =
+      urls.length > MAX_TRUSTED_URLS ? urls.slice(-MAX_TRUSTED_URLS) : urls;
+    localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(limitedUrls));

Review Comment:
   ## Clear text storage of sensitive information
   
   This stores sensitive data returned by [a call to getTrustedUrls](1) as 
clear text.
   This stores sensitive data returned by [an access to trustedUrls](2) as 
clear text.
   
   [Show more 
details](https://github.com/apache/superset/security/code-scanning/2072)



##########
superset-frontend/src/pages/RedirectWarning/index.tsx:
##########
@@ -0,0 +1,240 @@
+/**
+ * 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 { useState, useEffect, useMemo, useCallback } from 'react';
+import { t } from '@superset-ui/core';
+import { styled, css, useTheme } from '@apache-superset/core/ui';
+import {
+  Button,
+  Card,
+  Checkbox,
+  Flex,
+  Typography,
+  Icons,
+} from '@superset-ui/core/components';
+
+const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+const MAX_TRUSTED_URLS = 100;
+
+const PageContainer = styled(Flex)`
+  ${({ theme }) => css`
+    height: calc(100vh - 64px);
+    background-color: ${theme.colorBgLayout};
+    padding: ${theme.padding}px;
+  `}
+`;
+
+const WarningCard = styled(Card)`
+  ${({ theme }) => css`
+    max-width: 520px;
+    width: 100%;
+    box-shadow: ${theme.boxShadowSecondary};
+  `}
+`;
+
+const WarningHeader = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.paddingLG}px ${theme.paddingXL}px;
+    border-bottom: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningBody = styled.div`
+  ${({ theme }) => css`
+    padding: ${theme.paddingXL}px;
+  `}
+`;
+
+const UrlDisplay = styled(Flex)`
+  ${({ theme }) => css`
+    background-color: ${theme.colorFillQuaternary};
+    border-radius: ${theme.borderRadiusSM}px;
+    padding: ${theme.paddingSM}px ${theme.padding}px;
+    margin-bottom: ${theme.margin}px;
+  `}
+`;
+
+const UrlText = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-family: ${theme.fontFamilyCode};
+    font-size: ${theme.fontSize}px;
+    word-break: break-all;
+  `}
+`;
+
+const TrustSection = styled(Flex)`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginSM}px;
+  `}
+`;
+
+const WarningFooter = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.padding}px ${theme.paddingXL}px;
+    background-color: ${theme.colorFillAlter};
+    border-top: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningTitle = styled(Typography.Title)`
+  && {
+    margin: 0;
+  }
+`;
+
+function normalizeUrl(url: string): string {
+  try {
+    const parsed = new URL(url);
+    const normalized =
+      parsed.origin + parsed.pathname.replace(/\/$/, '') + parsed.search;
+    return normalized;
+  } catch {
+    return url;
+  }
+}
+
+function getTrustedUrls(): string[] {
+  try {
+    const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+    return stored ? JSON.parse(stored) : [];
+  } catch {
+    return [];
+  }
+}
+
+function saveTrustedUrls(urls: string[]): void {
+  try {
+    const limitedUrls =
+      urls.length > MAX_TRUSTED_URLS ? urls.slice(-MAX_TRUSTED_URLS) : urls;
+    localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(limitedUrls));
+
+    const expires = new Date();
+    expires.setDate(expires.getDate() + 30);
+    document.cookie = 
`superset_trusted_urls=${encodeURIComponent(JSON.stringify(limitedUrls))}; 
expires=${expires.toUTCString()}; path=/; SameSite=Strict`;
+  } catch {
+    // Ignore storage errors
+  }
+}
+
+function isUrlTrusted(url: string): boolean {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  return trustedUrls.some(trusted => normalizeUrl(trusted) === normalizedUrl);
+}
+
+function trustUrl(url: string): void {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  const normalizedTrusted = trustedUrls.map(u => normalizeUrl(u));
+
+  if (!normalizedTrusted.includes(normalizedUrl)) {
+    trustedUrls.push(url);
+    saveTrustedUrls(trustedUrls);
+  }
+}
+
+export default function RedirectWarning() {
+  const theme = useTheme();
+  const [trustChecked, setTrustChecked] = useState(false);
+
+  const targetUrl = useMemo(() => {
+    try {
+      const params = new URLSearchParams(window.location.search);
+      const url = params.get('url') || '';
+      return decodeURIComponent(url).trim();
+    } catch {
+      return '';
+    }
+  }, []);
+
+  useEffect(() => {
+    if (targetUrl && isUrlTrusted(targetUrl)) {
+      window.location.href = targetUrl;
+    }
+  }, [targetUrl]);
+
+  const handleContinue = useCallback(() => {
+    if (trustChecked && targetUrl) {
+      trustUrl(targetUrl);
+    }
+    window.location.href = targetUrl;

Review Comment:
   ## Client-side cross-site scripting
   
   Cross-site scripting vulnerability due to [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/superset/security/code-scanning/2076)



##########
superset-frontend/src/pages/RedirectWarning/index.tsx:
##########
@@ -0,0 +1,240 @@
+/**
+ * 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 { useState, useEffect, useMemo, useCallback } from 'react';
+import { t } from '@superset-ui/core';
+import { styled, css, useTheme } from '@apache-superset/core/ui';
+import {
+  Button,
+  Card,
+  Checkbox,
+  Flex,
+  Typography,
+  Icons,
+} from '@superset-ui/core/components';
+
+const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+const MAX_TRUSTED_URLS = 100;
+
+const PageContainer = styled(Flex)`
+  ${({ theme }) => css`
+    height: calc(100vh - 64px);
+    background-color: ${theme.colorBgLayout};
+    padding: ${theme.padding}px;
+  `}
+`;
+
+const WarningCard = styled(Card)`
+  ${({ theme }) => css`
+    max-width: 520px;
+    width: 100%;
+    box-shadow: ${theme.boxShadowSecondary};
+  `}
+`;
+
+const WarningHeader = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.paddingLG}px ${theme.paddingXL}px;
+    border-bottom: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningBody = styled.div`
+  ${({ theme }) => css`
+    padding: ${theme.paddingXL}px;
+  `}
+`;
+
+const UrlDisplay = styled(Flex)`
+  ${({ theme }) => css`
+    background-color: ${theme.colorFillQuaternary};
+    border-radius: ${theme.borderRadiusSM}px;
+    padding: ${theme.paddingSM}px ${theme.padding}px;
+    margin-bottom: ${theme.margin}px;
+  `}
+`;
+
+const UrlText = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-family: ${theme.fontFamilyCode};
+    font-size: ${theme.fontSize}px;
+    word-break: break-all;
+  `}
+`;
+
+const TrustSection = styled(Flex)`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginSM}px;
+  `}
+`;
+
+const WarningFooter = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.padding}px ${theme.paddingXL}px;
+    background-color: ${theme.colorFillAlter};
+    border-top: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningTitle = styled(Typography.Title)`
+  && {
+    margin: 0;
+  }
+`;
+
+function normalizeUrl(url: string): string {
+  try {
+    const parsed = new URL(url);
+    const normalized =
+      parsed.origin + parsed.pathname.replace(/\/$/, '') + parsed.search;
+    return normalized;
+  } catch {
+    return url;
+  }
+}
+
+function getTrustedUrls(): string[] {
+  try {
+    const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+    return stored ? JSON.parse(stored) : [];
+  } catch {
+    return [];
+  }
+}
+
+function saveTrustedUrls(urls: string[]): void {
+  try {
+    const limitedUrls =
+      urls.length > MAX_TRUSTED_URLS ? urls.slice(-MAX_TRUSTED_URLS) : urls;
+    localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(limitedUrls));
+
+    const expires = new Date();
+    expires.setDate(expires.getDate() + 30);
+    document.cookie = 
`superset_trusted_urls=${encodeURIComponent(JSON.stringify(limitedUrls))}; 
expires=${expires.toUTCString()}; path=/; SameSite=Strict`;
+  } catch {
+    // Ignore storage errors
+  }
+}
+
+function isUrlTrusted(url: string): boolean {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  return trustedUrls.some(trusted => normalizeUrl(trusted) === normalizedUrl);
+}
+
+function trustUrl(url: string): void {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  const normalizedTrusted = trustedUrls.map(u => normalizeUrl(u));
+
+  if (!normalizedTrusted.includes(normalizedUrl)) {
+    trustedUrls.push(url);
+    saveTrustedUrls(trustedUrls);
+  }
+}
+
+export default function RedirectWarning() {
+  const theme = useTheme();
+  const [trustChecked, setTrustChecked] = useState(false);
+
+  const targetUrl = useMemo(() => {
+    try {
+      const params = new URLSearchParams(window.location.search);
+      const url = params.get('url') || '';
+      return decodeURIComponent(url).trim();
+    } catch {
+      return '';
+    }
+  }, []);
+
+  useEffect(() => {
+    if (targetUrl && isUrlTrusted(targetUrl)) {
+      window.location.href = targetUrl;

Review Comment:
   ## Client-side cross-site scripting
   
   Cross-site scripting vulnerability due to [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/superset/security/code-scanning/2075)



##########
superset-frontend/src/pages/RedirectWarning/index.tsx:
##########
@@ -0,0 +1,240 @@
+/**
+ * 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 { useState, useEffect, useMemo, useCallback } from 'react';
+import { t } from '@superset-ui/core';
+import { styled, css, useTheme } from '@apache-superset/core/ui';
+import {
+  Button,
+  Card,
+  Checkbox,
+  Flex,
+  Typography,
+  Icons,
+} from '@superset-ui/core/components';
+
+const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+const MAX_TRUSTED_URLS = 100;
+
+const PageContainer = styled(Flex)`
+  ${({ theme }) => css`
+    height: calc(100vh - 64px);
+    background-color: ${theme.colorBgLayout};
+    padding: ${theme.padding}px;
+  `}
+`;
+
+const WarningCard = styled(Card)`
+  ${({ theme }) => css`
+    max-width: 520px;
+    width: 100%;
+    box-shadow: ${theme.boxShadowSecondary};
+  `}
+`;
+
+const WarningHeader = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.paddingLG}px ${theme.paddingXL}px;
+    border-bottom: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningBody = styled.div`
+  ${({ theme }) => css`
+    padding: ${theme.paddingXL}px;
+  `}
+`;
+
+const UrlDisplay = styled(Flex)`
+  ${({ theme }) => css`
+    background-color: ${theme.colorFillQuaternary};
+    border-radius: ${theme.borderRadiusSM}px;
+    padding: ${theme.paddingSM}px ${theme.padding}px;
+    margin-bottom: ${theme.margin}px;
+  `}
+`;
+
+const UrlText = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-family: ${theme.fontFamilyCode};
+    font-size: ${theme.fontSize}px;
+    word-break: break-all;
+  `}
+`;
+
+const TrustSection = styled(Flex)`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginSM}px;
+  `}
+`;
+
+const WarningFooter = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.padding}px ${theme.paddingXL}px;
+    background-color: ${theme.colorFillAlter};
+    border-top: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningTitle = styled(Typography.Title)`
+  && {
+    margin: 0;
+  }
+`;
+
+function normalizeUrl(url: string): string {
+  try {
+    const parsed = new URL(url);
+    const normalized =
+      parsed.origin + parsed.pathname.replace(/\/$/, '') + parsed.search;
+    return normalized;
+  } catch {
+    return url;
+  }
+}
+
+function getTrustedUrls(): string[] {
+  try {
+    const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+    return stored ? JSON.parse(stored) : [];
+  } catch {
+    return [];
+  }
+}
+
+function saveTrustedUrls(urls: string[]): void {
+  try {
+    const limitedUrls =
+      urls.length > MAX_TRUSTED_URLS ? urls.slice(-MAX_TRUSTED_URLS) : urls;
+    localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(limitedUrls));
+
+    const expires = new Date();
+    expires.setDate(expires.getDate() + 30);
+    document.cookie = 
`superset_trusted_urls=${encodeURIComponent(JSON.stringify(limitedUrls))}; 
expires=${expires.toUTCString()}; path=/; SameSite=Strict`;
+  } catch {
+    // Ignore storage errors
+  }
+}
+
+function isUrlTrusted(url: string): boolean {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  return trustedUrls.some(trusted => normalizeUrl(trusted) === normalizedUrl);
+}
+
+function trustUrl(url: string): void {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  const normalizedTrusted = trustedUrls.map(u => normalizeUrl(u));
+
+  if (!normalizedTrusted.includes(normalizedUrl)) {
+    trustedUrls.push(url);
+    saveTrustedUrls(trustedUrls);
+  }
+}
+
+export default function RedirectWarning() {
+  const theme = useTheme();
+  const [trustChecked, setTrustChecked] = useState(false);
+
+  const targetUrl = useMemo(() => {
+    try {
+      const params = new URLSearchParams(window.location.search);
+      const url = params.get('url') || '';
+      return decodeURIComponent(url).trim();
+    } catch {
+      return '';
+    }
+  }, []);
+
+  useEffect(() => {
+    if (targetUrl && isUrlTrusted(targetUrl)) {
+      window.location.href = targetUrl;
+    }
+  }, [targetUrl]);
+
+  const handleContinue = useCallback(() => {
+    if (trustChecked && targetUrl) {
+      trustUrl(targetUrl);
+    }
+    window.location.href = targetUrl;

Review Comment:
   ## Client-side URL redirect
   
   Untrusted URL redirection depends on a [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/superset/security/code-scanning/2074)



##########
superset-frontend/src/pages/RedirectWarning/index.tsx:
##########
@@ -0,0 +1,240 @@
+/**
+ * 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 { useState, useEffect, useMemo, useCallback } from 'react';
+import { t } from '@superset-ui/core';
+import { styled, css, useTheme } from '@apache-superset/core/ui';
+import {
+  Button,
+  Card,
+  Checkbox,
+  Flex,
+  Typography,
+  Icons,
+} from '@superset-ui/core/components';
+
+const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+const MAX_TRUSTED_URLS = 100;
+
+const PageContainer = styled(Flex)`
+  ${({ theme }) => css`
+    height: calc(100vh - 64px);
+    background-color: ${theme.colorBgLayout};
+    padding: ${theme.padding}px;
+  `}
+`;
+
+const WarningCard = styled(Card)`
+  ${({ theme }) => css`
+    max-width: 520px;
+    width: 100%;
+    box-shadow: ${theme.boxShadowSecondary};
+  `}
+`;
+
+const WarningHeader = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.paddingLG}px ${theme.paddingXL}px;
+    border-bottom: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningBody = styled.div`
+  ${({ theme }) => css`
+    padding: ${theme.paddingXL}px;
+  `}
+`;
+
+const UrlDisplay = styled(Flex)`
+  ${({ theme }) => css`
+    background-color: ${theme.colorFillQuaternary};
+    border-radius: ${theme.borderRadiusSM}px;
+    padding: ${theme.paddingSM}px ${theme.padding}px;
+    margin-bottom: ${theme.margin}px;
+  `}
+`;
+
+const UrlText = styled(Typography.Text)`
+  ${({ theme }) => css`
+    font-family: ${theme.fontFamilyCode};
+    font-size: ${theme.fontSize}px;
+    word-break: break-all;
+  `}
+`;
+
+const TrustSection = styled(Flex)`
+  ${({ theme }) => css`
+    margin-bottom: ${theme.marginSM}px;
+  `}
+`;
+
+const WarningFooter = styled(Flex)`
+  ${({ theme }) => css`
+    padding: ${theme.padding}px ${theme.paddingXL}px;
+    background-color: ${theme.colorFillAlter};
+    border-top: 1px solid ${theme.colorBorderSecondary};
+  `}
+`;
+
+const WarningTitle = styled(Typography.Title)`
+  && {
+    margin: 0;
+  }
+`;
+
+function normalizeUrl(url: string): string {
+  try {
+    const parsed = new URL(url);
+    const normalized =
+      parsed.origin + parsed.pathname.replace(/\/$/, '') + parsed.search;
+    return normalized;
+  } catch {
+    return url;
+  }
+}
+
+function getTrustedUrls(): string[] {
+  try {
+    const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+    return stored ? JSON.parse(stored) : [];
+  } catch {
+    return [];
+  }
+}
+
+function saveTrustedUrls(urls: string[]): void {
+  try {
+    const limitedUrls =
+      urls.length > MAX_TRUSTED_URLS ? urls.slice(-MAX_TRUSTED_URLS) : urls;
+    localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(limitedUrls));
+
+    const expires = new Date();
+    expires.setDate(expires.getDate() + 30);
+    document.cookie = 
`superset_trusted_urls=${encodeURIComponent(JSON.stringify(limitedUrls))}; 
expires=${expires.toUTCString()}; path=/; SameSite=Strict`;
+  } catch {
+    // Ignore storage errors
+  }
+}
+
+function isUrlTrusted(url: string): boolean {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  return trustedUrls.some(trusted => normalizeUrl(trusted) === normalizedUrl);
+}
+
+function trustUrl(url: string): void {
+  const normalizedUrl = normalizeUrl(url);
+  const trustedUrls = getTrustedUrls();
+  const normalizedTrusted = trustedUrls.map(u => normalizeUrl(u));
+
+  if (!normalizedTrusted.includes(normalizedUrl)) {
+    trustedUrls.push(url);
+    saveTrustedUrls(trustedUrls);
+  }
+}
+
+export default function RedirectWarning() {
+  const theme = useTheme();
+  const [trustChecked, setTrustChecked] = useState(false);
+
+  const targetUrl = useMemo(() => {
+    try {
+      const params = new URLSearchParams(window.location.search);
+      const url = params.get('url') || '';
+      return decodeURIComponent(url).trim();
+    } catch {
+      return '';
+    }
+  }, []);
+
+  useEffect(() => {
+    if (targetUrl && isUrlTrusted(targetUrl)) {
+      window.location.href = targetUrl;

Review Comment:
   ## Client-side URL redirect
   
   Untrusted URL redirection depends on a [user-provided value](1).
   
   [Show more 
details](https://github.com/apache/superset/security/code-scanning/2073)



-- 
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