mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Refactor git command arguments and make all arguments to be safe to be used (#21535)
Follow #21464 Make all git command arguments strictly safe. Most changes are one-to-one replacing, keep all existing logic.
This commit is contained in:
		@@ -12,6 +12,7 @@ import (
 | 
			
		||||
	git_model "code.gitea.io/gitea/models/git"
 | 
			
		||||
	user_model "code.gitea.io/gitea/models/user"
 | 
			
		||||
	"code.gitea.io/gitea/models/webhook"
 | 
			
		||||
	"code.gitea.io/gitea/modules/git"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
	"code.gitea.io/gitea/services/auth"
 | 
			
		||||
	"code.gitea.io/gitea/services/migrations"
 | 
			
		||||
@@ -58,7 +59,12 @@ func registerRepoHealthCheck() {
 | 
			
		||||
		Args:    []string{},
 | 
			
		||||
	}, func(ctx context.Context, _ *user_model.User, config Config) error {
 | 
			
		||||
		rhcConfig := config.(*RepoHealthCheckConfig)
 | 
			
		||||
		return repo_service.GitFsck(ctx, rhcConfig.Timeout, rhcConfig.Args)
 | 
			
		||||
		// the git args are set by config, they can be safe to be trusted
 | 
			
		||||
		args := make([]git.CmdArg, 0, len(rhcConfig.Args))
 | 
			
		||||
		for _, arg := range rhcConfig.Args {
 | 
			
		||||
			args = append(args, git.CmdArg(arg))
 | 
			
		||||
		}
 | 
			
		||||
		return repo_service.GitFsck(ctx, rhcConfig.Timeout, args)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user