github-advanced-security[bot] commented on code in PR #35021:
URL: https://github.com/apache/superset/pull/35021#discussion_r2590320536
##########
superset/templates/superset/redirect_warning.html:
##########
@@ -0,0 +1,421 @@
+{#
+ 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.
+#}
+{% extends "superset/spa.html" %}
+
+{% block title %}External Link Warning{% endblock %}
+
+{% block head_css %}
+ {{ super() }}
+ <style nonce="{{ macros.get_nonce() }}">
+ /* Reset body/html backgrounds for proper theming */
+ html, body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+ background-color: #c4c4c4;
+ }
+
+ .redirect-warning-page {
+ min-height: 100vh;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #c4c4c4;
+ padding: 16px;
+ font-family: var(--font-family-sans-serif, -apple-system,
BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif);
+ }
+
+ .warning-container {
+ background: #ffffff;
+ border-radius: 8px;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
+ max-width: 520px;
+ width: 100%;
+ overflow: hidden;
+ }
+
+ .warning-header {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ padding: 20px 24px;
+ border-bottom: 1px solid #e8e8e8;
+ }
+
+ .warning-icon {
+ width: 24px;
+ height: 24px;
+ flex-shrink: 0;
+ }
+
+ .warning-icon svg {
+ width: 100%;
+ height: 100%;
+ }
+
+ .warning-title {
+ color: #333333;
+ font-size: 18px;
+ font-weight: 600;
+ margin: 0;
+ }
+
+ .warning-body {
+ padding: 24px;
+ }
+
+ .warning-text {
+ color: #666666;
+ font-size: 14px;
+ line-height: 1.5;
+ margin: 0 0 16px 0;
+ }
+
+ .url-display {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ background-color: #f5f5f5;
+ border-radius: 4px;
+ padding: 12px 14px;
+ margin-bottom: 16px;
+ }
+
+ .url-display-icon {
+ color: #999999;
+ flex-shrink: 0;
+ }
+
+ .url-display-icon svg {
+ width: 16px;
+ height: 16px;
+ display: block;
+ }
+
+ .url-display-text {
+ font-family: var(--font-family-monospace, 'SF Mono', 'Consolas',
'Monaco', monospace);
+ font-size: 14px;
+ color: #333333;
+ word-break: break-all;
+ }
+
+ .trust-section {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ margin-bottom: 12px;
+ }
+
+ .trust-checkbox {
+ width: 16px;
+ height: 16px;
+ cursor: pointer;
+ accent-color: #20a7c9;
+ }
+
+ .trust-label {
+ font-size: 14px;
+ color: #333333;
+ cursor: pointer;
+ user-select: none;
+ }
+
+ .disclaimer {
+ font-size: 13px;
+ color: #999999;
+ margin: 0;
+ }
+
+ .warning-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 12px;
+ padding: 16px 24px;
+ background-color: #f9f9f9;
+ border-top: 1px solid #e8e8e8;
+ }
+
+ .warning-btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ padding: 10px 20px;
+ border-radius: 4px;
+ text-decoration: none;
+ font-weight: 500;
+ font-size: 14px;
+ cursor: pointer;
+ transition: all 0.2s ease;
+ border: none;
+ }
+
+ .btn-secondary {
+ background-color: transparent;
+ color: #20a7c9;
+ border: none;
+ }
+
+ .btn-secondary:hover {
+ background-color: rgba(32, 167, 201, 0.08);
+ color: #1a91b8;
+ text-decoration: none;
+ }
+
+ .btn-primary {
+ background-color: #3cc9a8;
+ color: #ffffff;
+ }
+
+ .btn-primary:hover {
+ background-color: #2fb898;
+ color: #ffffff;
+ text-decoration: none;
+ }
+
+ /* Dark mode overrides */
+ @media (prefers-color-scheme: dark) {
+ html, body {
+ background-color: #1a1a1a;
+ }
+ .redirect-warning-page {
+ background-color: #1a1a1a;
+ }
+ .warning-container {
+ background: #2e2e2e;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
+ }
+ .warning-header {
+ border-bottom-color: #404040;
+ }
+ .warning-title {
+ color: #ffffff;
+ }
+ .warning-text {
+ color: #b3b3b3;
+ }
+ .url-display {
+ background-color: #1a1a1a;
+ }
+ .url-display-text {
+ color: #ffffff;
+ }
+ .url-display-icon {
+ color: #666666;
+ }
+ .trust-label {
+ color: #e0e0e0;
+ }
+ .disclaimer {
+ color: #888888;
+ }
+ .warning-footer {
+ background-color: #252525;
+ border-top-color: #404040;
+ }
+ .btn-secondary {
+ color: #4dd4e8;
+ }
+ .btn-secondary:hover {
+ background-color: rgba(77, 212, 232, 0.1);
+ color: #6de0f0;
+ }
+ }
+
+ /* Explicit dark mode class support (for Superset's theme toggle) */
+ body.dark,
+ html[data-theme="dark"],
+ body[data-theme="dark"] {
+ background-color: #1a1a1a;
+ }
+ body.dark .redirect-warning-page,
+ [data-theme="dark"] .redirect-warning-page {
+ background-color: #1a1a1a;
+ }
+ body.dark .warning-container,
+ [data-theme="dark"] .warning-container {
+ background: #2e2e2e;
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
+ }
+ body.dark .warning-header,
+ [data-theme="dark"] .warning-header {
+ border-bottom-color: #404040;
+ }
+ body.dark .warning-title,
+ [data-theme="dark"] .warning-title {
+ color: #ffffff;
+ }
+ body.dark .warning-text,
+ [data-theme="dark"] .warning-text {
+ color: #b3b3b3;
+ }
+ body.dark .url-display,
+ [data-theme="dark"] .url-display {
+ background-color: #1a1a1a;
+ }
+ body.dark .url-display-text,
+ [data-theme="dark"] .url-display-text {
+ color: #ffffff;
+ }
+ body.dark .url-display-icon,
+ [data-theme="dark"] .url-display-icon {
+ color: #666666;
+ }
+ body.dark .trust-label,
+ [data-theme="dark"] .trust-label {
+ color: #e0e0e0;
+ }
+ body.dark .disclaimer,
+ [data-theme="dark"] .disclaimer {
+ color: #888888;
+ }
+ body.dark .warning-footer,
+ [data-theme="dark"] .warning-footer {
+ background-color: #252525;
+ border-top-color: #404040;
+ }
+ body.dark .btn-secondary,
+ [data-theme="dark"] .btn-secondary {
+ color: #4dd4e8;
+ }
+ body.dark .btn-secondary:hover,
+ [data-theme="dark"] .btn-secondary:hover {
+ background-color: rgba(77, 212, 232, 0.1);
+ color: #6de0f0;
+ }
+ </style>
+{% endblock %}
+
+{% block body %}
+<div class="redirect-warning-page">
+ <div class="warning-container">
+ <div class="warning-header">
+ <div class="warning-icon">
+ <svg viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg">
+ <path d="M12 9V13M12 17H12.01M10.29 3.86L1.82 18C1.64 18.3 1.55
18.64 1.55 19C1.55 19.36 1.64 19.7 1.82 20C2 20.3 2.26 20.56 2.56 20.74C2.86
20.92 3.21 21.01 3.56 21H20.44C20.79 21.01 21.14 20.92 21.44 20.74C21.74 20.56
22 20.3 22.18 20C22.36 19.7 22.45 19.36 22.45 19C22.45 18.64 22.36 18.3 22.18
18L13.71 3.86C13.53 3.56 13.27 3.32 12.97 3.15C12.67 2.98 12.34 2.89 12
2.89C11.66 2.89 11.33 2.98 11.03 3.15C10.73 3.32 10.47 3.56 10.29 3.86Z"
stroke="#F5A623" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"/>
+ </svg>
+ </div>
+ <h1 class="warning-title">External link warning</h1>
+ </div>
+
+ <div class="warning-body">
+ <p class="warning-text">This link will take you to an external website.
We cannot guarantee the safety of external destinations.</p>
+
+ <div class="url-display">
+ <span class="url-display-icon">
+ <svg viewBox="0 0 16 16" fill="none"
xmlns="http://www.w3.org/2000/svg">
+ <path d="M12 8.66667V12.6667C12 13.0203 11.8595 13.3594 11.6095
13.6095C11.3594 13.8595 11.0203 14 10.6667 14H3.33333C2.97971 14 2.64057
13.8595 2.39052 13.6095C2.14048 13.3594 2 13.0203 2 12.6667V5.33333C2 4.97971
2.14048 4.64057 2.39052 4.39052C2.64057 4.14048 2.97971 4 3.33333 4H7.33333"
stroke="currentColor" stroke-width="1.33" stroke-linecap="round"
stroke-linejoin="round"/>
+ <path d="M10 2H14V6" stroke="currentColor" stroke-width="1.33"
stroke-linecap="round" stroke-linejoin="round"/>
+ <path d="M6.66666 9.33333L14 2" stroke="currentColor"
stroke-width="1.33" stroke-linecap="round" stroke-linejoin="round"/>
+ </svg>
+ </span>
+ <span class="url-display-text">{{ target_url }}</span>
+ </div>
+
+ <div class="trust-section">
+ <input type="checkbox" id="trustUrl" class="trust-checkbox">
+ <label for="trustUrl" class="trust-label">Trust this exact URL and
don't ask again</label>
+ </div>
+
+ <p class="disclaimer">Only proceed if you trust the destination or its
source.</p>
+ </div>
+
+ <div class="warning-footer">
+ <a href="/" class="warning-btn btn-secondary">Return to Superset</a>
+ <a href="{{ target_url }}" id="continueBtn" class="warning-btn
btn-primary" target="_blank" rel="noopener noreferrer">Continue</a>
+ </div>
+ </div>
+</div>
+
+<script nonce="{{ macros.get_nonce() }}">
+(function() {
+ const TRUSTED_URLS_KEY = 'superset_trusted_urls';
+ const MAX_TRUSTED_URLS = 100;
+
+ const targetUrl = {{ target_url|tojson }};
+
+ function normalizeUrl(url) {
+ try {
+ const parsed = new URL(url);
+ let normalized = parsed.origin + parsed.pathname.replace(/\/$/, '') +
parsed.search;
+ return normalized;
+ } catch (e) {
+ return url;
+ }
+ }
+
+ function getTrustedUrls() {
+ try {
+ const stored = localStorage.getItem(TRUSTED_URLS_KEY);
+ return stored ? JSON.parse(stored) : [];
+ } catch (e) {
+ console.error('Error loading trusted URLs:', e);
+ return [];
+ }
+ }
+
+ function saveTrustedUrls(urls) {
+ try {
+ if (urls.length > MAX_TRUSTED_URLS) {
+ urls = urls.slice(-MAX_TRUSTED_URLS);
+ }
+ localStorage.setItem(TRUSTED_URLS_KEY, JSON.stringify(urls));
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/2071)
--
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]