Skip to content

Fix code scanning alert no. 2: Incomplete URL substring sanitization #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

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

guruh46
Copy link
Owner

@guruh46 guruh46 commented Nov 27, 2024

Fixes https://github.com/guruh46/vscode-gitlens/security/code-scanning/2

To fix the problem, we need to parse the URL and check its host value against a whitelist of allowed hosts. This ensures that the check handles arbitrary subdomain sequences correctly and prevents malicious URLs from bypassing the security check.

  1. Parse the URL using the url module to extract the host.
  2. Check if the host is in a predefined list of allowed hosts.
  3. Update the getHeaders method to use this new check.

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>
@guruh46 guruh46 marked this pull request as ready for review November 27, 2024 11:26
@guruh46 guruh46 merged commit 22479a8 into main Nov 27, 2024
6 checks passed
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