react-play is an opensource platform that helps you learn ReactJS faster with hands-on practice model. It is a collection of projects that you can use to learn ReactJS.
To fix the problem, we should avoid using window.location.href directly to construct URLs. Instead, we can use a predefined list of allowed hostnames and validate the current hostname against this list. If the hostname is not in the list, we should not construct the URL.
Create a list of allowed hostnames.
Modify the getHostName function to check if the current hostname is in the allowed list.
If the hostname is not allowed, return a safe default value or handle the error appropriately.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Fixes https://github.com/reactplay/react-play/security/code-scanning/9
To fix the problem, we should avoid using
window.location.href
directly to construct URLs. Instead, we can use a predefined list of allowed hostnames and validate the current hostname against this list. If the hostname is not in the list, we should not construct the URL.getHostName
function to check if the current hostname is in the allowed list.Suggested fixes powered by Copilot Autofix. Review carefully before merging.