Python script that randomizes various things in DK64. See the readme for current options that are available to be randomized as well as other features.
To fix the problem, we need to ensure that the constructed file path is securely validated. This involves normalizing the path and ensuring it remains within the intended directory. We will use os.path.normpath to normalize the path and then check that the normalized path starts with the intended base directory. This approach will prevent directory traversal attacks by ensuring that any ".." segments are resolved and the path remains within the allowed directory.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Fixes https://github.com/2dos/DK64-Randomizer/security/code-scanning/24
To fix the problem, we need to ensure that the constructed file path is securely validated. This involves normalizing the path and ensuring it remains within the intended directory. We will use
os.path.normpath
to normalize the path and then check that the normalized path starts with the intended base directory. This approach will prevent directory traversal attacks by ensuring that any ".." segments are resolved and the path remains within the allowed directory.Suggested fixes powered by Copilot Autofix. Review carefully before merging.