Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WriteToken doesn't update remote #46

Closed
satwell opened this issue Dec 17, 2020 · 1 comment
Closed

WriteToken doesn't update remote #46

satwell opened this issue Dec 17, 2020 · 1 comment

Comments

@satwell
Copy link

satwell commented Dec 17, 2020

While investigating #40, I noticed that WriteToken in plugin.go doesn't actually do anything. It appears that it should be transforming a URL like https://example.com/path.git into https://user:pass@example.com/path.git based on the contents of DRONE_NETRC_USERNAME and DRONE_NETRC_PASSWORD.

But that doesn't happen, because WriteToken is a value receiver rather than a pointer receiver:

func (p Plugin) WriteToken() error {
	var err error
	p.Config.Remote, err = repo.WriteToken(
		p.Config.Remote,
		p.Netrc.Login,
		p.Netrc.Password,
	)
	return err
}

So WriteToken is just updating a copy of the config.

But just turning WriteToken into a pointer receiver would be worse. The DRONE_NETRC_* credentials are for the server you're cloning from. If you're pushing to a different server, then you're going to send the credentials for your source repo, which is probably not what you want.

I'm not that familiar with how git uses .netrc, but maybe adding the user/pass to the URL is unnecessary, since drone-git-push also writes .netrc? And .netrc has a machine name that prevents us from sending credentials to an unintended server.

@appleboy
Copy link
Owner

appleboy commented Aug 2, 2022

fixed in #50

@appleboy appleboy closed this as completed Aug 2, 2022
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

No branches or pull requests

2 participants