Skip to content
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

Fix code scanning alert no. 311: Uncontrolled data used in path expression #542

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

KrzysztofPajak
Copy link
Member

Fixes https://github.com/grandnode/grandnode2/security/code-scanning/311

To fix the problem, we need to ensure that the directoryParam does not contain any path traversal characters or sequences. We can achieve this by validating the directoryParam to ensure it does not contain any ".." sequences or path separators. Additionally, we should ensure that the safeDirectoryName is a valid directory name.

  1. Validate the directoryParam to ensure it does not contain ".." or any path separators.
  2. Ensure that the safeDirectoryName is a valid directory name.
  3. Update the GetSafeFilePath method to include these validations.

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

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@KrzysztofPajak KrzysztofPajak marked this pull request as ready for review December 9, 2024 20:10
@KrzysztofPajak KrzysztofPajak merged commit a45a54b into main Dec 10, 2024
5 checks passed
@KrzysztofPajak KrzysztofPajak deleted the Autofix-311 branch December 10, 2024 17:42
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.

1 participant