fix(python-sdk): percent-encode git credentials in clone URL#1503
Open
Osamaali313 wants to merge 1 commit into
Open
fix(python-sdk): percent-encode git credentials in clone URL#1503Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
with_credentials embedded the username and password into the Git URL raw, so a username or token containing URL-significant characters (@, /, :, space, ...) produced a malformed URL — e.g. a password 'p@ss' yielded 'https://user:p@ss@host/...', which git parses with host 'ss@host' and rejects. The JS SDK percent-encodes via the URL username/password setters, so the two SDKs disagreed. Encode both with urllib.parse.quote(safe=''). Adds tests.
|
We require contributors to sign our Contributor License Agreement, and we don't have @Osamaali313 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check' |
🦋 Changeset detectedLatest commit: 16ab4a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
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.
Problem
with_credentials(packages/python-sdk/e2b/sandbox/_git/auth.py) embeds the username and password into the Git URL raw:When the username/token contains URL-significant characters (
@,/,:, space, …) the URL is malformed. A passwordp@ssproduceshttps://user:p@ss@github.com/org/repo.git, which git parses with hostss@github.comand rejects:The JS SDK builds the URL via the
URLusername/password setters, which do percent-encode — so the two SDKs disagree and the Python one breaks on real-world tokens.Reproduction
with_credentials("https://github.com/o/r.git", "user", "p@ss")→https://user:p@ss@github.com/o/r.git(before) vshttps://user:p%40ss@github.com/o/r.git(after, matching JS).Reachable via
Sandbox.git.clone(url, username=..., password=...)andgit.dangerously_authenticate(...).Fix
Percent-encode both credentials with
urllib.parse.quote(..., safe='').strip_credentialsstill round-trips the encoded URL back to the clean one.Tests
Adds
packages/python-sdk/tests/shared/git/test_auth.py(encoding of special chars, strip round-trip, no-credentials passthrough). Changeset included.