Skip to content

Conversation

@darkowlzz
Copy link
Contributor

@darkowlzz darkowlzz commented Nov 7, 2021

Before this change, the commands sent to the git server were of the form:

git-upload-pack "/bar/test-reponame"

This resulted in the git server (gitkit) returning error:
error parsing command: invalid git command

This change replaces the double quotes with single quotes:

git-upload-pack '/bar/test-reponame'

Using git smart transport via managed ssh transport against gitkit, fails with the following errors:

2021/11/07 21:57:24 ssh: incoming exec request: git-upload-pack "/bar/test-reponame"
2021/11/07 21:57:24 ssh: payload 'git-upload-pack "/bar/test-reponame"'
2021/11/07 21:57:24 ssh: error parsing command: invalid git command

Resulting in a clone failure: unable to clone: EOF.

Using ssh transport based on the libgit2 libraries work with gitkit.
Upon further investigation, I found that gitkit has a regular expression for parsing the commands and it fails to parse commands with " (double quote). Replacing the double quotes with single quote fixes the issue.
It felt like a bug in gitkit itself. So I wasn't sure if we should fix it in git2go. But after going through the libgit2 code, I found that the libgit2 implementation also uses single quotes, refer: https://github.com/libgit2/libgit2/blob/358a60e1b46000ea99ef10b4dd709e92f75ff74b/src/transports/ssh.c#L96-L99.

I guess it'd be better if we are consistent with libgit2 to maintain compatibility.

Copy link
Contributor

@lhchavez lhchavez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for this change! there's a small vulnerability being introduced, but once that's addressed, 👍!

@darkowlzz darkowlzz force-pushed the ssh-go-transport-fix branch from 0d4b36c to 5078688 Compare November 7, 2021 19:50
@darkowlzz darkowlzz force-pushed the ssh-go-transport-fix branch from 5078688 to bc0bbe9 Compare November 7, 2021 20:02
Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```
@lhchavez lhchavez merged commit 6cea7a7 into libgit2:main Nov 7, 2021
github-actions bot pushed a commit that referenced this pull request Nov 7, 2021
…git2 (#852)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)
github-actions bot pushed a commit that referenced this pull request Nov 7, 2021
…git2 (#852)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)
github-actions bot pushed a commit that referenced this pull request Nov 7, 2021
…git2 (#852)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)
github-actions bot pushed a commit that referenced this pull request Nov 7, 2021
…git2 (#852)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)
github-actions bot pushed a commit that referenced this pull request Nov 7, 2021
…git2 (#852)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)
@darkowlzz darkowlzz deleted the ssh-go-transport-fix branch November 7, 2021 20:30
lhchavez added a commit that referenced this pull request Nov 9, 2021
…git2 (#852) (#853)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)

Co-authored-by: Sunny <[email protected]>
Co-authored-by: lhchavez <[email protected]>
lhchavez added a commit that referenced this pull request Nov 9, 2021
…git2 (#852) (#854)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)

Co-authored-by: Sunny <[email protected]>
Co-authored-by: lhchavez <[email protected]>
lhchavez added a commit that referenced this pull request Nov 9, 2021
…git2 (#852) (#855)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)

Co-authored-by: Sunny <[email protected]>
Co-authored-by: lhchavez <[email protected]>
lhchavez added a commit that referenced this pull request Nov 9, 2021
…git2 (#852) (#856)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)

Co-authored-by: Sunny <[email protected]>
Co-authored-by: lhchavez <[email protected]>
lhchavez added a commit that referenced this pull request Nov 9, 2021
…git2 (#852) (#857)

* Fix ssh commands used in go SmartSubtransport

Before the fix, the commands sent were of the form:

```
git-upload-pack "/bar/test-reponame"
```

This resulted in the git server returning error:
`error parsing command: invalid git command`

This change replaces the double quotes with single quotes:

```
git-upload-pack '/bar/test-reponame'
```

* Update ssh.go

Co-authored-by: lhchavez <[email protected]>
(cherry picked from commit 6cea7a7)

Co-authored-by: Sunny <[email protected]>
Co-authored-by: lhchavez <[email protected]>
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.

2 participants