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:
		
							parent
							
								
									4eeea7b30e
								
							
						
					
					
						commit
						dcd9fc7ee8
					
				
					 71 changed files with 425 additions and 391 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue