@@ -574,11 +574,14 @@ func preReceiveSecrets(ctx *preReceiveContext, oldCommitID, newCommitID string,
574574	var  detector  * gitleaks.Detector 
575575
576576	config , _ , err  :=  git .NewCommand ("show" ).AddDynamicArguments (repo .DefaultBranch + ":.gitleaks.toml" ).RunStdString (ctx , & git.RunOpts {Dir : repo .RepoPath (), Env : ctx .env })
577- 	if  err  !=  nil  { // File has to exist to be taken into consideration 
577+ 	if  err  !=  nil  &&  config  !=  ""  { // File has to exist to be taken into consideration 
578+ 		log .Debug ("scanning with user configuration" )
578579		detector , err  =  newDetector (config )
579580	} else  {
581+ 		log .Debug ("scanning with default configuration" )
580582		detector , err  =  gitleaks .NewDetectorDefaultConfig ()
581583	}
584+ 
582585	if  err  !=  nil  {
583586		ctx .JSON (http .StatusTeapot , private.Response {Err : err .Error (), UserMsg : err .Error ()})
584587		return 
@@ -602,11 +605,11 @@ func preReceiveSecrets(ctx *preReceiveContext, oldCommitID, newCommitID string,
602605			Env :    ctx .env ,
603606			Stdout : w ,
604607			PipelineFunc : func (_  context.Context , _  context.CancelFunc ) error  {
608+ 				w .Close ()
605609				giteaCmd , err  :=  newPreReceiveDiff (r )
606610				if  err  !=  nil  {
607611					return  err 
608612				}
609- 				w .Close ()
610613				findings , err  =  detector .DetectGit (giteaCmd , gitleaks .NewRemoteInfo (scm .GitHubPlatform , repo .Website ))
611614				return  err 
612615			},
@@ -616,6 +619,7 @@ func preReceiveSecrets(ctx *preReceiveContext, oldCommitID, newCommitID string,
616619		ctx .JSON (http .StatusTeapot , private.Response {Err : err .Error (), UserMsg : err .Error ()})
617620		return 
618621	}
622+ 	log .Debug ("scan reported %v leaks, scanned: %v bytes" , len (findings ), detector .TotalBytes .Load ())
619623
620624	if  len (findings ) !=  0  {
621625		msg  :=  strings.Builder {}
0 commit comments