Potential fix for code scanning alert no. 6: Incomplete URL substring sanitization#469
Merged
Potential fix for code scanning alert no. 6: Incomplete URL substring sanitization#469
Conversation
… sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR replaces a simple substring check for the .ghe.com host with proper URL parsing and host validation to address a code scanning alert.
- Parse
pushUrlvia theURLconstructor and checkhost.endsWith(".ghe.com")instead of usingindexOf - Ensures the
.ghe.comcheck is applied specifically to the URL’s host component
Comments suppressed due to low confidence (1)
src/git/repository.ts:81
- [nitpick] There are no tests covering the new enterprise URL host validation. Add unit tests for valid
.ghe.comhosts, invalid URLs, and edge cases to ensure the behavior is correct and resilient.
(remote[0].pushUrl ? new URL(remote[0].pushUrl).host.endsWith(".ghe.com") : false)
konradpabjan
approved these changes
May 5, 2025
Contributor
|
It appears that this fix broke the GHE.com support for Git/SSH remote urls. I've created a bug issue: #502 If you don't have access to a ghe.com instance to try against, please ping me and I can help try the fix. 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/github/vscode-github-actions/security/code-scanning/6
To fix the issue, we need to ensure that the
.ghe.comsubstring check is replaced with a proper validation of the host component of the URL. This can be achieved by parsing the URL using theURLconstructor and then checking if the host ends with.ghe.com. This approach ensures that the validation is performed on the correct part of the URL and cannot be bypassed by embedding.ghe.comin other components of the URL.Steps to fix:
pushUrlusing theURLconstructor.hostcomponent of the URL.hostends with.ghe.comusing theendsWithmethod.Suggested fixes powered by Copilot Autofix. Review carefully before merging.