Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

nil pointer dereference when connecting to SSH based URLs with invalid proxy address #900

Copy link
Copy link
Closed
@anandf

Description

@anandf
Issue body actions

When trying to list references from a remote git repository, through a socks5 proxy, there is a nil pointer dereference operation causing the code to panic. In the below code, I am setting proxy server url as socks5://127.0.0.1:1080. If the proxy server is running, then the code behaves correctly, but if the proxy server is not running, the code panics at this line of code session, err := gitClient.NewUploadPackSession(ep, auth)

Reproducer code:

package main

import (
	"fmt"

	"github.com/go-git/go-git/v5/plumbing/transport"
	"github.com/go-git/go-git/v5/plumbing/transport/client"
	"github.com/go-git/go-git/v5/plumbing/transport/ssh"
)

func main() {
	ep, err := transport.NewEndpoint("git@github.com:anandf/openshift-gitops-microshift.git")
	if err != nil {
		fmt.Println(err)
		return
	}
	ep.Proxy = transport.ProxyOptions{URL: "socks5://127.0.0.1:1080"}
	gitClient, err := client.NewClient(ep)
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
	auth, err := ssh.NewPublicKeysFromFile("git", "/home/anjoseph/.ssh/id_rsa", "")
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
	session, err := gitClient.NewUploadPackSession(ep, auth)
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
	ar, err := session.AdvertisedReferences()
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
	allRefs, err := ar.AllReferences()
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
	fmt.Println(allRefs)
	err = session.Close()
	if err != nil {
		fmt.Println("Error:" + err.Error())
		return
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.