Explicitly disable Git credential helper (#5367)
* Explicitly disable Git credential helper
If the user running Gitea has configured a credential helper, Git
credentials might leak out of Gitea.
There are two problems with credential helpers when combined with Gitea:
1. Credentials entered by a user when doing a migration or setting up a
mirror will end up in the credential store. In the worst case, this
is the plain text file ~/.git-credentials.
2. Credentials in the credential store will be used for migrations and
mirrors by all users. For example, if user A sets up a mirror, their
credentials will be stored. If user B later sets up a mirror from the
same host and does not enter any credentials, user A's credentials
will be used.
This PR prepends -c credential.helper= to all Git commands to clear the
list of helpers. This requires at least Git version 2.9, as previous
versions will try to load an empty helper instead. For more details, see
24321375cd
* Update git module
This commit is contained in:
parent
08bf443016
commit
0222623be9
6 changed files with 51 additions and 25 deletions
5
vendor/code.gitea.io/git/command.go
generated
vendored
5
vendor/code.gitea.io/git/command.go
generated
vendored
|
@ -37,9 +37,12 @@ func (c *Command) String() string {
|
|||
|
||||
// NewCommand creates and returns a new Git Command based on given command and arguments.
|
||||
func NewCommand(args ...string) *Command {
|
||||
// Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it
|
||||
cargs := make([]string, len(GlobalCommandArgs))
|
||||
copy(cargs, GlobalCommandArgs)
|
||||
return &Command{
|
||||
name: "git",
|
||||
args: append(GlobalCommandArgs, args...),
|
||||
args: append(cargs, args...),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue