-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Release] Stage to Main #74
Conversation
JasonHowellSlavin
commented
Oct 21, 2024
- MWPW-159614 Add dynamicNav key to config #72
- MWPW-158484: Round 1 Blog Performance Improvements #73
* Performance improvement parity with bacom
const miloUtils = document.createElement('link'); | ||
|
||
miloStyles.setAttribute('as', 'style'); | ||
miloStyles.setAttribute('href', `${libs}/styles/styles.css`); |
Check warning
Code scanning / CodeQL
Client-side URL redirect Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to ensure that the branch
value is validated against a predefined list of authorized branches. This will prevent untrusted URL redirection by ensuring that only safe, known URLs are used.
- Create a list of authorized branches.
- Validate the
branch
value against this list. - If the
branch
value is not in the list, use a default safe value.
-
Copy modified lines R8-R11
@@ -7,4 +7,6 @@ | ||
const branch = new URLSearchParams(search).get('milolibs') || 'main'; | ||
if (branch === 'local') return 'http://localhost:6456/libs'; | ||
return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; | ||
const authorizedBranches = ['main', 'local', 'branch1', 'branch2']; // Add all authorized branches here | ||
if (!authorizedBranches.includes(branch)) return '/libs'; // Default to a safe value if branch is not authorized | ||
if (branch === 'local') return 'http://localhost:6456/libs'; | ||
return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; | ||
})(); |
miloStyles.setAttribute('href', `${libs}/styles/styles.css`); | ||
miloUtils.setAttribute('as', 'script'); | ||
miloUtils.setAttribute('crossorigin', 'true'); | ||
miloUtils.setAttribute('href', `${libs}/utils/utils.js`); |
Check warning
Code scanning / CodeQL
Client-side URL redirect Medium
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 3 months ago
To fix the problem, we need to ensure that the URL constructed from the search
parameter is validated against a list of authorized URLs. This can be achieved by maintaining a list of allowed branches and only constructing URLs from this list.
- Create a list of authorized branches.
- Validate the
branch
value against this list. - If the
branch
is not in the list, use a default safe value.
-
Copy modified lines R8-R9
@@ -7,2 +7,4 @@ | ||
const branch = new URLSearchParams(search).get('milolibs') || 'main'; | ||
const authorizedBranches = ['main', 'local', 'branch1', 'branch2']; // Add all authorized branches here | ||
if (!authorizedBranches.includes(branch)) return '/libs'; // Default to a safe value if branch is not authorized | ||
if (branch === 'local') return 'http://localhost:6456/libs'; |