Currently, the code responsible for injecting credentials into the REPOLIST_GIT URL simply replaces 'https://' with a version containing the token. This approach may not handle all possible URL formats and could fail or produce invalid URLs in cases where:
- The URL does not start with 'https://'
- The URL already includes credentials
- There are other edge cases in URL formatting
To make credential injection more robust and secure, we should refactor this logic to use a URL parsing library (such as Python's urllib.parse). This will allow us to safely inject credentials only when appropriate (e.g., when the scheme is 'https' and no credentials are present), and reconstruct the URL in a standards-compliant way.
Suggested action items:
- Refactor the credential injection logic to use
urllib.parse for parsing and reconstructing the URL.
- Ensure credentials are only injected when the scheme is 'https' and no credentials are already present.
- Add tests to cover various URL formats and edge cases.
This will improve the reliability and security of the repository cloning process, especially when using personal access tokens or other credentials.
I created this issue for @psegedy from #1347 (comment).
Tips and commands
Getting Help
Currently, the code responsible for injecting credentials into the
REPOLIST_GITURL simply replaces 'https://' with a version containing the token. This approach may not handle all possible URL formats and could fail or produce invalid URLs in cases where:To make credential injection more robust and secure, we should refactor this logic to use a URL parsing library (such as Python's
urllib.parse). This will allow us to safely inject credentials only when appropriate (e.g., when the scheme is 'https' and no credentials are present), and reconstruct the URL in a standards-compliant way.Suggested action items:
urllib.parsefor parsing and reconstructing the URL.This will improve the reliability and security of the repository cloning process, especially when using personal access tokens or other credentials.
I created this issue for @psegedy from #1347 (comment).
Tips and commands
Getting Help