Skip to content

Potential fix for code scanning alert no. 1: Incomplete URL substring sanitization#177

Closed
neatudarius wants to merge 4 commits into
mainfrom
alert-autofix-123
Closed

Potential fix for code scanning alert no. 1: Incomplete URL substring sanitization#177
neatudarius wants to merge 4 commits into
mainfrom
alert-autofix-123

Conversation

@neatudarius

Copy link
Copy Markdown
Member

Potential fix for https://github.com/bemanproject/website/security/code-scanning/1

In general, to fix incomplete URL substring sanitization, you should parse the URL with a standard URL parser and then compare the hostname (or host) against an explicit set of allowed domains (and, if needed, their well‑defined subdomain patterns), instead of checking for substrings anywhere in the URL string.

For this specific code, the best fix without changing intended functionality is to (1) parse the url argument using the built‑in URL class, (2) inspect hostname to see whether it is one of the known YouTube hosts (youtube.com, www.youtube.com, m.youtube.com, youtu.be, etc.), and (3) only return true from shouldTransform when the hostname matches one of these allowed values. We should also ensure that getHTML derives the videoId based on the same hostname logic, so that it correctly handles both youtube.com and youtu.be URLs and is robust against malformed inputs. To avoid breaking behavior, we will preserve the existing embed generation but make the shouldTransform check more precise. Concretely, inside src/components/youtube-transformer.js, we will replace the substring logic in shouldTransform with a try { new URL(url) } catch block, extract hostname, and compare it against an allowedHosts array. We will also align the youtu.be check in getHTML to use parsed hostname (urlObj.hostname === "youtu.be") rather than the previous naive includes check, ensuring consistency. No extra imports are needed as URL is part of the Node.js / browser standard library.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

… sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@netlify

netlify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy Preview for bemanproject ready!

Name Link
🔨 Latest commit b79a413
🔍 Latest deploy log https://app.netlify.com/projects/bemanproject/deploys/6a502bc3e5d7970008f74764
😎 Deploy Preview https://deploy-preview-177--bemanproject.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Resolve conflicts by taking main for pre-commit and HomepageFeatures
(already fixed in #179). Retain CodeQL fix: parse URLs and allowlist
YouTube hostnames instead of substring matching.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants